Commit 7b0f6508 authored by Marc Chevrier's avatar Marc Chevrier
Browse files

ALIAS targets: Non-global aliases must be propagated to sub-directories

Fixes: #20942
parent 6ab08c4e
......@@ -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;
}
......
......@@ -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")
......@@ -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)
......@@ -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)
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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment