summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-07-11 14:59:50 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-07-11 14:59:50 (GMT)
commit7b0f6508a03d7045d7599068ce9409004df2dbb0 (patch)
tree1f0cead6eda2344796ef818e91b6c3b9d1639fa7
parent6ab08c4e99469439900c1cdc02fd2452ab268a87 (diff)
downloadCMake-7b0f6508a03d7045d7599068ce9409004df2dbb0.zip
CMake-7b0f6508a03d7045d7599068ce9409004df2dbb0.tar.gz
CMake-7b0f6508a03d7045d7599068ce9409004df2dbb0.tar.bz2
ALIAS targets: Non-global aliases must be propagated to sub-directories
Fixes: #20942
-rw-r--r--Source/cmMakefile.cxx3
-rw-r--r--Tests/RunCMake/alias_targets/get_property-subdir/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake15
-rw-r--r--Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries-ALIAS/sub_dir/CMakeLists.txt7
5 files changed, 28 insertions, 6 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c78b751..db5cee9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1461,6 +1461,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
// Imported targets.
this->ImportedTargets = parent->ImportedTargets;
+ // Non-global Alias targets.
+ this->AliasTargets = parent->AliasTargets;
+
// Recursion depth.
this->RecursionDepth = parent->RecursionDepth;
}
diff --git a/Tests/RunCMake/alias_targets/get_property-subdir/CMakeLists.txt b/Tests/RunCMake/alias_targets/get_property-subdir/CMakeLists.txt
index bfd9840..b114b75 100644
--- a/Tests/RunCMake/alias_targets/get_property-subdir/CMakeLists.txt
+++ b/Tests/RunCMake/alias_targets/get_property-subdir/CMakeLists.txt
@@ -6,3 +6,10 @@ check_property (alias::import-local-subdir ALIASED_TARGET "import-local")
check_property (alias::import-local-subdir IMPORTED "TRUE")
check_property (alias::import-local-subdir ALIAS_GLOBAL "FALSE")
check_property (alias::import-local-subdir IMPORT_LOCAL_PROPERTY "IMPORT_LOCAL")
+
+
+# non-global alias defined in parent directory must be visible in sub-directory
+check_property (alias::import-local ALIASED_TARGET "import-local")
+check_property (alias::import-local IMPORTED "TRUE")
+check_property (alias::import-local ALIAS_GLOBAL "FALSE")
+check_property (alias::import-local IMPORT_LOCAL_PROPERTY "IMPORT_LOCAL")
diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake
index 73f8a7d..316b74b 100644
--- a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake
+++ b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake
@@ -15,22 +15,25 @@ endif()
add_library(import-local SHARED IMPORTED)
set_property(TARGET import-local PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_property(TARGET import-local PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}")
-add_library(alias-local ALIAS import-local)
+add_library(alias::local ALIAS import-local)
add_library (lib-local SHARED lib.c)
-target_link_libraries (lib-local PRIVATE import-local)
+target_link_libraries (lib-local PRIVATE alias::local)
add_executable (main-local main.c)
-target_link_libraries (main-local PRIVATE import-local)
+target_link_libraries (main-local PRIVATE alias::local)
add_library(import-global SHARED IMPORTED GLOBAL)
set_property(TARGET import-global PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_property(TARGET import-global PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}")
-add_library(alias-global ALIAS import-global)
+add_library(alias::global ALIAS import-global)
add_library (lib-global SHARED lib.c)
-target_link_libraries (lib-global PRIVATE import-global)
+target_link_libraries (lib-global PRIVATE alias::global)
add_executable (main-global main.c)
-target_link_libraries (main-global PRIVATE import-global)
+target_link_libraries (main-global PRIVATE alias::global)
+
+
+add_subdirectory(sub_dir)
diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake
index 4d24a6e..42ec47e 100644
--- a/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake
@@ -19,5 +19,7 @@ run_cmake_target(AliasTargets lib-local lib-local --config Release)
run_cmake_target(AliasTargets main-local main-local --config Release)
run_cmake_target(AliasTargets lib-global lib-global --config Release)
run_cmake_target(AliasTargets main-global main-global --config Release)
+run_cmake_target(AliasTargets lib-sub lib-sub --config Release)
+run_cmake_target(AliasTargets main-sub main-sub --config Release)
unset(RunCMake_TEST_OPTIONS)
unset(RunCMake_TEST_OUTPUT_MERGE)
diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/sub_dir/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-ALIAS/sub_dir/CMakeLists.txt
new file mode 100644
index 0000000..326e964
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-ALIAS/sub_dir/CMakeLists.txt
@@ -0,0 +1,7 @@
+
+
+add_library (lib-sub SHARED ../lib.c)
+target_link_libraries (lib-sub PRIVATE alias::local)
+
+add_executable (main-sub ../main.c)
+target_link_libraries (main-sub PRIVATE alias::local)