[Cmake-commits] CMake branch, next, updated. v3.2.2-2045-g0b63279

Brad King brad.king at kitware.com
Wed Apr 22 10:52:52 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  0b63279cae0284a0effe138fa436be66183ed07e (commit)
       via  e4adad1e496cae86b484fb49e22e661f49c1f9a5 (commit)
       via  faede40b46dee698d091e80b8c4658a70a1eb326 (commit)
      from  314156d30f156a714a455e110eb6e03430e6e932 (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=0b63279cae0284a0effe138fa436be66183ed07e
commit 0b63279cae0284a0effe138fa436be66183ed07e
Merge: 314156d e4adad1
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 22 10:52:50 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Apr 22 10:52:50 2015 -0400

    Merge topic 'interface-link-items' into next
    
    e4adad1e Allow INTERFACE libraries to specify link items
    faede40b cmComputeLinkInformation: Reduce 'if' nesting in AddItem


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e4adad1e496cae86b484fb49e22e661f49c1f9a5
commit e4adad1e496cae86b484fb49e22e661f49c1f9a5
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 22 10:29:30 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 22 10:51:27 2015 -0400

    Allow INTERFACE libraries to specify link items
    
    Add an INTERFACE_LINK_ITEMS target property to specify items 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 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 INTERFACE_LINK_ITEMS to refer to the
    SDK library by name.  See issue 15267.

diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index ae5e58e..079e89e 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -819,9 +819,10 @@ It may specify usage requirements such as
 :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`,
 :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS`,
 :prop_tgt:`INTERFACE_COMPILE_OPTIONS`,
-:prop_tgt:`INTERFACE_LINK_LIBRARIES`, and
+:prop_tgt:`INTERFACE_LINK_LIBRARIES`,
 :prop_tgt:`INTERFACE_SOURCES`,
-:prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE`.
+:prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE`,
+and :prop_tgt:`INTERFACE_LINK_ITEMS`.
 Only the ``INTERFACE`` modes of the :command:`target_include_directories`,
 :command:`target_compile_definitions`, :command:`target_compile_options`,
 :command:`target_sources`, and :command:`target_link_libraries` commands
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 02d164b..bed1c38 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -168,6 +168,7 @@ Properties on Targets
    /prop_tgt/INTERFACE_COMPILE_FEATURES
    /prop_tgt/INTERFACE_COMPILE_OPTIONS
    /prop_tgt/INTERFACE_INCLUDE_DIRECTORIES
+   /prop_tgt/INTERFACE_LINK_ITEMS
    /prop_tgt/INTERFACE_LINK_LIBRARIES
    /prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE
    /prop_tgt/INTERFACE_SOURCES
diff --git a/Help/prop_tgt/INTERFACE_LINK_ITEMS.rst b/Help/prop_tgt/INTERFACE_LINK_ITEMS.rst
new file mode 100644
index 0000000..dc10a8f
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_LINK_ITEMS.rst
@@ -0,0 +1,29 @@
+INTERFACE_LINK_ITEMS
+--------------------
+
+Specify link line items for an :ref:`Interface Library <Interface Libraries>`.
+
+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 ``INTERFACE_LINK_ITEMS`` property specifies a
+:ref:`;-list <CMake Language Lists>` of items to be placed on the
+link line in place of the interface library.  One may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+Each 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
+``INTERFACE_LINK_ITEMS`` property does not recognize the keyword
+arguments of that command.  Furthermore, items specified in this
+property are *not* treated as library target names even if they
+happen to name one.  Items may *not* contain ``::`` because CMake
+assumes such names refer to :ref:`Alias Targets` or
+:ref:`Imported Targets` whether they are defined or not.
+
+The ``INTERFACE_LINK_ITEMS`` property is allowed only on
+:ref:`Interface Libraries` and is rejected on targets of other
+types.
diff --git a/Help/release/dev/interface-link-items.rst b/Help/release/dev/interface-link-items.rst
new file mode 100644
index 0000000..6b84918
--- /dev/null
+++ b/Help/release/dev/interface-link-items.rst
@@ -0,0 +1,6 @@
+interface-link-items
+--------------------
+
+* :ref:`Interface Libraries` learned a new :prop_tgt:`INTERFACE_LINK_ITEMS`
+  target property to specify link line items since interface libraries do
+  not have their own library files.
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 6ecf0dc..8cda169 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -659,6 +659,16 @@ 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(), true, tgt));
+
+      // Also add items the interface specifies to be used in its place.
+      std::vector<std::string> ifaceLinkItems;
+      tgt->GetInterfaceLinkItems(ifaceLinkItems, config);
+      for (std::vector<std::string>::iterator i = ifaceLinkItems.begin(),
+             e = ifaceLinkItems.end(); i != e; ++i)
+        {
+        this->AddItem(*i, 0);
+        this->CheckInterfaceLinkItem(tgt, *i);
+        }
       }
     else
       {
@@ -1566,6 +1576,24 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
 }
 
 //----------------------------------------------------------------------------
