diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2021-02-22 10:45:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-02-23 13:14:14 (GMT) |
commit | b722eea9253acd9e33921779175fc615d064577a (patch) | |
tree | 260955614807534a07e7ecb8895704d6f931cb81 /Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake | |
parent | c2c31ae8969686f1909fe76fef43a232332c7b54 (diff) | |
download | CMake-b722eea9253acd9e33921779175fc615d064577a.zip CMake-b722eea9253acd9e33921779175fc615d064577a.tar.gz CMake-b722eea9253acd9e33921779175fc615d064577a.tar.bz2 |
Genex: LINK_LANGUAGE respects LINKER_LANGUAGE property
If target property LINKER_LANGUAGE is set, LINK_LANGUAGE generator
expression evaluation must be always successful.
This fix can be helpful to elaborate a solution for issue #21818.
Diffstat (limited to 'Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake')
-rw-r--r-- | Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake index f3fe955..22d3df7 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake @@ -7,6 +7,8 @@ enable_language(CXX) add_library(shared_C SHARED func.c) add_library(shared_CXX SHARED func.cxx) +add_library(static_cxx STATIC func.cxx) +target_compile_definitions(static_cxx PRIVATE BUILD_STATIC) add_library(static1_C STATIC empty.c) target_link_libraries (static1_C INTERFACE $<$<LINK_LANGUAGE:C>:shared_C>) @@ -70,3 +72,10 @@ add_executable(LinkLibraries_C_static main.c) target_link_libraries (LinkLibraries_C_static PRIVATE static3) add_executable(LinkLibraries_CXX_static main.cxx) target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) + +# $<LINK_LANGUAGE:> change, by default, link language from C to CXX +# but because LINKER_LANGUAGE property is set, keep C as link language +add_executable(LinkLibraries_C_static_CXX main.c) +target_compile_definitions (LinkLibraries_C_static_CXX PRIVATE C_USE_CXX) +target_link_libraries (LinkLibraries_C_static_CXX PRIVATE $<$<LINK_LANGUAGE:C>:static_cxx>) +set_property(TARGET LinkLibraries_C_static_CXX PROPERTY LINKER_LANGUAGE C) |