set CMAKE_BUILD_TYPE only in top-level project (#3480)

pull/3486/head
Ashish Ahuja 1 month ago committed by GitHub
parent 486b55554f
commit dd3ca04a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -19,7 +19,11 @@ include(GNUInstallDirs)
# Set default build to release
# ---------------------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
# Set CMAKE_BUILD_TYPE only if this project is top-level
if((DEFINED PROJECT_IS_TOP_LEVEL AND PROJECT_IS_TOP_LEVEL)
OR (NOT DEFINED PROJECT_IS_TOP_LEVEL AND CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR))
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif()
endif()
# ---------------------------------------------------------------------------------------

Loading…
Cancel
Save