[Cmake-commits] CMake branch, next, updated. v3.7.0-rc3-971-g3f7b09c

Brad King brad.king at kitware.com
Tue Nov 8 10:48:41 EST 2016


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  3f7b09c95ee2efff892b5699fdc03a8ffc1423ac (commit)
       via  ff3b05d41b6bbbba0b32697a8bd6096dacc8aed4 (commit)
       via  1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc (commit)
       via  479932fa32115b666be1deea42862673a0c4b608 (commit)
       via  925e4270fdc5c731c123cb8037607840008f4713 (commit)
      from  38ec4b15d232f45124fe290accc773284b99a679 (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f7b09c95ee2efff892b5699fdc03a8ffc1423ac
commit 3f7b09c95ee2efff892b5699fdc03a8ffc1423ac
Merge: 38ec4b1 ff3b05d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 8 10:48:39 2016 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Nov 8 10:48:39 2016 -0500

    Merge topic 'imported-interface-libname' into next
    
    ff3b05d4 Allow imported INTERFACE libraries to specify a link library name
    1d1f1eeb cmTarget: Refactor GetMappedConfig to choose location property up front
    479932fa cmTarget: Add comment clarifying interface library special case
    925e4270 cmTarget: Clarify comments in GetMappedConfig


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff3b05d41b6bbbba0b32697a8bd6096dacc8aed4
commit ff3b05d41b6bbbba0b32697a8bd6096dacc8aed4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 3 16:44:32 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 3 16:46:45 2016 -0400

    Allow imported INTERFACE libraries to specify a link library name
    
    Add an `IMPORTED_LIBNAME[_<CONFIG>]` target property to specify a library
    name to be placed on the link line in place of an interface library
    since it has no library file of its own.  Restrict use of the property
    to imported `INTERFACE` libraries.
    
    This will be particularly useful for find modules that need to provide
    imported libraries from system SDKs where the full path to the library
    file is not known.  Now such find modules will be able to provide an
    imported interface library and set `IMPORTED_LIBNAME` to refer to the
    SDK library by name.
    
    Issue: #15267

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index fa21a1f..82d5588 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -167,6 +167,8 @@ Properties on Targets
    /prop_tgt/IMPORTED_CONFIGURATIONS
    /prop_tgt/IMPORTED_IMPLIB_CONFIG
    /prop_tgt/IMPORTED_IMPLIB
+   /prop_tgt/IMPORTED_LIBNAME_CONFIG
+   /prop_tgt/IMPORTED_LIBNAME
    /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG
    /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES
    /prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG
diff --git a/Help/prop_tgt/IMPORTED_LIBNAME.rst b/Help/prop_tgt/IMPORTED_LIBNAME.rst
new file mode 100644
index 0000000..1943dba
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_LIBNAME.rst
@@ -0,0 +1,23 @@
+IMPORTED_LIBNAME
+----------------
+
+Specify the link library name for an :ref:`imported <Imported Targets>`
+:ref:`Interface Library <Interface Libraries>`.
+
+An interface library builds no library file itself but does specify
+usage requirements for its consumers.  The ``IMPORTED_LIBNAME``
+property may be set to specify a single library name to be placed
+on the link line in place of the interface library target name as
+a requirement for using the interface.
+
+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 value 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 name is never treated as a library target
+name even if it happens to name one.
+
+The ``IMPORTED_LIBNAME`` property is allowed only on
+:ref:`imported <Imported Targets>` :ref:`Interface Libraries`
+and is rejected on targets of other types (for which
+the :prop_tgt:`IMPORTED_LOCATION` target property may be used).
diff --git a/Help/prop_tgt/IMPORTED_LIBNAME_CONFIG.rst b/Help/prop_tgt/IMPORTED_LIBNAME_CONFIG.rst
new file mode 100644
index 0000000..a28b838
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_LIBNAME_CONFIG.rst
@@ -0,0 +1,7 @@
+IMPORTED_LIBNAME_<CONFIG>
+-------------------------
+
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LIBNAME` property.
+
+Configuration names correspond to those provided by the project from
+which the target is imported.
diff --git a/Help/release/dev/imported-interface-libname.rst b/Help/release/dev/imported-interface-libname.rst
new file mode 100644
index 0000000..fdbae78
--- /dev/null
+++ b/Help/release/dev/imported-interface-libname.rst
@@ -0,0 +1,7 @@
+imported-interface-libname
+--------------------------
+
+* :ref:`Imported <Imported Targets>` :ref:`Interface Libraries` learned new
+  :prop_tgt:`IMPORTED_LIBNAME` and :prop_tgt:`IMPORTED_LIBNAME_<CONFIG>`
+  target properties to specify a link library name since interface libraries
+  do not build their own library files.
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 28aa533..ff386f9 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -606,6 +606,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       // of COMPATIBLE_INTERFACE_ enforcement.  The generators will ignore
       // this for the actual link line.
       this->Items.push_back(Item(std::string(), false, tgt));
+
+      // Also add the item the interface specifies to be used in its place.
+      std::string const& libName = tgt->GetImportedLibName(config);
+      if (!libName.empty()) {
+        this->AddItem(libName, 0);
+      }
     } else {
       // Decide whether to use an import library.
       bool implib =
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index ca056c0..a18a9ef 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2796,6 +2796,16 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
   }
 }
 
+std::string cmGeneratorTarget::GetImportedLibName(
+  std::string const& config) const
+{
+  if (cmGeneratorTarget::ImportInfo const* info =
+        this->GetImportInfo(config)) {
+    return info->LibName;
+  }
+  return std::string();
+}
+
 std::string cmGeneratorTarget::GetFullPath(const std::string& config,
                                            bool implib, bool realname) const
 {
@@ -4711,6 +4721,9 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
     }
   }
   if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+    if (loc) {
+      info.LibName = loc;
+    }
     return;
   }
 
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 3805bfc..4c3c14b 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -147,6 +147,9 @@ public:
                                      const cmGeneratorTarget* head,
                                      bool usage_requirements_only) const;
 
+  /** Get the library name for an imported interface library.  */
+  std::string GetImportedLibName(std::string const& config) const;
+
   /** Get the full path to the target according to the settings in its
       makefile and the configuration type.  */
   std::string GetFullPath(const std::string& config = "", bool implib = false,
@@ -643,6 +646,7 @@ private:
     std::string Location;
     std::string SOName;
     std::string ImportLibrary;
+    std::string LibName;
     std::string Languages;
     std::string Libraries;
     std::string LibrariesProp;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e37a9f8..434edf5 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -912,6 +912,9 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
       this->Internal->SourceEntries.push_back(value);
       this->Internal->SourceBacktraces.push_back(lfbt);
     }
+  } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") &&
+             !this->CheckImportedLibName(prop, value ? value : "")) {
+    /* error was reported by check method */
   } else {
     this->Properties.SetProperty(prop, value);
   }
@@ -979,6 +982,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     this->Internal->SourceEntries.push_back(value);
     this->Internal->SourceBacktraces.push_back(lfbt);
+  } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME")) {
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+                                 prop + " property may not be APPENDed.");
   } else {
     this->Properties.AppendProperty(prop, value, asString);
   }
@@ -1374,20 +1380,41 @@ void cmTarget::SetPropertyDefault(const std::string& property,
   }
 }
 
+bool cmTarget::CheckImportedLibName(std::string const& prop,
+                                    std::string const& value) const
+{
+  if (this->GetType() != cmStateEnums::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 with '-'.");
+      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;
+}
+
 bool cmTarget::GetMappedConfig(std::string const& desired_config,
                                const char** loc, const char** imp,
                                std::string& suffix) const
 {
-  if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
-    // This method attempts to find a config-specific LOCATION for the
-    // IMPORTED library. In the case of cmStateEnums::INTERFACE_LIBRARY, there
-    // is no
-    // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate
-    // and valid response.
-    return true;
-  }
-
-  std::string const locPropBase = "IMPORTED_LOCATION";
+  std::string const locPropBase =
+    this->GetType() == cmStateEnums::INTERFACE_LIBRARY ? "IMPORTED_LIBNAME"
+                                                       : "IMPORTED_LOCATION";
 
   // Track the configuration-specific property suffix.
   suffix = "_";
@@ -1445,7 +1472,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   // then the target location is not found.  The project does not want
   // any other configuration.
   if (!mappedConfigs.empty() && !*loc && !*imp) {
-    return false;
+    // Interface libraries are always available because their
+    // library name is optional so it is okay to leave *loc empty.
+    return this->GetType() == cmStateEnums::INTERFACE_LIBRARY;
   }
 
   // If we have not yet found it then there are no mapped
@@ -1499,7 +1528,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   }
   // If we have not yet found it then the target location is not available.
   if (!*loc && !*imp) {
-    return false;
+    // Interface libraries are always available because their
+    // library name is optional so it is okay to leave *loc empty.
+    return this->GetType() == cmStateEnums::INTERFACE_LIBRARY;
   }
 
   return true;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 1f035a1..2f6aa12 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -277,6 +277,9 @@ private:
   void SetPropertyDefault(const std::string& property,
                           const char* default_value);
 
+  bool CheckImportedLibName(std::string const& prop,
+                            std::string const& value) const;
+
 private:
   cmPropertyMap Properties;
   std::set<std::string> SystemIncludeDirectories;
diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx
index 7cf1fd8..5ad1694 100644
--- a/Source/cmTargetPropertyComputer.cxx
+++ b/Source/cmTargetPropertyComputer.cxx
@@ -66,7 +66,9 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
     return true;
   }
 
-  if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
+  if (prop == "IMPORTED_CONFIGURATIONS" || prop == "IMPORTED_LIBNAME" ||
+      cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME_") ||
+      cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
     return true;
   }
 
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
index ee81419..3db210a 100644
--- a/Tests/InterfaceLibrary/CMakeLists.txt
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -25,8 +25,25 @@ target_sources(iface_objlib INTERFACE $<TARGET_OBJECTS:objlib>)
 add_library(intermediate INTERFACE)
 target_link_libraries(intermediate INTERFACE iface_objlib)
 
+add_library(item_fake_tgt STATIC item_fake.cpp)
+set_property(TARGET item_fake_tgt PROPERTY OUTPUT_NAME item_fake)
+add_library(item_real STATIC item.cpp)
+add_library(item_iface INTERFACE IMPORTED)
+set_property(TARGET item_iface PROPERTY IMPORTED_LIBNAME item_real)
+add_dependencies(item_iface item_real)
+link_directories(${CMAKE_CURRENT_BINARY_DIR})
+
 add_executable(InterfaceLibrary definetestexe.cpp)
-target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface intermediate)
+target_link_libraries(InterfaceLibrary
+  iface_nodepends
+  headeriface
+  subiface
+  intermediate
+
+  item_iface
+  item_fake # ensure that 'item_real' is ordered in place of item_iface
+  )
+add_dependencies(InterfaceLibrary item_fake_tgt)
 
 add_subdirectory(libsdir)
 
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
index a6b5592..098502c 100644
--- a/Tests/InterfaceLibrary/definetestexe.cpp
+++ b/Tests/InterfaceLibrary/definetestexe.cpp
@@ -17,8 +17,9 @@
 
 extern int obj();
 extern int sub();
+extern int item();
 
 int main(int, char**)
 {
-  return obj() + sub();
+  return obj() + sub() + item();
 }
diff --git a/Tests/InterfaceLibrary/item.cpp b/Tests/InterfaceLibrary/item.cpp
new file mode 100644
index 0000000..85cda1b
--- /dev/null
+++ b/Tests/InterfaceLibrary/item.cpp
@@ -0,0 +1,4 @@
+int item()
+{
+  return 0;
+}
diff --git a/Tests/InterfaceLibrary/item_fake.cpp b/Tests/InterfaceLibrary/item_fake.cpp
new file mode 100644
index 0000000..b4bd829
--- /dev/null
+++ b/Tests/InterfaceLibrary/item_fake.cpp
@@ -0,0 +1,5 @@
+extern int item_undefined();
+int item()
+{
+  return item_undefined();
+}
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt
new file mode 100644
index 0000000..454c655
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt
@@ -0,0 +1,44 @@
+^CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property value
+
+    -flag
+
+  may not start with '-'.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property value
+
+    item1;item2
+
+  may not contain ';'.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property value
+
+    /path/to/item1
+
+  may not contain '/'.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property value
+
+    \\path\\to\\item1
+
+  may not contain '\\'.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME 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_LIBNAME-bad-value.cmake b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake
new file mode 100644
index 0000000..1af65b4
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake
@@ -0,0 +1,6 @@
+add_library(MyTarget INTERFACE IMPORTED)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME -flag)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME item1 item2)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME /path/to/item1)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME \\path\\to\\item1)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME c:\\path\\to\\item1)
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt
new file mode 100644
index 0000000..3a329d2
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt
@@ -0,0 +1,45 @@
+^CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME 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_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property may not be APPENDed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME_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_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME_DEBUG property may not be APPENDed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME 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_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME 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_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME 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_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property may be set only on imported INTERFACE library
+  targets.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake
new file mode 100644
index 0000000..fe6841a
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake
@@ -0,0 +1,17 @@
+add_custom_target(MyCustom)
+set_property(TARGET MyCustom PROPERTY IMPORTED_LIBNAME item1)
+set_property(TARGET MyCustom APPEND PROPERTY IMPORTED_LIBNAME item2)
+set_property(TARGET MyCustom PROPERTY IMPORTED_LIBNAME_DEBUG item1)
+set_property(TARGET MyCustom APPEND PROPERTY IMPORTED_LIBNAME_DEBUG item2)
+
+add_library(MyStatic STATIC IMPORTED)
+set_property(TARGET MyStatic PROPERTY IMPORTED_LIBNAME item1)
+
+add_library(MyShared SHARED IMPORTED)
+set_property(TARGET MyShared PROPERTY IMPORTED_LIBNAME item1)
+
+add_library(MyModule MODULE IMPORTED)
+set_property(TARGET MyModule PROPERTY IMPORTED_LIBNAME item1)
+
+add_executable(MyExe IMPORTED)
+set_property(TARGET MyExe PROPERTY IMPORTED_LIBNAME item1)
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt
new file mode 100644
index 0000000..e9d94cf
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt
@@ -0,0 +1,21 @@
+^CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME 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_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME property may not be APPENDed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME_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_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LIBNAME_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_LIBNAME-non-imported.cmake b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake
new file mode 100644
index 0000000..07a67d7
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake
@@ -0,0 +1,5 @@
+add_library(MyTarget INTERFACE)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME item1)
+set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LIBNAME item2)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME_DEBUG item1)
+set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LIBNAME_DEBUG item2)
diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
index 201daa7..5a6af1d 100644
--- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
@@ -8,3 +8,6 @@ run_cmake(invalid_signature)
 run_cmake(global-interface)
 run_cmake(genex_link)
 run_cmake(add_custom_command-TARGET)
+run_cmake(IMPORTED_LIBNAME-bad-value)
+run_cmake(IMPORTED_LIBNAME-non-iface)
+run_cmake(IMPORTED_LIBNAME-non-imported)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc
commit 1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 3 16:10:31 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 3 16:10:35 2016 -0400

    cmTarget: Refactor GetMappedConfig to choose location property up front
    
    Store the `IMPORTED_LOCATION` property name in a variable up front
    to avoid duplicating the string literal.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 3289a84..e37a9f8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1387,6 +1387,8 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
     return true;
   }
 
+  std::string const locPropBase = "IMPORTED_LOCATION";
+
   // Track the configuration-specific property suffix.
   suffix = "_";
   suffix += desired_config;
@@ -1412,7 +1414,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
     if (mci->empty()) {
       // An empty string in the mapping has a special meaning:
       // look up the config-less properties.
-      *loc = this->GetProperty("IMPORTED_LOCATION");
+      *loc = this->GetProperty(locPropBase);
       if (allowImp) {
         *imp = this->GetProperty("IMPORTED_IMPLIB");
       }
@@ -1422,7 +1424,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
       }
     } else {
       std::string mcUpper = cmSystemTools::UpperCase(*mci);
-      std::string locProp = "IMPORTED_LOCATION_";
+      std::string locProp = locPropBase + "_";
       locProp += mcUpper;
       *loc = this->GetProperty(locProp);
       if (allowImp) {
@@ -1449,7 +1451,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   // If we have not yet found it then there are no mapped
   // configurations.  Look for an exact-match.
   if (!*loc && !*imp) {
-    std::string locProp = "IMPORTED_LOCATION";
+    std::string locProp = locPropBase;
     locProp += suffix;
     *loc = this->GetProperty(locProp);
     if (allowImp) {
@@ -1467,7 +1469,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
 
     // Look for a configuration-less location.  This may be set by
     // manually-written code.
-    *loc = this->GetProperty("IMPORTED_LOCATION");
+    *loc = this->GetProperty(locPropBase);
     if (allowImp) {
       *imp = this->GetProperty("IMPORTED_IMPLIB");
     }
@@ -1485,7 +1487,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
          !*loc && !*imp && aci != availableConfigs.end(); ++aci) {
       suffix = "_";
       suffix += cmSystemTools::UpperCase(*aci);
-      std::string locProp = "IMPORTED_LOCATION";
+      std::string locProp = locPropBase;
       locProp += suffix;
       *loc = this->GetProperty(locProp);
       if (allowImp) {

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=479932fa32115b666be1deea42862673a0c4b608
commit 479932fa32115b666be1deea42862673a0c4b608
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 3 16:02:49 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 3 16:02:49 2016 -0400

    cmTarget: Add comment clarifying interface library special case

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 07f07c1..3289a84 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -289,6 +289,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
          ci != configNames.end(); ++ci) {
       std::string configUpper = cmSystemTools::UpperCase(*ci);
       for (const char** p = configProps; *p; ++p) {
+        // Interface libraries have no output locations, so honor only
+        // the configuration map.
         if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY &&
             strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) {
           continue;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=925e4270fdc5c731c123cb8037607840008f4713
commit 925e4270fdc5c731c123cb8037607840008f4713
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 3 14:53:35 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 3 14:53:35 2016 -0400

    cmTarget: Clarify comments in GetMappedConfig
    
    Clarify comments explaining the availability of a target location
    (file on disk) to distinguish this from the existence of the target.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 25ae339..07f07c1 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1438,8 +1438,8 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   }
 
   // If we needed to find one of the mapped configurations but did not
-  // then the target is not found.  The project does not want any
-  // other configuration.
+  // then the target location is not found.  The project does not want
+  // any other configuration.
   if (!mappedConfigs.empty() && !*loc && !*imp) {
     return false;
   }
@@ -1493,7 +1493,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
       }
     }
   }
-  // If we have not yet found it then the target is not available.
+  // If we have not yet found it then the target location is not available.
   if (!*loc && !*imp) {
     return false;
   }

-----------------------------------------------------------------------

Summary of changes:
 Help/manual/cmake-properties.7.rst                 |    2 +
 Help/prop_tgt/IMPORTED_LIBNAME.rst                 |   23 +++++++
 Help/prop_tgt/IMPORTED_LIBNAME_CONFIG.rst          |    7 ++
 Help/release/dev/imported-interface-libname.rst    |    7 ++
 Source/cmComputeLinkInformation.cxx                |    6 ++
 Source/cmGeneratorTarget.cxx                       |   13 ++++
 Source/cmGeneratorTarget.h                         |    4 ++
 Source/cmTarget.cxx                                |   71 +++++++++++++++-----
 Source/cmTarget.h                                  |    3 +
 Source/cmTargetPropertyComputer.cxx                |    4 +-
 Tests/InterfaceLibrary/CMakeLists.txt              |   19 +++++-
 Tests/InterfaceLibrary/definetestexe.cpp           |    3 +-
 .../InterfaceLibrary/item.cpp                      |    2 +-
 Tests/InterfaceLibrary/item_fake.cpp               |    5 ++
 .../IMPORTED_LIBNAME-bad-value-result.txt}         |    0
 .../IMPORTED_LIBNAME-bad-value-stderr.txt          |   44 ++++++++++++
 .../IMPORTED_LIBNAME-bad-value.cmake               |    6 ++
 .../IMPORTED_LIBNAME-non-iface-result.txt}         |    0
 .../IMPORTED_LIBNAME-non-iface-stderr.txt          |   45 +++++++++++++
 .../IMPORTED_LIBNAME-non-iface.cmake               |   17 +++++
 .../IMPORTED_LIBNAME-non-imported-result.txt}      |    0
 .../IMPORTED_LIBNAME-non-imported-stderr.txt       |   21 ++++++
 .../IMPORTED_LIBNAME-non-imported.cmake            |    5 ++
 .../RunCMake/interface_library/RunCMakeTest.cmake  |    3 +
 24 files changed, 288 insertions(+), 22 deletions(-)
 create mode 100644 Help/prop_tgt/IMPORTED_LIBNAME.rst
 create mode 100644 Help/prop_tgt/IMPORTED_LIBNAME_CONFIG.rst
 create mode 100644 Help/release/dev/imported-interface-libname.rst
 copy Modules/DummyCXXFile.cxx => Tests/InterfaceLibrary/item.cpp (59%)
 create mode 100644 Tests/InterfaceLibrary/item_fake.cpp
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => interface_library/IMPORTED_LIBNAME-bad-value-result.txt} (100%)
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => interface_library/IMPORTED_LIBNAME-non-iface-result.txt} (100%)
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => interface_library/IMPORTED_LIBNAME-non-imported-result.txt} (100%)
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list