diff options
author | Brad King <brad.king@kitware.com> | 2020-05-14 13:18:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-05-15 09:39:25 (GMT) |
commit | 25995b2b3028a5f990792b6e2e409f681c3a89d0 (patch) | |
tree | e52d07357e8b7a57cf2d53d78491a98a0a7ee8f8 /Tests/ConfigSources | |
parent | ae9614a22d5e39882b2a686e8229170a8296212d (diff) | |
download | CMake-25995b2b3028a5f990792b6e2e409f681c3a89d0.zip CMake-25995b2b3028a5f990792b6e2e409f681c3a89d0.tar.gz CMake-25995b2b3028a5f990792b6e2e409f681c3a89d0.tar.bz2 |
cmGlobalGenerator: Fix CheckTargetsForMissingSources after refactoring
Refactoring in commit 01b2d6ab74 (Modernize: Use ranged for-loops when
possible, 2019-02-07, v3.15.0-rc1~575^2) accidentally changed a loop
condition in this method from "keep iterating if srcs.empty()" to
"stop iterating if srcs.empty()". Switch it back.
The bug could only manifest in very subtle conditions in a multi-config
generator. Add one such case to the test suite.
Fixes: #20706
Diffstat (limited to 'Tests/ConfigSources')
-rw-r--r-- | Tests/ConfigSources/CMakeLists.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index 21f923e..c5f9c50 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -1,4 +1,8 @@ cmake_minimum_required(VERSION 3.0) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build") +endif() project(ConfigSources CXX) # Per-config sources via INTERFACE_SOURCES. @@ -55,3 +59,13 @@ target_compile_definitions(ConfigSourcesLinkIface PRIVATE "$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>" ) target_link_libraries(ConfigSourcesLinkIface ConfigSourcesIface) + +# A target with sources in only one configuration that is not the +# first in CMAKE_CONFIGURATION_TYPES. +if(CMAKE_CONFIGURATION_TYPES MATCHES ";([^;]+)") + set(one_config "${CMAKE_MATCH_1}") +else() + set(one_config "${CMAKE_BUILD_TYPE}") +endif() +add_library(OneConfigOnly OBJECT "$<$<CONFIG:${one_config}>:${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp>") +set_property(TARGET OneConfigOnly PROPERTY LINKER_LANGUAGE CXX) |