[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3336-g4f8cba9

Brad King brad.king at kitware.com
Wed Jul 24 11:45: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  4f8cba99d903cb9f56afb369a57ca94b091f9460 (commit)
       via  caa68636930d96b9277556148e5db6eb6f84bf75 (commit)
       via  37812504128c2ed07f103bb741c218bd62bb1cbb (commit)
      from  03702f00f9513f9361f8f99e6786d002bfdaecd0 (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=4f8cba99d903cb9f56afb369a57ca94b091f9460
commit 4f8cba99d903cb9f56afb369a57ca94b091f9460
Merge: 03702f0 caa6863
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 24 11:45:39 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jul 24 11:45:39 2013 -0400

    Merge topic 'framework-interface-includes' into next
    
    caa6863 Use linked frameworks as a source of include directories.
    3781250 target_link_libraries: Add PUBLIC/PRIVATE/INTERFACE keyword signature


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=caa68636930d96b9277556148e5db6eb6f84bf75
commit caa68636930d96b9277556148e5db6eb6f84bf75
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Jul 8 16:59:03 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jul 24 11:44:37 2013 -0400

    Use linked frameworks as a source of include directories.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index a043c05..34856ae 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3395,6 +3395,34 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
                         new cmTargetInternals::TargetPropertyEntry(cge,
                                                               it->Value));
       }
