Skip to content

Commit

Permalink
Merge pull request #276 from recp/cmake-fix-buildtype
Browse files Browse the repository at this point in the history
cmake: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory
  • Loading branch information
recp authored Jan 27, 2023
2 parents 7f1c062 + 9fc3a20 commit c51040c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ else()
add_compile_options(-Wall -Werror -O3)
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
get_directory_property(hasParent PARENT_DIRECTORY)

if(NOT hasParent AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
Expand Down

0 comments on commit c51040c

Please sign in to comment.