summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-13 16:12:59 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-05-13 16:14:09 (GMT)
commit3a82b3f534b54aa3a4f82241f5bb3a929860b922 (patch)
tree16c3dab8853e3f7311b9c5c172e8908136fb21f4 /Tests
parentdbc0bc175059c692e2a6536f2dc0f01da7d12de9 (diff)
parent6c5d4522bcc242361895e72c3fcbd91710abb64c (diff)
downloadCMake-3a82b3f534b54aa3a4f82241f5bb3a929860b922.zip
CMake-3a82b3f534b54aa3a4f82241f5bb3a929860b922.tar.gz
CMake-3a82b3f534b54aa3a4f82241f5bb3a929860b922.tar.bz2
Merge topic 'interface-sources-multi-config'
6c5d4522bc INTERFACE_SOURCES: Fix per-config link libs on multi-config generators 8daa140c6a cmGeneratorTarget: Factor evaluated target prop entries into struct fcd1a1a920 cmGeneratorTarget: Track when the set of link libs is config-dependent Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4740
Diffstat (limited to 'Tests')
-rw-r--r--Tests/ConfigSources/CMakeLists.txt38
-rw-r--r--Tests/ConfigSources/main.cpp9
2 files changed, 46 insertions, 1 deletions
diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt
index f5dd276..21f923e 100644
--- a/Tests/ConfigSources/CMakeLists.txt
+++ b/Tests/ConfigSources/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.0)
project(ConfigSources CXX)
+# Per-config sources via INTERFACE_SOURCES.
add_library(iface INTERFACE)
target_sources(iface INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp"
@@ -12,10 +13,45 @@ target_compile_definitions(iface INTERFACE
"$<$<CONFIG:Debug>:CFG_DEBUG>"
"$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>"
)
-
add_executable(ConfigSources
$<$<CONFIG:Debug>:main_debug.cpp>
$<$<NOT:$<CONFIG:Debug>>:main_other.cpp>
$<$<CONFIG:NotAConfig>:does_not_exist.cpp>
)
target_link_libraries(ConfigSources iface)
+
+# Per-config sources via LINK_LIBRARIES.
+add_library(iface_debug INTERFACE)
+target_sources(iface_debug INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/iface_debug_src.cpp"
+ )
+add_library(iface_other INTERFACE)
+target_sources(iface_other INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/iface_other_src.cpp"
+ )
+add_executable(ConfigSourcesLink main.cpp)
+target_compile_definitions(ConfigSourcesLink PRIVATE
+ "$<$<CONFIG:Debug>:CFG_DEBUG>"
+ "$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>"
+ )
+target_link_libraries(ConfigSourcesLink PRIVATE
+ "$<$<CONFIG:Debug>:iface_debug>"
+ "$<$<NOT:$<CONFIG:Debug>>:iface_other>"
+ "$<$<CONFIG:NotAConfig>:iface_does_not_exist>"
+ )
+
+# Per-config sources via INTERFACE_LINK_LIBRARIES.
+add_library(ConfigSourcesIface INTERFACE)
+target_link_libraries(ConfigSourcesIface INTERFACE
+ "$<$<CONFIG:Debug>:iface_debug>"
+ "$<$<NOT:$<CONFIG:Debug>>:iface_other>"
+ "$<$<CONFIG:NotAConfig>:iface_does_not_exist>"
+ )
+add_executable(ConfigSourcesLinkIface main.cpp)
+target_compile_definitions(ConfigSourcesLinkIface PRIVATE
+ "$<$<CONFIG:Debug>:CFG_DEBUG>"
+ "$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>"
+ )
+target_link_libraries(ConfigSourcesLinkIface ConfigSourcesIface)
diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp
new file mode 100644
index 0000000..c1cd3b2
--- /dev/null
+++ b/Tests/ConfigSources/main.cpp
@@ -0,0 +1,9 @@
+#if !defined(CFG_DEBUG) && !defined(CFG_OTHER)
+# error "Neither CFG_DEBUG or CFG_OTHER is defined."
+#endif
+#ifdef CFG_DEBUG
+# include "main_debug.cpp"
+#endif
+#ifdef CFG_OTHER
+# include "main_other.cpp"
+#endif