summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-11-09 15:06:33 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-11-09 15:06:33 (GMT)
commited484544cbf39ffefe1898b8255a5189062e5c60 (patch)
treee89b186f367df605e87a67c5a771ed7ec8502605
parent20e445f4418088ddf6e8f30ff3425af1588d2710 (diff)
parent4ce9742ae33678d8fce189d172c2fffb1a43061c (diff)
downloadCMake-ed484544cbf39ffefe1898b8255a5189062e5c60.zip
CMake-ed484544cbf39ffefe1898b8255a5189062e5c60.tar.gz
CMake-ed484544cbf39ffefe1898b8255a5189062e5c60.tar.bz2
Merge topic 'fix-alias-target-access'
4ce9742a Alias: Fix access at generate-time (#15832)
-rw-r--r--Source/cmGlobalGenerator.cxx6
-rw-r--r--Tests/AliasTarget/CMakeLists.txt4
-rw-r--r--Tests/AliasTarget/subdir/CMakeLists.txt3
-rw-r--r--Tests/AliasTarget/subdir/empty.cpp7
4 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 3d2db42..2126c71 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2274,6 +2274,12 @@ cmGlobalGenerator::FindTarget(const std::string& name,
cmGeneratorTarget*
cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
{
+ std::map<std::string, std::string>::const_iterator ai =
+ this->AliasTargets.find(name);
+ if (ai != this->AliasTargets.end())
+ {
+ return this->FindGeneratorTargetImpl(ai->second);
+ }
if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
{
return tgt;
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index c50b4e6..e1d8966 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -37,7 +37,9 @@ target_include_directories(bat PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(targetgenerator targetgenerator.cpp)
add_executable(Generator::Target ALIAS targetgenerator)
-add_custom_target(usealias Generator::Target)
+add_subdirectory(subdir)
+
+add_custom_target(usealias Generator::Target $<TARGET_FILE:Sub::tgt>)
add_dependencies(bat usealias)
if (NOT TARGET Another::Alias)
diff --git a/Tests/AliasTarget/subdir/CMakeLists.txt b/Tests/AliasTarget/subdir/CMakeLists.txt
new file mode 100644
index 0000000..8c84aea
--- /dev/null
+++ b/Tests/AliasTarget/subdir/CMakeLists.txt
@@ -0,0 +1,3 @@
+
+add_library(tgt STATIC empty.cpp)
+add_library(Sub::tgt ALIAS tgt)
diff --git a/Tests/AliasTarget/subdir/empty.cpp b/Tests/AliasTarget/subdir/empty.cpp
new file mode 100644
index 0000000..b19427a
--- /dev/null
+++ b/Tests/AliasTarget/subdir/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int main(void)
+{
+ return 0;
+}