Skip to content

Commit

Permalink
Refactor CMake Build Directory Check
Browse files Browse the repository at this point in the history
This resolves the issue where the previous method using `get_property` would erroneously trigger an error when executing `cmake -B /path/to/dir`.
  • Loading branch information
santiago046 committed May 3, 2024
1 parent 1ef7a32 commit 82469be
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ project(


# Prevent cmake from running in the root directory to avoid replacing the original Makefile
get_property(not_top DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT not_top)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Generating CMake build files in the project root directory is not allowed. Please create a new directory and run cmake from there, or use the command 'cmake -B /path/to/build_directory' to specify a build directory.")
endif()

Expand Down

0 comments on commit 82469be

Please sign in to comment.