[Cmake-commits] CMake branch, next, updated. v3.2.2-3177-g154f875
Brad King
brad.king at kitware.com
Tue May 26 13:53:35 EDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 154f87549bf8d68211f0f8b3b98c3fddfbe373c5 (commit)
via 2aafaa7073c8a93c5e75498c7480788878545e6c (commit)
from b3704401400218f764b38a382f8817d2f70f2478 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=154f87549bf8d68211f0f8b3b98c3fddfbe373c5
commit 154f87549bf8d68211f0f8b3b98c3fddfbe373c5
Merge: b370440 2aafaa7
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue May 26 13:53:34 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue May 26 13:53:34 2015 -0400
Merge topic 'imported-link-item' into next
2aafaa70 fixup! Allow imported INTERFACE libraries to specify a link item
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2aafaa7073c8a93c5e75498c7480788878545e6c
commit 2aafaa7073c8a93c5e75498c7480788878545e6c
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue May 26 13:40:20 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue May 26 13:48:29 2015 -0400
fixup! Allow imported INTERFACE libraries to specify a link item
diff --git a/Help/prop_tgt/IMPORTED_LINK_ITEM.rst b/Help/prop_tgt/IMPORTED_LINK_ITEM.rst
index d8ee91f..ca8aa03 100644
--- a/Help/prop_tgt/IMPORTED_LINK_ITEM.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_ITEM.rst
@@ -8,18 +8,13 @@ An interface library has no library file so linking to it normally
adds its usage requirements but does not link to an actual library.
The ``IMPORTED_LINK_ITEM`` property specifies a single item to
be placed on the link line in place of the interface library.
-The item may be:
-* A full path to a library file such as ``/usr/lib/libfoo.so``.
-* A plain library name such as ``foo``.
-* A link flag.
-
-See the :command:`target_link_libraries` command for details on
-how each type of item is treated, but note that the
-``IMPORTED_LINK_ITEM`` property does not recognize the keyword
-arguments of that command. Furthermore, the item specified in
-this property is *not* treated as a library target name even if
-it happens to name one.
+This property is intended for use in naming libraries provided by
+a platform SDK for which the full path to a library file may not
+be known. The item may be a plain library name such as ``foo``
+but may *not* be a path (e.g. ``/usr/lib/libfoo.so``) or a flag
+(e.g. ``-Wl,...``). The item is never treated as a library target
+name even if it happens to name one.
The ``IMPORTED_LINK_ITEM`` property is allowed only on
:ref:`imported <Imported Targets>` :ref:`Interface Libraries`
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ada1488..f33f78b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1745,13 +1745,9 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
else if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_ITEM") &&
- (this->GetType() != cmTarget::INTERFACE_LIBRARY ||
- !this->IsImported()))
+ !this->CheckImportedLinkItem(prop, value? value:""))
{
- std::ostringstream e;
- e << prop << " property may be set only on "
- << "imported INTERFACE library targets.\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ /* error was reported by check method */
}
else if (prop == "LINK_LIBRARIES")
{
@@ -1840,14 +1836,10 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
<< this->Name << "\")\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
- else if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_ITEM") &&
- (this->GetType() != cmTarget::INTERFACE_LIBRARY ||
- !this->IsImported()))
+ else if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_ITEM"))
{
- std::ostringstream e;
- e << prop << " property may be set only on "
- << "imported INTERFACE library targets.\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ prop + " property may not be APPENDed.");
}
else if (prop == "LINK_LIBRARIES")
{
@@ -5721,6 +5713,37 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
}
//----------------------------------------------------------------------------
+bool cmTarget::CheckImportedLinkItem(std::string const& prop,
+ std::string const& value) const
+{
+ if (this->GetType() != cmTarget::INTERFACE_LIBRARY ||
+ !this->IsImported())
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, prop +
+ " property may be set only on imported INTERFACE library targets.");
+ return false;
+ }
+ if (!value.empty())
+ {
+ if (value[0] == '-')
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, prop +
+ " property value\n " + value + "\nmay not start in '-'.");
+ return false;
+ }
+ std::string::size_type bad = value.find_first_of(":/\\;");
+ if (bad != value.npos)
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, prop +
+ " property value\n " + value + "\nmay not contain '" +
+ value.substr(bad,1) + "'.");
+ return false;
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
cmTarget::LinkInterface const* cmTarget::GetLinkInterface(
const std::string& config,
cmTarget const* head) const
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index f3b8d8d..5e4f632 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -794,6 +794,9 @@ private:
void ComputeImportInfo(std::string const& desired_config,
ImportInfo& info) const;
+ bool CheckImportedLinkItem(std::string const& prop,
+ std::string const& value) const;
+
// Cache target compile paths for each configuration.
struct CompileInfo;
CompileInfo const* GetCompileInfo(const std::string& config) const;
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-stderr.txt
new file mode 100644
index 0000000..6a18cac
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-stderr.txt
@@ -0,0 +1,44 @@
+^CMake Error at IMPORTED_LINK_ITEM-bad-value.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM property value
+
+ -flag
+
+ may not start in '-'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-bad-value.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM property value
+
+ item1;item2
+
+ may not contain ';'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-bad-value.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM property value
+
+ /path/to/item1
+
+ may not contain '/'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-bad-value.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM property value
+
+ \\path\\to\\item1
+
+ may not contain '\\'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-bad-value.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM property value
+
+ c:\\path\\to\\item1
+
+ may not contain ':'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value.cmake b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value.cmake
new file mode 100644
index 0000000..91b0349
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value.cmake
@@ -0,0 +1,6 @@
+add_library(MyTarget INTERFACE IMPORTED)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM -flag)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM item1 item2)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM /path/to/item1)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM \\path\\to\\item1)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM c:\\path\\to\\item1)
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
index 223474b..4d64a83 100644
--- a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
@@ -1,27 +1,21 @@
^CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
IMPORTED_LINK_ITEM property may be set only on imported INTERFACE library
targets.
-
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
- IMPORTED_LINK_ITEM property may be set only on imported INTERFACE library
- targets.
-
+ IMPORTED_LINK_ITEM property may not be APPENDed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
IMPORTED_LINK_ITEM_DEBUG property may be set only on imported INTERFACE
library targets.
-
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
- IMPORTED_LINK_ITEM_DEBUG property may be set only on imported INTERFACE
- library targets.
-
+ IMPORTED_LINK_ITEM_DEBUG property may not be APPENDed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported-stderr.txt
similarity index 50%
copy from Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
copy to Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported-stderr.txt
index 223474b..8ef2987 100644
--- a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported-stderr.txt
@@ -1,27 +1,21 @@
-^CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
+^CMake Error at IMPORTED_LINK_ITEM-non-imported.cmake:[0-9]+ \(set_property\):
IMPORTED_LINK_ITEM property may be set only on imported INTERFACE library
targets.
-
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
-CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
- IMPORTED_LINK_ITEM property may be set only on imported INTERFACE library
- targets.
-
+CMake Error at IMPORTED_LINK_ITEM-non-imported.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM property may not be APPENDed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
-CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
+CMake Error at IMPORTED_LINK_ITEM-non-imported.cmake:[0-9]+ \(set_property\):
IMPORTED_LINK_ITEM_DEBUG property may be set only on imported INTERFACE
library targets.
-
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
-CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
- IMPORTED_LINK_ITEM_DEBUG property may be set only on imported INTERFACE
- library targets.
-
+CMake Error at IMPORTED_LINK_ITEM-non-imported.cmake:[0-9]+ \(set_property\):
+ IMPORTED_LINK_ITEM_DEBUG property may not be APPENDed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported.cmake b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported.cmake
new file mode 100644
index 0000000..beefdb5
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-imported.cmake
@@ -0,0 +1,5 @@
+add_library(MyTarget INTERFACE)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM item1)
+set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LINK_ITEM item2)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM_DEBUG item1)
+set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LINK_ITEM_DEBUG item2)
diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
index d49d773..fac35b8 100644
--- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
@@ -8,4 +8,6 @@ run_cmake(invalid_signature)
run_cmake(global-interface)
run_cmake(genex_link)
run_cmake(add_custom_command-TARGET)
+run_cmake(IMPORTED_LINK_ITEM-bad-value)
run_cmake(IMPORTED_LINK_ITEM-non-iface)
+run_cmake(IMPORTED_LINK_ITEM-non-imported)
-----------------------------------------------------------------------
Summary of changes:
Help/prop_tgt/IMPORTED_LINK_ITEM.rst | 17 +++----
Source/cmTarget.cxx | 49 ++++++++++++++------
Source/cmTarget.h | 3 ++
.../IMPORTED_LINK_ITEM-bad-value-result.txt} | 0
.../IMPORTED_LINK_ITEM-bad-value-stderr.txt | 44 ++++++++++++++++++
.../IMPORTED_LINK_ITEM-bad-value.cmake | 6 +++
.../IMPORTED_LINK_ITEM-non-iface-stderr.txt | 10 +---
.../IMPORTED_LINK_ITEM-non-imported-result.txt} | 0
... => IMPORTED_LINK_ITEM-non-imported-stderr.txt} | 18 +++----
...cmake => IMPORTED_LINK_ITEM-non-imported.cmake} | 2 +-
.../RunCMake/interface_library/RunCMakeTest.cmake | 2 +
11 files changed, 106 insertions(+), 45 deletions(-)
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => interface_library/IMPORTED_LINK_ITEM-bad-value-result.txt} (100%)
create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value-stderr.txt
create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-bad-value.cmake
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => interface_library/IMPORTED_LINK_ITEM-non-imported-result.txt} (100%)
copy Tests/RunCMake/interface_library/{IMPORTED_LINK_ITEM-non-iface-stderr.txt => IMPORTED_LINK_ITEM-non-imported-stderr.txt} (50%)
copy Tests/RunCMake/interface_library/{IMPORTED_LINK_ITEM-non-iface.cmake => IMPORTED_LINK_ITEM-non-imported.cmake} (89%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list