+
+    if(this->Makefile->IsOn("APPLE"))
+      {
+      LinkImplementation const* impl = this->GetLinkImplementation(config,
+                                                                   this);
+      for(std::vector<std::string>::const_iterator
+          it = impl->Libraries.begin();
+          it != impl->Libraries.end(); ++it)
+        {
+        std::string libDir = cmSystemTools::CollapseFullPath(it->c_str());
+
+        static cmsys::RegularExpression
+          frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
+        if(!frameworkCheck.find(libDir))
+          {
+          continue;
+          }
+
+        libDir = frameworkCheck.match(1);
+
+        cmGeneratorExpression ge(lfbt);
+        cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+                  ge.Parse(libDir.c_str());
+        this->Internal
+                ->CachedLinkInterfaceIncludeDirectoriesEntries[configString]
+                .push_back(new cmTargetInternals::TargetPropertyEntry(cge));
+        }
+      }
     }
 
   processIncludeDirectories(this,
diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h
index 96cfe65..9ee54ab 100644
--- a/Source/cmTargetLinkLibrariesCommand.h
+++ b/Source/cmTargetLinkLibrariesCommand.h
@@ -109,6 +109,11 @@ public:
       " INTERFACE_POSITION_INDEPENDENT_CODE: Sets POSITION_INDEPENDENT_CODE\n"
       "   or checked for consistency with existing value\n"
       "\n"
+      "If an <item> is a library in a Mac OX framework, the Headers "
+      "directory of the framework will also be processed as a \"usage "
+      "requirement\".  This has the same effect as passing the framework "
+      "directory as an include directory."
+      "\n"
       "  target_link_libraries(<target>\n"
       "                      <PRIVATE|PUBLIC|INTERFACE> <lib> ...\n"
       "                      [<PRIVATE|PUBLIC|INTERFACE> <lib> ... ] ...])\n"
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index f810f3b..3262523 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -312,6 +312,12 @@ install(
   FRAMEWORK DESTINATION Frameworks
   BUNDLE DESTINATION Applications
   )
+if (APPLE)
+  file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/testLib4.framework/Headers)
+  file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/testLib4.framework/Headers)
+  file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/testLib4.framework/Headers)
+  install(FILES testLib4.h DESTINATION Frameworks/testLib4.framework/Headers)
+endif()
 install(
   TARGETS
   testExe2libImp testLib3Imp
diff --git a/Tests/ExportImport/Export/testLib4.h b/Tests/ExportImport/Export/testLib4.h
new file mode 100644
index 0000000..9eeda7c
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib4.h
@@ -0,0 +1,2 @@
+
+#define TESTLIB4_H
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index aa8847b..2627354 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -210,6 +210,10 @@ if (run_pic_test)
   target_compile_definitions(deps_shared_iface PRIVATE CHECK_PIC_WORKS)
 endif()
 
+if(APPLE)
+  add_subdirectory(framework_interface)
+endif()
+
 #-----------------------------------------------------------------------------
 # Test that targets imported from the build tree have their dependencies
 # evaluated correctly. The above already tests the same for the install tree.
diff --git a/Tests/ExportImport/Import/A/framework_interface/CMakeLists.txt b/Tests/ExportImport/Import/A/framework_interface/CMakeLists.txt
new file mode 100644
index 0000000..0e00655
--- /dev/null
+++ b/Tests/ExportImport/Import/A/framework_interface/CMakeLists.txt
@@ -0,0 +1,9 @@
+
+add_library(exp_framework_test framework_test.cpp)
+get_target_property(exp_loc exp_testLib4 LOCATION)
+target_link_libraries(exp_framework_test ${exp_loc})
+
+
+add_library(bld_framework_test framework_test.cpp)
+get_target_property(bld_loc bld_testLib4 LOCATION)
+target_link_libraries(bld_framework_test ${bld_loc})
diff --git a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp
new file mode 100644
index 0000000..357f64f
--- /dev/null
+++ b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp
@@ -0,0 +1,6 @@
+
+#include <testLib4/testLib4.h>
+
+#ifndef TESTLIB4_H
+#error Expected define TESTLIB4_H
+#endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=37812504128c2ed07f103bb741c218bd62bb1cbb
commit 37812504128c2ed07f103bb741c218bd62bb1cbb
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Jun 4 16:21:33 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jul 24 11:42:10 2013 -0400

    target_link_libraries: Add PUBLIC/PRIVATE/INTERFACE keyword signature
    
    Add a new signature to help populate INTERFACE_LINK_LIBRARIES and
    LINK_LIBRARIES cleanly in a single call.  Add policy CMP0023 to control
    whether the keyword signatures can be mixed with uses of the plain
    signatures on the same target.

diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 70c28d4..6054b34 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -575,6 +575,32 @@ cmPolicies::cmPolicies()
     "property for in-build targets, and ignore the old properties matching "
     "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?.",
     2,8,11,20130516, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0023, "CMP0023",
+    "Plain and keyword target_link_libraries signatures cannot be mixed.",
+    "CMake 2.8.12 introduced the target_link_libraries signature using "
+    "the PUBLIC, PRIVATE, and INTERFACE keywords to generalize the "
+    "LINK_PUBLIC and LINK_PRIVATE keywords introduced in CMake 2.8.7.  "
+    "Use of signatures with any of these keywords sets the link interface "
+    "of a target explicitly, even if empty.  "
+    "This produces confusing behavior when used in combination with the "
+    "historical behavior of the plain target_link_libraries signature.  "
+    "For example, consider the code:\n"
+    " target_link_libraries(mylib A)\n"
+    " target_link_libraries(mylib PRIVATE B)\n"
+    "After the first line the link interface has not been set explicitly "
+    "so CMake would use the link implementation, A, as the link interface.  "
+    "However, the second line sets the link interface to empty.  "
+    "In order to avoid this subtle behavior CMake now prefers to disallow "
+    "mixing the plain and keyword signatures of target_link_libraries for "
+    "a single target."
+    "\n"
+    "The OLD behavior for this policy is to allow keyword and plain "
+    "target_link_libraries signatures to be mixed.  "
+    "The NEW behavior for this policy is to not to allow mixing of the "
+    "keyword and plain signatures.",
+    2,8,11,20130516, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 20c953f..5b843a9 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -73,6 +73,7 @@ public:
     CMP0021, ///< Fatal error on relative paths in INCLUDE_DIRECTORIES
     /// target property
     CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
+    CMP0023, ///< Disallow mixing keyword and plain tll signatures
 
     /** \brief Always the last entry.
      *
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 70500cd..a043c05 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2497,6 +2497,57 @@ static std::string targetNameGenex(const char *lib)
 }
 
 //----------------------------------------------------------------------------
+bool cmTarget::PushTLLCommandTrace(TLLSignature signature)
+{
+  bool ret = true;
+  if (!this->TLLCommands.empty())
+    {
+    if (this->TLLCommands.back().first != signature)
+      {
+      ret = false;
+      }
+    }
+  cmListFileBacktrace lfbt;
+  this->Makefile->GetBacktrace(lfbt);
+  this->TLLCommands.push_back(std::make_pair(signature, lfbt));
+  return ret;
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
+                                     TLLSignature sig) const
+{
+  std::vector<cmListFileBacktrace> sigs;
+  typedef std::vector<std::pair<TLLSignature, cmListFileBacktrace> > Container;
+  for(Container::const_iterator it = this->TLLCommands.begin();
+      it != this->TLLCommands.end(); ++it)
+    {
+    if (it->first == sig)
+      {
+      sigs.push_back(it->second);
+      }
+    }
+  if (!sigs.empty())
+    {
+    const char *sigString
+                        = (sig == cmTarget::KeywordTLLSignature ? "keyword"
+                                                                : "plain");
+    s << "The uses of the " << sigString << " signature are here:\n";
+    for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin();
+        it != sigs.end(); ++it)
+      {
+      cmListFileBacktrace::const_iterator i = it->begin();
+      if(i != it->end())
+        {
+        cmListFileContext const& lfc = *i;
+        s << " * " << (lfc.Line? "": " in ") << lfc << std::endl;
+        ++i;
+        }
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
 void cmTarget::AddLinkLibrary(cmMakefile& mf,
                               const char *target, const char* lib,
                               LinkLibraryType llt)
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 0da0f12..24a71ed 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -190,6 +190,12 @@ public:
   void AddLinkLibrary(cmMakefile& mf,
                       const char *target, const char* lib,
                       LinkLibraryType llt);
+  enum TLLSignature {
+    KeywordTLLSignature,
+    PlainTLLSignature
+  };
+  bool PushTLLCommandTrace(TLLSignature signature);
+  void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
 
   void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
                            const LinkLibraryVectorType& libs );
@@ -548,6 +554,8 @@ private:
   // directories.
   std::set<cmStdString> SystemIncludeDirectories;
 
+  std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;
+
   /**
    * A list of direct dependencies. Use in conjunction with DependencyMap.
    */
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index c5f490e..0ee9420 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -116,7 +116,7 @@ bool cmTargetLinkLibrariesCommand
     {
     if(args[i] == "LINK_INTERFACE_LIBRARIES")
       {
-      this->CurrentProcessingState = ProcessingLinkInterface;
+      this->CurrentProcessingState = ProcessingPlainLinkInterface;
       if(i != 1)
         {
         this->Makefile->IssueMessage(
@@ -127,9 +127,26 @@ bool cmTargetLinkLibrariesCommand
         return true;
         }
       }
+    else if(args[i] == "INTERFACE")
+      {
+      if(i != 1
+          && this->CurrentProcessingState != ProcessingKeywordPrivateInterface
+          && this->CurrentProcessingState != ProcessingKeywordPublicInterface
+          && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
+        {
+        this->Makefile->IssueMessage(
+          cmake::FATAL_ERROR,
+          "The INTERFACE option must appear as the second "
+          "argument, just after the target name."
+          );
+        return true;
+        }
+      this->CurrentProcessingState = ProcessingKeywordLinkInterface;
+      }
     else if(args[i] == "LINK_PUBLIC")
       {
-      if(i != 1 && this->CurrentProcessingState != ProcessingPrivateInterface)
+      if(i != 1
+          && this->CurrentProcessingState != ProcessingPlainPrivateInterface)
         {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
@@ -138,11 +155,28 @@ bool cmTargetLinkLibrariesCommand
           );
         return true;
         }
-      this->CurrentProcessingState = ProcessingPublicInterface;
+      this->CurrentProcessingState = ProcessingPlainPublicInterface;
+      }
+    else if(args[i] == "PUBLIC")
+      {
+      if(i != 1
+          && this->CurrentProcessingState != ProcessingKeywordPrivateInterface
+          && this->CurrentProcessingState != ProcessingKeywordPublicInterface
+          && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
+        {
+        this->Makefile->IssueMessage(
+          cmake::FATAL_ERROR,
+          "The PUBLIC or PRIVATE option must appear as the second "
+          "argument, just after the target name."
+          );
+        return true;
+        }
+      this->CurrentProcessingState = ProcessingKeywordPublicInterface;
       }
     else if(args[i] == "LINK_PRIVATE")
       {
-      if(i != 1 && this->CurrentProcessingState != ProcessingPublicInterface)
+      if(i != 1
+          && this->CurrentProcessingState != ProcessingPlainPublicInterface)
         {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
@@ -151,7 +185,23 @@ bool cmTargetLinkLibrariesCommand
           );
         return true;
         }
-      this->CurrentProcessingState = ProcessingPrivateInterface;
+      this->CurrentProcessingState = ProcessingPlainPrivateInterface;
+      }
+    else if(args[i] == "PRIVATE")
+      {
+      if(i != 1
+          && this->CurrentProcessingState != ProcessingKeywordPrivateInterface
+          && this->CurrentProcessingState != ProcessingKeywordPublicInterface
+          && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
+        {
+        this->Makefile->IssueMessage(
+          cmake::FATAL_ERROR,
+          "The PUBLIC or PRIVATE option must appear as the second "
+          "argument, just after the target name."
+          );
+        return true;
+        }
+      this->CurrentProcessingState = ProcessingKeywordPrivateInterface;
       }
     else if(args[i] == "debug")
       {
@@ -184,7 +234,10 @@ bool cmTargetLinkLibrariesCommand
       {
       // The link type was specified by the previous argument.
       haveLLT = false;
-      this->HandleLibrary(args[i].c_str(), llt);
+      if (!this->HandleLibrary(args[i].c_str(), llt))
+        {
+        return false;
+        }
       }
     else
       {
@@ -210,7 +263,10 @@ bool cmTargetLinkLibrariesCommand
           llt = cmTarget::OPTIMIZED;
           }
         }
-      this->HandleLibrary(args[i].c_str(), llt);
+      if (!this->HandleLibrary(args[i].c_str(), llt))
+        {
+        return false;
+        }
       }
     }
 
@@ -257,16 +313,69 @@ cmTargetLinkLibrariesCommand
 }
 
 //----------------------------------------------------------------------------
-void
+bool
 cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
                                             cmTarget::LinkLibraryType llt)
 {
+  cmTarget::TLLSignature sig =
+        (this->CurrentProcessingState == ProcessingPlainPrivateInterface
+      || this->CurrentProcessingState == ProcessingPlainPublicInterface
+      || this->CurrentProcessingState == ProcessingKeywordPrivateInterface
+      || this->CurrentProcessingState == ProcessingKeywordPublicInterface
+      || this->CurrentProcessingState == ProcessingKeywordLinkInterface)
+        ? cmTarget::KeywordTLLSignature : cmTarget::PlainTLLSignature;
+  if (!this->Target->PushTLLCommandTrace(sig))
+    {
+    const char *modal = 0;
+    cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0023))
+      {
+      case cmPolicies::WARN:
+        modal = "should";
+      case cmPolicies::OLD:
+        break;
+      case cmPolicies::REQUIRED_ALWAYS:
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::NEW:
+        modal = "must";
+        messageType = cmake::FATAL_ERROR;
+      }
+
+      if(modal)
+        {
+        cmOStringStream e;
+        // If the sig is a keyword form and there is a conflict, the existing
+        // form must be the plain form.
+        const char *existingSig
+                    = (sig == cmTarget::KeywordTLLSignature ? "plain"
+                                                            : "keyword");
+        e << this->Makefile->GetPolicies()
+                              ->GetPolicyWarning(cmPolicies::CMP0023) << "\n"
+            "The " << existingSig << " signature for target_link_libraries "
+            "has already been used with the target \""
+          << this->Target->GetName() << "\".  All uses of "
+             "target_link_libraries with a target " << modal << " be either "
+             "all-keyword or all-plain.\n";
+        this->Target->GetTllSignatureTraces(e,
+                                          sig == cmTarget::KeywordTLLSignature
+                                            ? cmTarget::PlainTLLSignature
+                                            : cmTarget::KeywordTLLSignature);
+        this->Makefile->IssueMessage(messageType, e.str().c_str());
+        if(messageType == cmake::FATAL_ERROR)
+          {
+          return false;
+          }
+        }
+    }
+
   // Handle normal case first.
