Merge pull request #276 from recp/cmake-fix-buildtype

cmake: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory
This commit is contained in:
Recep Aslantas
2023-01-27 21:01:54 +03:00
committed by GitHub

View File

@@ -41,7 +41,9 @@ else()
add_compile_options(-Wall -Werror -O3) add_compile_options(-Wall -Werror -O3)
endif() 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.") 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(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui # Set the possible values of build type for cmake-gui