summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-05-11 13:17:05 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-05-11 13:18:08 (GMT)
commit1e521a1a91291b4ac6400c7f37345fcdb423d793 (patch)
tree8e12f38afefd1030643218fc4366937584247cbc
parentc747d4ccb349f87963a8d1da69394bc4db6b74ed (diff)
parente567d7eb639b43c2256340acdf4b0053dec0018a (diff)
downloadCMake-1e521a1a91291b4ac6400c7f37345fcdb423d793.zip
CMake-1e521a1a91291b4ac6400c7f37345fcdb423d793.tar.gz
CMake-1e521a1a91291b4ac6400c7f37345fcdb423d793.tar.bz2
Merge topic 'restore-imported-lib-alias-diagnostic'
e567d7eb63 add_library: Restore error on alias of non-global imported target Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2058
-rw-r--r--Help/release/3.11.rst9
-rw-r--r--Source/cmAddLibraryCommand.cxx8
-rw-r--r--Tests/RunCMake/alias_targets/imported-target-stderr.txt10
3 files changed, 25 insertions, 2 deletions
diff --git a/Help/release/3.11.rst b/Help/release/3.11.rst
index dbaa8af..184497c 100644
--- a/Help/release/3.11.rst
+++ b/Help/release/3.11.rst
@@ -283,3 +283,12 @@ Changes made since CMake 3.11.0 include the following.
CMake 3.11.0. This has been reverted due to changing behavior of
checks for existing projects. It may be restored in the future
with a policy for compatibility.
+
+3.11.2
+------
+
+* Calling :command:`add_library` to create an alias of an imported
+ target that is not globally visible now causes an error again as
+ it did prior to 3.11.0. This diagnostic was accidentally dropped
+ from CMake 3.11.0 and 3.11.1 by the change to allow globally visible
+ imported targets to be aliased.
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 1278232..7792235 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -228,6 +228,14 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
this->SetError(e.str());
return false;
}
+ if (aliasedTarget->IsImported() &&
+ !aliasedTarget->IsImportedGloballyVisible()) {
+ std::ostringstream e;
+ e << "cannot create ALIAS target \"" << libName << "\" because target \""
+ << aliasedName << "\" is imported but not globally visible.";
+ this->SetError(e.str());
+ return false;
+ }
this->Makefile->AddAlias(libName, aliasedName);
return true;
}
diff --git a/Tests/RunCMake/alias_targets/imported-target-stderr.txt b/Tests/RunCMake/alias_targets/imported-target-stderr.txt
index 12ffbc2..465de03 100644
--- a/Tests/RunCMake/alias_targets/imported-target-stderr.txt
+++ b/Tests/RunCMake/alias_targets/imported-target-stderr.txt
@@ -3,7 +3,13 @@
\"test-exe\" is imported but not globally visible.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
-
-
++
'alias-test-exe' does not exist![?]
+*
+CMake Error at imported-target.cmake:[0-9]+ \(add_library\):
+ add_library cannot create ALIAS target "alias-test-lib" because target
+ "test-lib" is imported but not globally visible.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
'alias-test-lib' does not exist![?]$