-  if(this->CurrentProcessingState != ProcessingLinkInterface)
+  if(this->CurrentProcessingState != ProcessingKeywordLinkInterface
+      && this->CurrentProcessingState != ProcessingPlainLinkInterface)
     {
     this->Makefile
       ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
-    if (this->CurrentProcessingState != ProcessingPublicInterface)
+    if (this->CurrentProcessingState != ProcessingKeywordPublicInterface
+        && this->CurrentProcessingState != ProcessingPlainPublicInterface)
       {
       if (this->Target->GetType() == cmTarget::STATIC_LIBRARY)
         {
@@ -275,8 +384,9 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
                   this->Target->GetDebugGeneratorExpressions(lib, llt) +
                   ">").c_str());
         }
-      // Not LINK_INTERFACE_LIBRARIES or LINK_PUBLIC, do not add to interface.
-      return;
+      // Not a 'public' or 'interface' library. Do not add to interface
+      // property.
+      return true;
       }
     }
 
@@ -289,7 +399,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
   if (policy22Status != cmPolicies::OLD
       && policy22Status != cmPolicies::WARN)
     {
-    return;
+    return true;
     }
 
   // Get the list of configurations considered to be DEBUG.
@@ -327,4 +437,5 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
         }
       }
     }
+  return true;
 }
diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h
index ca651d0..96cfe65 100644
--- a/Source/cmTargetLinkLibrariesCommand.h
+++ b/Source/cmTargetLinkLibrariesCommand.h
@@ -109,13 +109,25 @@ public:
       " INTERFACE_POSITION_INDEPENDENT_CODE: Sets POSITION_INDEPENDENT_CODE\n"
       "   or checked for consistency with existing value\n"
       "\n"
+      "  target_link_libraries(<target>\n"
+      "                      <PRIVATE|PUBLIC|INTERFACE> <lib> ...\n"
+      "                      [<PRIVATE|PUBLIC|INTERFACE> <lib> ... ] ...])\n"
+      "The PUBLIC, PRIVATE and INTERFACE keywords can be used to specify "
+      "both the link dependencies and the link interface in one command.  "
+      "Libraries and targets following PUBLIC are linked to, and are "
+      "made part of the link interface.  Libraries and targets "
+      "following PRIVATE are linked to, but are not made part of the "
+      "link interface.  Libraries following INTERFACE are appended "
+      "to the link interface and are not used for linking <target>."
+      "\n"
       "  target_link_libraries(<target> LINK_INTERFACE_LIBRARIES\n"
       "                        [[debug|optimized|general] <lib>] ...)\n"
       "The LINK_INTERFACE_LIBRARIES mode appends the libraries "
       "to the INTERFACE_LINK_LIBRARIES target property instead of using them "
       "for linking.  If policy CMP0022 is not NEW, then this mode also "
       "appends libraries to the LINK_INTERFACE_LIBRARIES and its "
