diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-05-28 11:51:22 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-06-02 15:11:47 (GMT) |
commit | 056489d567b657bd1ebeae8bf78f4937f900b2e0 (patch) | |
tree | d3800c8fdf726c1e04cf73e463b68861efe6abd3 /Tests/RunCMake/GeneratorExpression | |
parent | 254f2b9058f814e952ef0178e13b3f98e8d216a1 (diff) | |
download | CMake-056489d567b657bd1ebeae8bf78f4937f900b2e0.zip CMake-056489d567b657bd1ebeae8bf78f4937f900b2e0.tar.gz CMake-056489d567b657bd1ebeae8bf78f4937f900b2e0.tar.bz2 |
add_library/add_executable: allow local alias to imported targets
Fixes: #20641
Diffstat (limited to 'Tests/RunCMake/GeneratorExpression')
3 files changed, 23 insertions, 0 deletions
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 24c3642..7d3c22b 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -111,6 +111,7 @@ run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target) run_cmake(TARGET_PROPERTY-INCLUDE_DIRECTORIES) run_cmake(TARGET_PROPERTY-LOCATION) run_cmake(TARGET_PROPERTY-SOURCES) +run_cmake(TARGET_PROPERTY-ALIAS_GLOBAL) run_cmake(LINK_ONLY-not-linking) run_cmake(TARGET_EXISTS-no-arg) run_cmake(TARGET_EXISTS-empty-arg) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-ALIAS_GLOBAL-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-ALIAS_GLOBAL-check.cmake new file mode 100644 index 0000000..0fbf837 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-ALIAS_GLOBAL-check.cmake @@ -0,0 +1,6 @@ +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/alias_global.txt alias_global) + +set(expected "TRUE(lib-global):TRUE;FALSE(lib-local):FALSE;TRUE(lib):FALSE") +if(NOT alias_global STREQUAL expected) + set(RunCMake_TEST_FAILED "ALIAS_GLOBAL was:\n [[${alias_global}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-ALIAS_GLOBAL.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-ALIAS_GLOBAL.cmake new file mode 100644 index 0000000..212c034 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-ALIAS_GLOBAL.cmake @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 3.17) + +add_library(lib-global SHARED IMPORTED GLOBAL) +add_library(alias-lib-global ALIAS lib-global) + +add_library(lib-local SHARED IMPORTED) +add_library(alias-lib-local ALIAS lib-local) + +add_library(lib SHARED IMPORTED) +add_library(alias-lib ALIAS lib) +# switch from local to global +set_property (TARGET lib PROPERTY IMPORTED_GLOBAL TRUE) + + +file(GENERATE OUTPUT alias_global.txt CONTENT "$<TARGET_PROPERTY:lib-global,IMPORTED_GLOBAL>($<TARGET_PROPERTY:alias-lib-global,ALIASED_TARGET>):$<TARGET_PROPERTY:alias-lib-global,ALIAS_GLOBAL>\n$<TARGET_PROPERTY:lib-local,IMPORTED_GLOBAL>($<TARGET_PROPERTY:alias-lib-local,ALIASED_TARGET>):$<TARGET_PROPERTY:alias-lib-local,ALIAS_GLOBAL>\n$<TARGET_PROPERTY:lib,IMPORTED_GLOBAL>($<TARGET_PROPERTY:alias-lib,ALIASED_TARGET>):$<TARGET_PROPERTY:alias-lib,ALIAS_GLOBAL>\n") |