+void cmComputeLinkInformation::CheckInterfaceLinkItem(cmTarget const* target,
+                                                      std::string const& item)
+{
+  if (item.find("::") == item.npos)
+    {
+    return;
+    }
+  std::ostringstream e;
+  e <<
+    "INTERFACE library \"" << target->GetName() << "\" has an invalid "
+    "INTERFACE_LINK_ITEMS entry \"" << item << "\".  "
+    "Entries may not contain \"::\"."
+    ;
+  this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                    target->GetBacktrace());
+}
+
+//----------------------------------------------------------------------------
 bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
 {
   // Support broken projects if necessary.
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 8847141..e847cf3 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -147,6 +147,7 @@ private:
   bool CheckSharedLibNoSOName(std::string const& item);
   void AddSharedLibNoSOName(std::string const& item);
   void HandleBadFullItem(std::string const& item, std::string const& file);
+  void CheckInterfaceLinkItem(cmTarget const* target, std::string const& item);
 
   // Framework info.
   void ComputeFrameworkInfo();
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index b1203dd..8ae3fb5 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -92,6 +92,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
     this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te,
                                     cmGeneratorExpression::BuildInterface,
                                     properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_LINK_ITEMS", te,
+                                    cmGeneratorExpression::BuildInterface,
+                                    properties, missingTargets);
     this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
                                   te, properties);
     const bool newCMP0022Behavior =
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 6d639c9..d137d91 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -125,6 +125,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
   bool require2_8_12 = false;
   bool require3_0_0 = false;
   bool require3_1_0 = false;
+  bool require3_3_0 = false;
   bool requiresConfigFiles = false;
   // Create all the imported targets.
   for(std::vector<cmTargetExport*>::const_iterator
@@ -166,6 +167,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
                                   te,
                                   cmGeneratorExpression::InstallInterface,
                                   properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_LINK_ITEMS",
+                                  te,
+                                  cmGeneratorExpression::InstallInterface,
+                                  properties, missingTargets);
 
     const bool newCMP0022Behavior =
                               te->GetPolicyStatusCMP0022() != cmPolicies::WARN
@@ -190,6 +195,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
       // can consume them.
       require3_1_0 = true;
       }
+    if(te->GetProperty("INTERFACE_LINK_ITEMS"))
+      {
+      require3_3_0 = true;
+      }
 
     this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
                                   te, properties);
@@ -198,7 +207,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
     this->GenerateInterfaceProperties(te, os, properties);
     }
 
-  if (require3_1_0)
+  if (require3_3_0)
+    {
+    this->GenerateRequiredCMakeVersion(os, DEVEL_CMAKE_VERSION(3,3));
+    }
+  else if (require3_1_0)
     {
     this->GenerateRequiredCMakeVersion(os, "3.1.0");
     }
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index f69e9ae..060ec33 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1762,6 +1762,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
           << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     }
+  else if(prop == "INTERFACE_LINK_ITEMS" &&
+          this->GetType() != cmTarget::INTERFACE_LIBRARY)
+    {
+    std::ostringstream e;
+    e << "INTERFACE_LINK_ITEMS property may be set only on "
+      << "INTERFACE library targets.\n";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+    }
   else if (prop == "LINK_LIBRARIES")
     {
     this->Internal->LinkImplementationPropertyEntries.clear();
@@ -1849,6 +1857,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
           << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     }