-      "per-configuration equivalent.  "
+      "per-configuration equivalent.  This signature "
+      "is for compatibility only. Prefer the INTERFACE mode instead.  "
       "Libraries specified as \"debug\" are wrapped in a generator "
       "expression to correspond to debug builds.  If policy CMP0022 is not "
       "NEW, the libraries are also appended to the "
@@ -134,7 +146,9 @@ public:
       "                        [<LINK_PRIVATE|LINK_PUBLIC>\n"
       "                          [[debug|optimized|general] <lib>] ...])\n"
       "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both "
-      "the link dependencies and the link interface in one command.  "
+      "the link dependencies and the link interface in one command.  This "
+      "signature is for compatibility only. Prefer the PUBLIC or PRIVATE "
+      "keywords instead.  "
       "Libraries and targets following LINK_PUBLIC are linked to, and are "
       "made part of the INTERFACE_LINK_LIBRARIES.  If policy CMP0022 is not "
       "NEW, they are also made part of the LINK_INTERFACE_LIBRARIES.  "
@@ -180,14 +194,17 @@ private:
   cmTarget* Target;
   enum ProcessingState {
     ProcessingLinkLibraries,
-    ProcessingLinkInterface,
-    ProcessingPublicInterface,
-    ProcessingPrivateInterface
+    ProcessingPlainLinkInterface,
+    ProcessingKeywordLinkInterface,
+    ProcessingPlainPublicInterface,
+    ProcessingKeywordPublicInterface,
+    ProcessingPlainPrivateInterface,
+    ProcessingKeywordPrivateInterface
   };
 
   ProcessingState CurrentProcessingState;
 
