[Cmake-commits] CMake branch, next, updated. v2.8.12-3736-gbe7a948

Stephen Kelly steveire at gmail.com
Wed Oct 9 19:04:47 EDT 2013


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  be7a948b7ef580a0eecb51cee2a0a5f0112e50d2 (commit)
       via  2303cb18cd024ebf1a4e4fa748b45a3ef2092124 (commit)
      from  3b257e09aab8a00e5395288485802def7d07d1a0 (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=be7a948b7ef580a0eecb51cee2a0a5f0112e50d2
commit be7a948b7ef580a0eecb51cee2a0a5f0112e50d2
Merge: 3b257e0 2303cb1
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Oct 9 19:04:34 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Oct 9 19:04:34 2013 -0400

    Merge topic 'INTERFACE_LIBRARY-build-targets' into next
    
    2303cb1 Create make rules for INTERFACE_LIBRARY targets.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2303cb18cd024ebf1a4e4fa748b45a3ef2092124
commit 2303cb18cd024ebf1a4e4fa748b45a3ef2092124
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Aug 21 22:00:48 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 10 01:03:36 2013 +0200

    Create make rules for INTERFACE_LIBRARY targets.
    
    The result is that the depends of the target are created.
    
    So,
    
     add_library(somelib foo.cpp)
     add_library(anotherlib EXCLUDE_FROM_ALL foo.cpp)
     add_library(extra EXCLUDE_FROM_ALL foo.cpp)
     target_link_libraries(anotherlib extra)
    
     add_library(iface INTERFACE)
     target_link_libraries(iface INTERFACE anotherlib)
    
    Executing 'make iface' will result in the anotherlib and extra targets
    being made.
    
    Adding a regular executable to the INTERFACE of an INTERFACE_LIBRARY
    will not result in the executable being built with 'make iface' because
    of the logic in cmComputeTargetDepends::AddTargetDepend.
    
    So far, this is implemented only for the Makefile generator. Other
    generators will follow if this feature is possible for them.

diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 0829add..7fd4754 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -208,7 +208,15 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
   std::set<cmStdString> emitted;
   {
   std::vector<std::string> tlibs;
-  depender->GetDirectLinkLibraries(0, tlibs, depender);
+  if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
+    {
+    // For INTERFACE_LIBRARY depend on the interface instead.
+    depender->GetInterfaceLinkLibraries(0, tlibs, depender);
+    }
+  else
+    {
+    depender->GetDirectLinkLibraries(0, tlibs, depender);
+    }
   // A target should not depend on itself.
   emitted.insert(depender->GetName());
   for(std::vector<std::string>::const_iterator lib = tlibs.begin();
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 9e23ae9..6713995 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -439,6 +439,7 @@ cmGlobalUnixMakefileGenerator3
        (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
        (l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
        (l->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
+       (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) ||
        (l->second.GetType() == cmTarget::UTILITY))
       {
       // Add this to the list of depends rules in this directory.
@@ -616,6 +617,7 @@ cmGlobalUnixMakefileGenerator3
           (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
           (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
           (t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
+          (t->second.GetType() == cmTarget::INTERFACE_LIBRARY) ||
           (t->second.GetType() == cmTarget::UTILITY)))
         {
         // Add a rule to build the target by name.
@@ -637,6 +639,10 @@ cmGlobalUnixMakefileGenerator3
                           t->second.GetName(), depends, commands,
                           true);
 
+        if (t->second.GetType() == cmTarget::INTERFACE_LIBRARY)
+          {
+          continue;
+          }
         // Add a fast rule to build the target
         std::string localName = lg->GetRelativeTargetDirectory(t->second);
         std::string makefileName;
@@ -703,6 +709,7 @@ cmGlobalUnixMakefileGenerator3
         || (t->second.GetType() == cmTarget::SHARED_LIBRARY)
         || (t->second.GetType() == cmTarget::MODULE_LIBRARY)
         || (t->second.GetType() == cmTarget::OBJECT_LIBRARY)
+        || (t->second.GetType() == cmTarget::INTERFACE_LIBRARY)
         || (t->second.GetType() == cmTarget::UTILITY)))
       {
       std::string makefileName;
@@ -719,69 +726,77 @@ cmGlobalUnixMakefileGenerator3
         << localName << "\n\n";
 
       commands.clear();
-      makeTargetName = localName;
-      makeTargetName += "/depend";
-      commands.push_back(lg->GetRecursiveMakeCall
-                         (makefileName.c_str(),makeTargetName.c_str()));
 
-      // add requires if we need it for this generator
-      if (needRequiresStep)
+      if(t->second.GetType() != cmTarget::INTERFACE_LIBRARY)
         {
         makeTargetName = localName;
-        makeTargetName += "/requires";
+        makeTargetName += "/depend";
         commands.push_back(lg->GetRecursiveMakeCall
-                           (makefileName.c_str(),makeTargetName.c_str()));
-        }
-      makeTargetName = localName;
-      makeTargetName += "/build";
-      commands.push_back(lg->GetRecursiveMakeCall
                           (makefileName.c_str(),makeTargetName.c_str()));
 
-      // Write the rule.
-      localName += "/all";
-      depends.clear();
+        // add requires if we need it for this generator
+        if (needRequiresStep)
+          {
+          makeTargetName = localName;
+          makeTargetName += "/requires";
+          commands.push_back(lg->GetRecursiveMakeCall
+                            (makefileName.c_str(),makeTargetName.c_str()));
+          }
+        makeTargetName = localName;
+        makeTargetName += "/build";
+        commands.push_back(lg->GetRecursiveMakeCall
+                            (makefileName.c_str(),makeTargetName.c_str()));
 
-      std::string progressDir =
-        lg->GetMakefile()->GetHomeOutputDirectory();
-      progressDir += cmake::GetCMakeFilesDirectory();
-        {
-        cmOStringStream progCmd;
-        progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
-        // all target counts
-        progCmd << lg->Convert(progressDir.c_str(),
-                                cmLocalGenerator::FULL,
-                                cmLocalGenerator::SHELL);
-        progCmd << " ";
-        std::vector<unsigned long>& progFiles =
-          this->ProgressMap[&t->second].Marks;
-        for (std::vector<unsigned long>::iterator i = progFiles.begin();
-              i != progFiles.end(); ++i)
+        // Write the rule.
+        localName += "/all";
+        depends.clear();
+
+        std::string progressDir =
+          lg->GetMakefile()->GetHomeOutputDirectory();
+        progressDir += cmake::GetCMakeFilesDirectory();
           {
-          progCmd << " " << *i;
+          cmOStringStream progCmd;
+          progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
+          // all target counts
+          progCmd << lg->Convert(progressDir.c_str(),
+                                  cmLocalGenerator::FULL,
+                                  cmLocalGenerator::SHELL);
+          progCmd << " ";
+          std::vector<unsigned long>& progFiles =
+            this->ProgressMap[&t->second].Marks;
+          for (std::vector<unsigned long>::iterator i = progFiles.begin();
+                i != progFiles.end(); ++i)
+            {
+            progCmd << " " << *i;
+            }
+          commands.push_back(progCmd.str());
           }
-        commands.push_back(progCmd.str());
+        progressDir = "Built target ";
+        progressDir += t->first;
+        lg->AppendEcho(commands,progressDir.c_str());
         }
-      progressDir = "Built target ";
-      progressDir += t->first;
-      lg->AppendEcho(commands,progressDir.c_str());
 
       this->AppendGlobalTargetDepends(depends,t->second);
+
       lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
                         localName.c_str(), depends, commands, true);
 
-      // add the all/all dependency
-      if(!this->IsExcluded(this->LocalGenerators[0], t->second))
+      if(t->second.GetType() != cmTarget::INTERFACE_LIBRARY)
         {
-        depends.clear();
-        depends.push_back(localName);
-        commands.clear();
-        lg->WriteMakeRule(ruleFileStream, "Include target in all.",
-                          "all", depends, commands, true);
+        // add the all/all dependency
+        if(!this->IsExcluded(this->LocalGenerators[0], t->second))
+          {
+          depends.clear();
+          depends.push_back(localName);
+          commands.clear();
+          lg->WriteMakeRule(ruleFileStream, "Include target in all.",
+                            "all", depends, commands, true);
+          }
         }
 
       // Write the rule.
       commands.clear();
-      progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
+      std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
       progressDir += cmake::GetCMakeFilesDirectory();
 
       {
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 2443583..4725459 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -381,6 +381,7 @@ void cmLocalUnixMakefileGenerator3
        (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
        (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
        (t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
+       (t->second.GetType() == cmTarget::INTERFACE_LIBRARY) ||
        (t->second.GetType() == cmTarget::UTILITY))
       {
       emitted.insert(t->second.GetName());
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index ea9663f..29365a3 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -82,6 +82,9 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
     case cmTarget::OBJECT_LIBRARY:
       this->WriteObjectLibraryRules();
       break;
+    case cmTarget::INTERFACE_LIBRARY:
+      // Nothing to do.
+      break;
     default:
       // If language is not known, this is an error.
       cmSystemTools::Error("Unknown Library Type");
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 42091e3..13410f1 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -75,6 +75,7 @@ cmMakefileTargetGenerator::New(cmTarget *tgt)
     case cmTarget::SHARED_LIBRARY:
     case cmTarget::MODULE_LIBRARY:
     case cmTarget::OBJECT_LIBRARY:
+    case cmTarget::INTERFACE_LIBRARY:
       result = new cmMakefileLibraryTargetGenerator(tgt);
       break;
     case cmTarget::UTILITY:
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1c04e4e..55745a9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2485,6 +2485,29 @@ void cmTarget::GetDirectLinkLibraries(const char *config,
 }
 
 //----------------------------------------------------------------------------
+void cmTarget::GetInterfaceLinkLibraries(const char *config,
+                            std::vector<std::string> &libs, cmTarget *head)
+{
+  const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES");
+  if (prop)
+    {
+    cmListFileBacktrace lfbt;
+    cmGeneratorExpression ge(lfbt);
+    const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+
+    cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+                                        this->GetName(),
+                                        "INTERFACE_LINK_LIBRARIES", 0, 0);
+    cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile,
+                                        config,
+                                        false,
+                                        head,
+                                        &dagChecker),
+                                      libs);
+    }
+}
+
+//----------------------------------------------------------------------------
 std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
                                   cmTarget::LinkLibraryType llt)
 {
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a88c5ec..4474971 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -177,6 +177,9 @@ public:
   void GetDirectLinkLibraries(const char *config,
                               std::vector<std::string> &,
                               cmTarget *head);
+  void GetInterfaceLinkLibraries(const char *config,
+                              std::vector<std::string> &,
+                              cmTarget *head);
 
   /** Compute the link type to use for the given configuration.  */
   LinkLibraryType ComputeLinkType(const char* config);
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 9afc112..d673adb 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -261,6 +261,20 @@ if(BUILD_TESTING)
       PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
   endif()
 
+  if(CMAKE_GENERATOR MATCHES Make)
+    add_test(InterfaceBuildTargets ${CMAKE_CTEST_COMMAND}
+      --build-and-test
+      "${CMake_SOURCE_DIR}/Tests/InterfaceBuildTargets"
+      "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets"
+      --build-two-config
+      ${build_generator_args}
+      --build-project InterfaceBuildTargets
+      --build-target iface
+      --test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate testlib
+      )
+    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets")
+  endif()
+
   list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
 
   if(NOT QT4_FOUND)
diff --git a/Tests/InterfaceBuildTargets/CMakeLists.txt b/Tests/InterfaceBuildTargets/CMakeLists.txt
new file mode 100644
index 0000000..ad92578
--- /dev/null
+++ b/Tests/InterfaceBuildTargets/CMakeLists.txt
@@ -0,0 +1,8 @@
+project(InterfaceBuildTargets)
+
+add_library(testlib testlib.cxx)
+set_property(TARGET testlib PROPERTY PREFIX "")
+set_property(TARGET testlib PROPERTY SUFFIX "")
+
+add_library(iface INTERFACE)
+target_link_libraries(iface INTERFACE testlib)
diff --git a/Tests/InterfaceBuildTargets/main.cxx b/Tests/InterfaceBuildTargets/main.cxx
new file mode 100644
index 0000000..e9ad257
--- /dev/null
+++ b/Tests/InterfaceBuildTargets/main.cxx
@@ -0,0 +1,5 @@
+
+int main(int, char**)
+{
+  return 0;
+}

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

Summary of changes:
 Source/cmComputeTargetDepends.cxx           |   10 +++-
 Source/cmGlobalUnixMakefileGenerator3.cxx   |  101 +++++++++++++++-----------
 Source/cmLocalUnixMakefileGenerator3.cxx    |    1 +
 Source/cmMakefileLibraryTargetGenerator.cxx |    3 +
 Source/cmMakefileTargetGenerator.cxx        |    1 +
 Source/cmTarget.cxx                         |   23 ++++++
 Source/cmTarget.h                           |    3 +
 Tests/CMakeLists.txt                        |   14 ++++
 Tests/InterfaceBuildTargets/CMakeLists.txt  |    8 ++
 Tests/InterfaceBuildTargets/main.cxx        |    5 ++
 10 files changed, 125 insertions(+), 44 deletions(-)
 create mode 100644 Tests/InterfaceBuildTargets/CMakeLists.txt
 create mode 100644 Tests/InterfaceBuildTargets/main.cxx


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list