diff options
Diffstat (limited to 'Tests/ConfigSources/CMakeLists.txt')
-rw-r--r-- | Tests/ConfigSources/CMakeLists.txt | 38 |
1 files changed, 37 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) |