-  void HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt);
+  bool HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt);
 };
 
 
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 2240539..06019e6 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -124,3 +124,9 @@ add_library(libConsumer empty.cpp)
 target_link_libraries(libConsumer debug depA)
 
 add_subdirectory(cmp0022)
+
+add_executable(newsignature1 newsignature1.cpp)
+target_link_libraries(newsignature1 PRIVATE depC INTERFACE depD PUBLIC depB PRIVATE subdirlib INTERFACE INTERFACE PUBLIC)
+
+assert_property(newsignature1 INTERFACE_LINK_LIBRARIES "depD;depB")
+assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib")
diff --git a/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
new file mode 100644
index 0000000..d1321a1
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
@@ -0,0 +1,19 @@
+
+#include "depB.h"
+#include "depC.h"
+#include "depIfaceOnly.h"
+
+#include "subdirlib.h"
+
+int main(int, char **)
+{
+  DepA a;
+  DepB b;
+  DepC c;
+
+  DepIfaceOnly iface_only;
+
+  SubDirLibObject sd;
+
+  return a.foo() + b.foo() + c.foo() + iface_only.foo() + sd.foo();
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 66ce3f1..12f68d7 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -115,3 +115,4 @@ if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
 endif()
 
 add_RunCMake_test(File_Generate)
+add_RunCMake_test(target_link_libraries)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-result.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt
new file mode 100644
index 0000000..d27686d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt
@@ -0,0 +1,16 @@
+CMake Error at CMP0023-NEW-2.cmake:11 \(target_link_libraries\):
+  Policy CMP0023 is not set: Plain and keyword target_link_libraries
+  signatures cannot be mixed.  Run "cmake --help-policy CMP0023" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The plain signature for target_link_libraries has already been used with
+  the target "foo".  All uses of target_link_libraries with a target must be
+  either all-keyword or all-plain.
+
+  The uses of the plain signature are here:
+
+   \* CMP0023-NEW-2.cmake:10 \(target_link_libraries\)
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2.cmake
new file mode 100644
index 0000000..f8b3546
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2.cmake
@@ -0,0 +1,11 @@
+
+project(CMP0022-WARN)
+
+cmake_policy(SET CMP0023 NEW)
+
+add_library(foo SHARED empty_vs6_1.cpp)
+add_library(bar SHARED empty_vs6_2.cpp)
+add_library(bat SHARED empty_vs6_3.cpp)
+
+target_link_libraries(foo bar)
+target_link_libraries(foo LINK_PRIVATE bat)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-result.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt
new file mode 100644
index 0000000..d7be0ff
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt
@@ -0,0 +1,16 @@
+CMake Error at CMP0023-NEW.cmake:11 \(target_link_libraries\):
+  Policy CMP0023 is not set: Plain and keyword target_link_libraries
+  signatures cannot be mixed.  Run "cmake --help-policy CMP0023" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The plain signature for target_link_libraries has already been used with
+  the target "foo".  All uses of target_link_libraries with a target must be
+  either all-keyword or all-plain.
+
+  The uses of the plain signature are here:
+
+   \* CMP0023-NEW.cmake:10 \(target_link_libraries\)
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-NEW.cmake
new file mode 100644
index 0000000..f0aa63f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW.cmake
@@ -0,0 +1,11 @@
+
+project(CMP0022-WARN)
+
+cmake_policy(SET CMP0023 NEW)
+
+add_library(foo SHARED empty_vs6_1.cpp)
+add_library(bar SHARED empty_vs6_2.cpp)
+add_library(bat SHARED empty_vs6_3.cpp)
+
+target_link_libraries(foo bar)
+target_link_libraries(foo PRIVATE bat)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt
new file mode 100644
index 0000000..5147861
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt
@@ -0,0 +1,16 @@
+CMake Warning \(dev\) at CMP0023-WARN-2.cmake:9 \(target_link_libraries\):
+  Policy CMP0023 is not set: Plain and keyword target_link_libraries
+  signatures cannot be mixed.  Run "cmake --help-policy CMP0023" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The plain signature for target_link_libraries has already been used with
+  the target "foo".  All uses of target_link_libraries with a target should
+  be either all-keyword or all-plain.
+
+  The uses of the plain signature are here:
+
+   \* CMP0023-WARN-2.cmake:8 \(target_link_libraries\)
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake
new file mode 100644
index 0000000..2e9cba8
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake
@@ -0,0 +1,9 @@
+
+project(CMP0022-WARN)
+
+add_library(foo SHARED empty_vs6_1.cpp)
+add_library(bar SHARED empty_vs6_2.cpp)
+add_library(bat SHARED empty_vs6_3.cpp)
+
+target_link_libraries(foo bar)
+target_link_libraries(foo LINK_PRIVATE bat)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt
new file mode 100644
index 0000000..a7474fa
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt
@@ -0,0 +1,16 @@
+CMake Warning \(dev\) at CMP0023-WARN.cmake:9 \(target_link_libraries\):
+  Policy CMP0023 is not set: Plain and keyword target_link_libraries
+  signatures cannot be mixed.  Run "cmake --help-policy CMP0023" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The plain signature for target_link_libraries has already been used with
+  the target "foo".  All uses of target_link_libraries with a target should
+  be either all-keyword or all-plain.
+
+  The uses of the plain signature are here:
+
+   \* CMP0023-WARN.cmake:8 \(target_link_libraries\)
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake
new file mode 100644
index 0000000..fcc8da0
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake
@@ -0,0 +1,9 @@
+
+project(CMP0022-WARN)
+
+add_library(foo SHARED empty_vs6_1.cpp)
+add_library(bar SHARED empty_vs6_2.cpp)
+add_library(bat SHARED empty_vs6_3.cpp)
+
+target_link_libraries(foo bar)
+target_link_libraries(foo PRIVATE bat)
diff --git a/Tests/RunCMake/target_link_libraries/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-result.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/MixedSignature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt
new file mode 100644
index 0000000..a0c66db
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at MixedSignature.cmake:6 \(target_link_libraries\):
+  The PUBLIC or PRIVATE option must appear as the second argument, just after
+  the target name.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature.cmake b/Tests/RunCMake/target_link_libraries/MixedSignature.cmake
new file mode 100644
index 0000000..fa70685
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/MixedSignature.cmake
@@ -0,0 +1,6 @@
+
+add_library(foo empty_vs6_1.cpp)
+add_library(bar empty_vs6_2.cpp)
+add_library(bat empty_vs6_3.cpp)
+
+target_link_libraries(foo LINK_PUBLIC bar PRIVATE bat)
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
new file mode 100644
index 0000000..f97022e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(CMP0023-WARN)
+run_cmake(CMP0023-NEW)
+run_cmake(CMP0023-WARN-2)
+run_cmake(CMP0023-NEW-2)
+run_cmake(MixedSignature)
+run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses)
diff --git a/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses-result.txt b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses.cmake b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses.cmake
new file mode 100644
index 0000000..e32891d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses.cmake
@@ -0,0 +1,9 @@
+
+enable_language(CXX)
+
+add_library(foo empty_vs6_1.cpp)
+add_library(bar empty_vs6_2.cpp)
+add_library(bat empty_vs6_3.cpp)
+
+target_link_libraries(foo LINK_PRIVATE bar)
+target_link_libraries(foo PRIVATE bat)
diff --git a/Tests/RunCMake/target_link_libraries/empty.cpp b/Tests/RunCMake/target_link_libraries/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/target_link_libraries/empty_vs6_1.cpp b/Tests/RunCMake/target_link_libraries/empty_vs6_1.cpp
new file mode 100644
index 0000000..7efedab
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/empty_vs6_1.cpp
@@ -0,0 +1 @@
+#include "empty.cpp"
diff --git a/Tests/RunCMake/target_link_libraries/empty_vs6_2.cpp b/Tests/RunCMake/target_link_libraries/empty_vs6_2.cpp
new file mode 100644
index 0000000..7efedab
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/empty_vs6_2.cpp
@@ -0,0 +1 @@
+#include "empty.cpp"
diff --git a/Tests/RunCMake/target_link_libraries/empty_vs6_3.cpp b/Tests/RunCMake/target_link_libraries/empty_vs6_3.cpp
new file mode 100644
index 0000000..7efedab
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/empty_vs6_3.cpp
@@ -0,0 +1 @@
+#include "empty.cpp"

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list