summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-05-16 11:33:22 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-05-16 11:33:35 (GMT)
commit7a390edefbc5de670f9b5cab60d282df2e22f548 (patch)
treee69a4a4e58ce6d9170fb8b062f638850201a0252 /Modules
parentc51d9550e7c64bad2762abe9d2d2e3f34e4fffca (diff)
parent10865c8e5f0854699b898a4c9066856906b7a6a6 (diff)
downloadCMake-7a390edefbc5de670f9b5cab60d282df2e22f548.zip
CMake-7a390edefbc5de670f9b5cab60d282df2e22f548.tar.gz
CMake-7a390edefbc5de670f9b5cab60d282df2e22f548.tar.bz2
Merge topic 'fetchcontent-subbuild-config-type'
10865c8e5f FetchContent: Hard-code a config for the sub-build Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !7228
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FetchContent.cmake13
1 files changed, 11 insertions, 2 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 1b81778..b92c679 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1351,6 +1351,14 @@ ExternalProject_Add_Step(${contentName}-populate copyfile
list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
endif()
+ # Override the sub-build's configuration types for multi-config generators.
+ # This ensures we are not affected by any custom setting from the project
+ # and can always request a known configuration further below.
+ get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(is_multi_config)
+ list(APPEND subCMakeOpts "-DCMAKE_CONFIGURATION_TYPES:STRING=Release")
+ endif()
+
else()
# Likely we've been invoked via CMake's script mode where no
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
@@ -1395,7 +1403,8 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION
# If we've already previously done these steps, they will not cause
# anything to be updated, so extra rebuilds of the project won't occur.
# Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project
- # has this set to something not findable on the PATH.
+ # has this set to something not findable on the PATH. We also ensured above
+ # that the Release config will be defined for multi-config generators.
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FetchContent/CMakeLists.cmake.in"
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
execute_process(
@@ -1411,7 +1420,7 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION
message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}")
endif()
execute_process(
- COMMAND ${CMAKE_COMMAND} --build .
+ COMMAND ${CMAKE_COMMAND} --build . --config Release
RESULT_VARIABLE result
${outputOptions}
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"