+  else if(prop == "INTERFACE_LINK_ITEMS" &&
+          this->GetType() != cmTarget::INTERFACE_LIBRARY)
+    {
+    std::ostringstream e;
+    e << "INTERFACE_LINK_ITEMS property may be set only on "
+      << "INTERFACE library targets.\n";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+    }
   else if (prop == "LINK_LIBRARIES")
     {
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
@@ -2500,6 +2516,28 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
 }
 
 //----------------------------------------------------------------------------
+void cmTarget::GetInterfaceLinkItems(std::vector<std::string> &items,
+                                     std::string const& config) const
+{
+  const char *prop = this->GetProperty("INTERFACE_LINK_ITEMS");
+  if (!prop)
+    {
+    return;
+    }
+  cmGeneratorExpression ge;
+  cmGeneratorExpressionDAGChecker dagChecker(
+                                      this->GetName(),
+                                      "INTERFACE_LINK_ITEMS", 0, 0);
+  cmSystemTools::ExpandListArgument(ge.Parse(prop)
+                                      ->Evaluate(this->Makefile,
+                                                config,
+                                                false,
+                                                this,
+                                                &dagChecker),
+                                    items);
+}
+
+//----------------------------------------------------------------------------
 void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop)
 {
   // Wipe out maps caching information affected by this property.
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a032414..882372b 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -587,6 +587,9 @@ public:
   void GetCompileFeatures(std::vector<std::string> &features,
                           const std::string& config) const;
 
+  void GetInterfaceLinkItems(std::vector<std::string> &items,
+                             std::string const& config) const;
+
   bool IsNullImpliedByLinkLibraries(const std::string &p) const;
   bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
                          const std::string& config) const;
diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt
index 00a5375..2e6fcfc 100644
--- a/Tests/ExportImport/Export/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt
@@ -1,3 +1,9 @@
+add_library(item STATIC item.cpp)
+add_library(item_iface INTERFACE)
+set_property(TARGET item_iface PROPERTY INTERFACE_LINK_ITEMS
+  $<TARGET_FILE:$<TARGET_NAME:item>>
+)
+add_dependencies(item_iface item)
 
 add_library(headeronly INTERFACE)
 set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES
@@ -21,7 +27,7 @@ set_property(TARGET sharedlib PROPERTY INTERFACE_INCLUDE_DIRECTORIES
 set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_DEFINE")
 
 add_library(sharediface INTERFACE)
-target_link_libraries(sharediface INTERFACE sharedlib)
+target_link_libraries(sharediface INTERFACE sharedlib item_iface)
 
 add_library(use_auto_type INTERFACE)
 target_compile_features(use_auto_type INTERFACE cxx_auto_type)
@@ -40,9 +46,11 @@ install(FILES
 )
 
 install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target
+                item_iface
   EXPORT expInterface
 )
 install(TARGETS sharedlib
+                item
   EXPORT expInterface
   RUNTIME DESTINATION bin
   LIBRARY DESTINATION lib NAMELINK_SKIP
diff --git a/Tests/ExportImport/Export/Interface/item.cpp b/Tests/ExportImport/Export/Interface/item.cpp
new file mode 100644
index 0000000..be612c9
--- /dev/null
+++ b/Tests/ExportImport/Export/Interface/item.cpp
@@ -0,0 +1 @@
+int item() { return 0; }
diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp
index 786458d..f9d2bd9 100644
--- a/Tests/ExportImport/Import/Interface/interfacetest.cpp
+++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp
@@ -13,8 +13,12 @@
 #error Expected DEFINE_IFACE_DEFINE
 #endif
 
+extern int item();
+
 int main(int,char**)
 {
   SharedLibObject slo;
-  return slo.foo();
+  return slo.foo()
+    + item()
+    ;
 }
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
index ee81419..6fa0016 100644
--- a/Tests/InterfaceLibrary/CMakeLists.txt
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -25,8 +25,22 @@ target_sources(iface_objlib INTERFACE $<TARGET_OBJECTS:objlib>)
 add_library(intermediate INTERFACE)
 target_link_libraries(intermediate INTERFACE iface_objlib)
 
+add_library(item STATIC item.cpp)
+add_library(item_iface INTERFACE)
+set_property(TARGET item_iface PROPERTY INTERFACE_LINK_ITEMS $<TARGET_FILE:item>)
+add_dependencies(item_iface item)
+add_library(item_fake STATIC item_fake.cpp)
+
 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' is ordered in place of item_iface
+  )
 
 add_subdirectory(libsdir)
 
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
index 9044076..e6b7f58 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..be612c9
--- /dev/null
+++ b/Tests/InterfaceLibrary/item.cpp
@@ -0,0 +1 @@
+int item() { return 0; }
diff --git a/Tests/InterfaceLibrary/item_fake.cpp b/Tests/InterfaceLibrary/item_fake.cpp
new file mode 100644
index 0000000..3944710
--- /dev/null
+++ b/Tests/InterfaceLibrary/item_fake.cpp
@@ -0,0 +1,2 @@
+extern int item_undefined();
+int item() { return item_undefined(); }
diff --git a/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-result.txt b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-stderr.txt b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-stderr.txt
new file mode 100644
index 0000000..d2c0a30
--- /dev/null
+++ b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-stderr.txt
@@ -0,0 +1,6 @@
+^(CMake Error at INTERFACE_LINK_ITEMS-invalid_item.cmake:[0-9]+ \(add_library\):
+  INTERFACE library "SomeIFace" has an invalid INTERFACE_LINK_ITEMS entry
+  "bad::item".  Entries may not contain "::".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+*)+$
diff --git a/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item.cmake b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item.cmake
new file mode 100644
index 0000000..e81a3c9
--- /dev/null
+++ b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(SomeIFace INTERFACE)
+set_property(TARGET SomeIFace APPEND PROPERTY INTERFACE_LINK_ITEMS bad::item)
+add_executable(main main.c)
+target_link_libraries(main SomeIFace)
diff --git a/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-result.txt b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-stderr.txt b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-stderr.txt
new file mode 100644
index 0000000..9609b94
--- /dev/null
+++ b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Error at INTERFACE_LINK_ITEMS-non-iface.cmake:[0-9]+ \(set_property\):
+  INTERFACE_LINK_ITEMS property may be set only on INTERFACE library targets.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at INTERFACE_LINK_ITEMS-non-iface.cmake:[0-9]+ \(set_property\):
+  INTERFACE_LINK_ITEMS property may be set only on INTERFACE library targets.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface.cmake b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface.cmake
new file mode 100644
index 0000000..49b1e53
--- /dev/null
+++ b/Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface.cmake
@@ -0,0 +1,3 @@
+add_custom_target(MyTarget)
+set_property(TARGET MyTarget PROPERTY INTERFACE_LINK_ITEMS item1)
+set_property(TARGET MyTarget APPEND PROPERTY INTERFACE_LINK_ITEMS item2)
diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
index 201daa7..2679ceb 100644
--- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
@@ -8,3 +8,5 @@ run_cmake(invalid_signature)
 run_cmake(global-interface)
 run_cmake(genex_link)
 run_cmake(add_custom_command-TARGET)
+run_cmake(INTERFACE_LINK_ITEMS-non-iface)
+run_cmake(INTERFACE_LINK_ITEMS-invalid_item)
diff --git a/Tests/RunCMake/interface_library/main.c b/Tests/RunCMake/interface_library/main.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/Tests/RunCMake/interface_library/main.c
@@ -0,0 +1 @@
+int main(void) { return 0; }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=faede40b46dee698d091e80b8c4658a70a1eb326
commit faede40b46dee698d091e80b8c4658a70a1eb326
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Apr 21 13:51:51 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 21 14:03:02 2015 -0400

    cmComputeLinkInformation: Reduce 'if' nesting in AddItem
    
    Also add a comment explaining why interface libraries still get a link
    item.

diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 83d38ef..6ecf0dc 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -653,6 +653,13 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       this->Items.push_back(Item(linkItem, true, tgt));
       this->Depends.push_back(exe);
       }
+    else if(tgt->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      // Add the interface library as an item so it can be considered as part
+      // of COMPATIBLE_INTERFACE_ enforcement.  The generators will ignore
+      // this for the actual link line.
+      this->Items.push_back(Item(std::string(), true, tgt));
+      }
     else
       {
       // Decide whether to use an import library.
@@ -660,11 +667,6 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
         (this->UseImportLibrary &&
          (impexe || tgt->GetType() == cmTarget::SHARED_LIBRARY));
 
-      if(tgt->GetType() == cmTarget::INTERFACE_LIBRARY)
-        {
-        this->Items.push_back(Item(std::string(), true, tgt));
-        return;
-        }
       // Pass the full path to the target file.
       std::string lib = tgt->GetFullPath(config, implib, true);
       if(!this->LinkDependsNoShared ||

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

Summary of changes:
 Help/manual/cmake-buildsystem.7.rst                |    5 ++-
 Help/manual/cmake-properties.7.rst                 |    1 +
 Help/prop_tgt/INTERFACE_LINK_ITEMS.rst             |   29 ++++++++++++++
 Help/release/dev/interface-link-items.rst          |    6 +++
 Source/cmComputeLinkInformation.cxx                |   40 +++++++++++++++++---
 Source/cmComputeLinkInformation.h                  |    1 +
 Source/cmExportBuildFileGenerator.cxx              |    3 ++
 Source/cmExportInstallFileGenerator.cxx            |   15 +++++++-
 Source/cmTarget.cxx                                |   38 +++++++++++++++++++
 Source/cmTarget.h                                  |    3 ++
 Tests/ExportImport/Export/Interface/CMakeLists.txt |   10 ++++-
 Tests/ExportImport/Export/Interface/item.cpp       |    1 +
 .../Import/Interface/interfacetest.cpp             |    6 ++-
 Tests/InterfaceLibrary/CMakeLists.txt              |   16 +++++++-
 Tests/InterfaceLibrary/definetestexe.cpp           |    3 +-
 Tests/InterfaceLibrary/item.cpp                    |    1 +
 Tests/InterfaceLibrary/item_fake.cpp               |    2 +
 .../INTERFACE_LINK_ITEMS-invalid_item-result.txt}  |    0
 .../INTERFACE_LINK_ITEMS-invalid_item-stderr.txt   |    6 +++
 .../INTERFACE_LINK_ITEMS-invalid_item.cmake        |    6 +++
 .../INTERFACE_LINK_ITEMS-non-iface-result.txt}     |    0
 .../INTERFACE_LINK_ITEMS-non-iface-stderr.txt      |   11 ++++++
 .../INTERFACE_LINK_ITEMS-non-iface.cmake           |    3 ++
 .../RunCMake/interface_library/RunCMakeTest.cmake  |    2 +
 .../interface_library}/main.c                      |    0
 25 files changed, 196 insertions(+), 12 deletions(-)
 create mode 100644 Help/prop_tgt/INTERFACE_LINK_ITEMS.rst
 create mode 100644 Help/release/dev/interface-link-items.rst
 create mode 100644 Tests/ExportImport/Export/Interface/item.cpp
 create mode 100644 Tests/InterfaceLibrary/item.cpp
 create mode 100644 Tests/InterfaceLibrary/item_fake.cpp
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => interface_library/INTERFACE_LINK_ITEMS-invalid_item-result.txt} (100%)
 create mode 100644 Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item-stderr.txt
 create mode 100644 Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-invalid_item.cmake
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => interface_library/INTERFACE_LINK_ITEMS-non-iface-result.txt} (100%)
 create mode 100644 Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface-stderr.txt
 create mode 100644 Tests/RunCMake/interface_library/INTERFACE_LINK_ITEMS-non-iface.cmake
 copy Tests/{CMakeOnly/LinkInterfaceLoop => RunCMake/interface_library}/main.c (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list