[Cmake-commits] CMake branch, next, updated. v2.8.10.2-1235-g687834d

Brad King brad.king at kitware.com
Thu Dec 6 10:32:11 EST 2012


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  687834d31aab938a884e85885e34cdd9d5a506b7 (commit)
       via  1864a188191bc3ef73460531f0353a9430e6dac6 (commit)
       via  2a0a5c78caec1cac70e801ad2dc55bd12a5b6789 (commit)
      from  8373fab93a51952fadd8d965905ce0eabf22f2a4 (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=687834d31aab938a884e85885e34cdd9d5a506b7
commit 687834d31aab938a884e85885e34cdd9d5a506b7
Merge: 8373fab 1864a18
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Dec 6 10:30:02 2012 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Dec 6 10:30:02 2012 -0500

    Merge topic 'add-INTERFACE_LINK_LIBRARIES-property' into next
    
    1864a18 Merge branch 'skip-variable-re-expansion' into add-INTERFACE_LINK_LIBRARIES-property
    2a0a5c7 Add policy CMP0021 to skip include/link variable re-expansion


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1864a188191bc3ef73460531f0353a9430e6dac6
commit 1864a188191bc3ef73460531f0353a9430e6dac6
Merge: 6a39219 2a0a5c7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Dec 6 10:20:17 2012 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Dec 6 10:20:17 2012 -0500

    Merge branch 'skip-variable-re-expansion' into add-INTERFACE_LINK_LIBRARIES-property
    
    Conflicts:
    	Source/cmPolicies.cxx
    	Source/cmPolicies.h

diff --cc Source/cmPolicies.cxx
index 304904a,c16acc8..6bfd807
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@@ -492,52 -492,22 +492,69 @@@ cmPolicies::cmPolicies(
      "honor the POSITION_INDEPENDENT_CODE target property.",
      2,8,9,0, cmPolicies::WARN);
  
 +    this->DefinePolicy(
 +    CMP0019, "CMP0019",
 +    "Use INTERFACE_LINK_LIBRARIES instead of LINK_INTERFACE_LIBRARIES.",
 +    "A CMake shared library target (or an executable with the "
 +    "ENABLE_EXPORTS property) may be given a \"link interface\" "
 +    "determining the libraries that must be linked by its dependents.  "
 +    "CMake 2.8.10 and lower used the LINK_INTERFACE_LIBRARIES and "
 +    "LINK_INTERFACE_LIBRARIES_<CONFIG> target properties "
 +    "to determine the link interface.  "
 +    "CMake 2.8.11 and higher prefer the single "
 +    "INTERFACE_LINK_LIBRARIES target property "
 +    "to determine the link interface.  "
 +    "The new property supports generator expressions "
 +    "to specify configuration-specific link libraries."
 +    "\n"
 +    "This policy is not considered when loading IMPORTED targets.  "
 +    "However, it does affect how the export() and install(EXPORT) "
 +    "commands generate imported targets for use in dependent projects.  "
 +    "\n"
 +    "The OLD behavior for this policy is to ignore the new "
 +    "INTERFACE_LINK_LIBRARIES property and use the old "
 +    "LINK_INTERFACE_LIBRARIES(_<CONFIG>) properties to determine the "
 +    "link interface.  "
 +    "Targets named after LINK_PUBLIC in target_link_libraries will "
 +    "populate the old properties and the new.  "
 +    "The export() and install(EXPORT) commands will generate only the "
 +    "IMPORTED_LINK_INTERFACE_LIBRARIES(_<CONFIG>) properties on a "
 +    "target to be imported into other projects, and not "
 +    "INTERFACE_LINK_LIBRARIES.  "
 +    "\n"
 +    "The NEW behavior for this policy is to ignore the old "
 +    "LINK_INTERFACE_LIBRARIES(_<CONFIG>) properties and use the new "
 +    "INTERFACE_LINK_LIBRARIES property to determine the link interface.  "
 +    "Targets named after LINK_PUBLIC in target_link_libraries will "
 +    "populate the new property and not the old.  "
 +    "The export() and install(EXPORT) commands will generate the new "
 +    "INTERFACE_LINK_LIBRARIES property on a target to be imported "
 +    "into other projects.  "
 +    "They will generate IMPORTED_LINK_INTERFACE_LIBRARIES(_<CONFIG>) "
 +    "properties only if LINK_INTERFACE_LIBRARIES(_<CONFIG>) have been "
 +    "set explicitly on the target to be exported."
 +    "\n"
 +    "The setting for this policy used to determine the link interface is "
 +    "that in effect when the target is created by an add_library or "
 +    "add_executable command.",
 +    2,8,11,0, cmPolicies::WARN);
++
+   this->DefinePolicy(
+     CMP0021, "CMP0021",
+     "Do not re-expand variables in include and link information.",
+     "CMake 2.8.10 and lower re-evaluated values given to the "
+     "include_directories, link_directories, and link_libraries "
+     "commands to expand any leftover variable references at the "
+     "end of the configuration step.  "
+     "This was for strict compatibility with VERY early CMake versions "
+     "because all variable references are now normally evaluated during "
+     "CMake language processing.  "
+     "CMake 2.8.11 and higher prefer to skip the extra evaluation."
+     "\n"
+     "The OLD behavior for this policy is to re-evaluate the values "
+     "for strict compatibility.  "
+     "The NEW behavior for this policy is to leave the values untouched.",
+     2,8,11,0, cmPolicies::WARN);
  }
  
  cmPolicies::~cmPolicies()
diff --cc Source/cmPolicies.h
index b6b8e39,9180b26..cdd4856
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@@ -68,7 -68,9 +68,9 @@@ public
      CMP0018, ///< Ignore language flags for shared libs, and adhere to
      /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C}
      /// instead.
 -    CMP0019, ///< Reserved.
 +    CMP0019, ///< Use new-style INTERFACE_LINK_LIBRARIES
+     CMP0020, ///< Reserved.
+     CMP0021, ///< No variable re-expansion in include and link info
  
      /** \brief Always the last entry.
       *

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2a0a5c78caec1cac70e801ad2dc55bd12a5b6789
commit 2a0a5c78caec1cac70e801ad2dc55bd12a5b6789
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Dec 6 09:59:18 2012 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Dec 6 10:19:10 2012 -0500

    Add policy CMP0021 to skip include/link variable re-expansion
    
    Historically CMake has always expanded ${} variable references in the
    values given to include_directories(), link_directories(), and
    link_libraries().  This has been unnecessary since general ${}
    evaluation syntax was added to the language a LONG time ago, but has
    remained for compatibility with VERY early CMake versions.
    
    For a long time the re-expansion was a lightweight operation because it
    was only processed once at the directory level and the fast-path of
    cmMakefile::ExpandVariablesInString was usually taken because values did
    not have any '$' in them.  Then commit d899eb71 (Call
    ExpandVariablesInString for each target's INCLUDE_DIRECTORIES,
    2012-02-22) made the operation a bit heavier because the expansion is
    now needed on a per-target basis.  In the future we will support
    generator expressions in INCLUDE_DIRECTORIES with $<> syntax, so the
    fast-path in cmMakefile::ExpandVariablesInString will no longer be taken
    and re-expansion will be very expensive.
    
    Add policy CMP0021 to skip the re-expansion altogether in NEW behavior.
    (Skip and reserve CMP0019 and CMP0020 for other policies in development
    elsewhere.)  In OLD behavior perform the expansion but improve the
    fast-path heuristic to match ${} but not $<>.  If the policy is not set
    then warn if expansion actually does anything.  We expect this to be
    encountered very rarely in practice.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 8498d72..2552689 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -814,7 +814,7 @@ bool cmMakefile::NeedBackwardsCompatibility(unsigned int major,
 void cmMakefile::FinalPass()
 {
   // do all the variable expansions here
-  this->ExpandVariables();
+  this->ExpandVariablesCMP0021();
 
   // give all the commands a chance to do something
   // after the file has been parsed before generation
@@ -2122,21 +2122,33 @@ void cmMakefile::AddExtraDirectory(const char* dir)
   this->AuxSourceDirectories.push_back(dir);
 }
 
+static bool mightExpandVariablesCMP0021(const char* s)
+{
+  return s && *s && strstr(s,"${") && strchr(s,'}');
+}
 
-// expand CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
-// include and library directories.
-
-void cmMakefile::ExpandVariables()
+void cmMakefile::ExpandVariablesCMP0021()
 {
-  // Now expand variables in the include and link strings
+  // Drop this ancient compatibility behavior with a policy.
+  cmPolicies::PolicyStatus pol = this->GetPolicyStatus(cmPolicies::CMP0021);
+  if(pol != cmPolicies::OLD && pol != cmPolicies::WARN)
+    {
+    return;
+    }
+  cmOStringStream w;
 
-  // May not be necessary anymore... But may need a policy for strict
-  // backwards compatibility
   const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
-  if (includeDirs)
+  if(mightExpandVariablesCMP0021(includeDirs))
     {
     std::string dirs = includeDirs;
     this->ExpandVariablesInString(dirs, true, true);
+    if(pol == cmPolicies::WARN && dirs != includeDirs)
+      {
+      w << "Evaluated directory INCLUDE_DIRECTORIES\n"
+        << "  " << includeDirs << "\n"
+        << "as\n"
+        << "  " << dirs << "\n";
+      }
     this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
     }
 
@@ -2146,10 +2158,17 @@ void cmMakefile::ExpandVariables()
     {
     cmTarget &t = l->second;
     includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
-    if (includeDirs)
+    if(mightExpandVariablesCMP0021(includeDirs))
       {
       std::string dirs = includeDirs;
       this->ExpandVariablesInString(dirs, true, true);
+      if(pol == cmPolicies::WARN && dirs != includeDirs)
+        {
+        w << "Evaluated target " << t.GetName() << " INCLUDE_DIRECTORIES\n"
+          << "  " << includeDirs << "\n"
+          << "as\n"
+          << "  " << dirs << "\n";
+        }
       t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
       }
     }
@@ -2157,13 +2176,45 @@ void cmMakefile::ExpandVariables()
   for(std::vector<std::string>::iterator d = this->LinkDirectories.begin();
       d != this->LinkDirectories.end(); ++d)
     {
-    this->ExpandVariablesInString(*d, true, true);
+    if(mightExpandVariablesCMP0021(d->c_str()))
+      {
+      std::string orig = *d;
+      this->ExpandVariablesInString(*d, true, true);
+      if(pol == cmPolicies::WARN && *d != orig)
+        {
+        w << "Evaluated link directory\n"
+          << "  " << orig << "\n"
+          << "as\n"
+          << "  " << *d << "\n";
+        }
+      }
     }
   for(cmTarget::LinkLibraryVectorType::iterator l =
         this->LinkLibraries.begin();
       l != this->LinkLibraries.end(); ++l)
     {
-    this->ExpandVariablesInString(l->first, true, true);
+    if(mightExpandVariablesCMP0021(l->first.c_str()))
+      {
+      std::string orig = l->first;
+      this->ExpandVariablesInString(l->first, true, true);
+      if(pol == cmPolicies::WARN && l->first != orig)
+        {
+        w << "Evaluated link library\n"
+          << "  " << orig << "\n"
+          << "as\n"
+          << "  " << l->first << "\n";
+        }
+      }
+    }
+
+  if(!w.str().empty())
+    {
+    cmOStringStream m;
+    m << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0021)
+      << "\n"
+      << "The following variable evaluations were encountered:\n"
+      << w.str();
+    this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
     }
 }
 
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 70cfe54..96a3d59 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -693,7 +693,7 @@ public:
   /**
    * Expand variables in the makefiles ivars such as link directories etc
    */
-  void ExpandVariables();
+  void ExpandVariablesCMP0021();
 
   /**
    * Replace variables and #cmakedefine lines in the given string.
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 6aef502..c16acc8 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -491,6 +491,23 @@ cmPolicies::cmPolicies()
     "CMAKE_SHARED_LIBRARY_<Lang>_FLAGS whether it is modified or not and "
     "honor the POSITION_INDEPENDENT_CODE target property.",
     2,8,9,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0021, "CMP0021",
+    "Do not re-expand variables in include and link information.",
+    "CMake 2.8.10 and lower re-evaluated values given to the "
+    "include_directories, link_directories, and link_libraries "
+    "commands to expand any leftover variable references at the "
+    "end of the configuration step.  "
+    "This was for strict compatibility with VERY early CMake versions "
+    "because all variable references are now normally evaluated during "
+    "CMake language processing.  "
+    "CMake 2.8.11 and higher prefer to skip the extra evaluation."
+    "\n"
+    "The OLD behavior for this policy is to re-evaluate the values "
+    "for strict compatibility.  "
+    "The NEW behavior for this policy is to leave the values untouched.",
+    2,8,11,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 6932565..9180b26 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -68,6 +68,9 @@ public:
     CMP0018, ///< Ignore language flags for shared libs, and adhere to
     /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C}
     /// instead.
+    CMP0019, ///< Reserved.
+    CMP0020, ///< Reserved.
+    CMP0021, ///< No variable re-expansion in include and link info
 
     /** \brief Always the last entry.
      *
diff --git a/Tests/RunCMake/CMP0021/CMP0021-NEW.cmake b/Tests/RunCMake/CMP0021/CMP0021-NEW.cmake
new file mode 100644
index 0000000..e2d6546
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/CMP0021-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0021 NEW)
+include(CMP0021-code.cmake)
diff --git a/Tests/RunCMake/CMP0021/CMP0021-OLD.cmake b/Tests/RunCMake/CMP0021/CMP0021-OLD.cmake
new file mode 100644
index 0000000..67eca3f
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/CMP0021-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0021 OLD)
+include(CMP0021-code.cmake)
diff --git a/Tests/RunCMake/CMP0021/CMP0021-WARN-stderr.txt b/Tests/RunCMake/CMP0021/CMP0021-WARN-stderr.txt
new file mode 100644
index 0000000..b95deb9
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/CMP0021-WARN-stderr.txt
@@ -0,0 +1,40 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+  Policy CMP0021 is not set: Do not re-expand variables in include and link
+  information.  Run "cmake --help-policy CMP0021" for policy details.  Use
+  the cmake_policy command to set the policy and suppress this warning.
+
+  The following variable evaluations were encountered:
+
+  Evaluated directory INCLUDE_DIRECTORIES
+
+    /usr/include/\${VAR_INCLUDE};/usr/include/normal
+
+  as
+
+    /usr/include/VAL_INCLUDE;/usr/include/normal
+
+  Evaluated target some_target INCLUDE_DIRECTORIES
+
+    /usr/include/\${VAR_INCLUDE};/usr/include/normal
+
+  as
+
+    /usr/include/VAL_INCLUDE;/usr/include/normal
+
+  Evaluated link directory
+
+    /usr/lib/\${VAR_LINK_DIRS}
+
+  as
+
+    /usr/lib/VAL_LINK_DIRS
+
+  Evaluated link library
+
+    \${VAR_LINK_LIBS}
+
+  as
+
+    VAL_LINK_LIBS
+
+This warning is for project developers.  Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CMP0021/CMP0021-WARN.cmake b/Tests/RunCMake/CMP0021/CMP0021-WARN.cmake
new file mode 100644
index 0000000..941e7d1
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/CMP0021-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0021-code.cmake)
diff --git a/Tests/RunCMake/CMP0021/CMP0021-code.cmake b/Tests/RunCMake/CMP0021/CMP0021-code.cmake
new file mode 100644
index 0000000..26c0e5b
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/CMP0021-code.cmake
@@ -0,0 +1,9 @@
+set(VAR_INCLUDE "VAL_INCLUDE")
+set(VAR_LINK_DIRS "VAL_LINK_DIRS")
+set(VAR_LINK_LIBS "VAL_LINK_LIBS")
+add_custom_target(some_target)
+include_directories("/usr/include/\${VAR_INCLUDE}" /usr/include/normal)
+link_directories("/usr/lib/\${VAR_LINK_DIRS}"  /usr/lib/normal)
+link_libraries("\${VAR_LINK_LIBS}" normal)
+add_custom_target(other_target)
+set_property(TARGET other_target PROPERTY INCLUDE_DIRECTORIES "")
diff --git a/Tests/RunCMake/CMP0021/CMakeLists.txt b/Tests/RunCMake/CMP0021/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/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/CMP0021/RunCMakeTest.cmake b/Tests/RunCMake/CMP0021/RunCMakeTest.cmake
new file mode 100644
index 0000000..d777782
--- /dev/null
+++ b/Tests/RunCMake/CMP0021/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0021-WARN)
+run_cmake(CMP0021-OLD)
+run_cmake(CMP0021-NEW)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 722d9c3..26719a1 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -45,6 +45,7 @@ macro(add_RunCMake_test test)
     )
 endmacro()
 
+add_RunCMake_test(CMP0021)
 add_RunCMake_test(GeneratorExpression)
 add_RunCMake_test(TargetPropertyGeneratorExpressions)
 add_RunCMake_test(Languages)

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

Summary of changes:
 Source/cmMakefile.cxx                              |   75 ++++++++++++++++---
 Source/cmMakefile.h                                |    2 +-
 Source/cmPolicies.cxx                              |   17 +++++
 Source/cmPolicies.h                                |    2 +
 Tests/RunCMake/CMP0021/CMP0021-NEW.cmake           |    2 +
 Tests/RunCMake/CMP0021/CMP0021-OLD.cmake           |    2 +
 Tests/RunCMake/CMP0021/CMP0021-WARN-stderr.txt     |   40 +++++++++++
 Tests/RunCMake/CMP0021/CMP0021-WARN.cmake          |    1 +
 Tests/RunCMake/CMP0021/CMP0021-code.cmake          |    9 +++
 .../CMakeLists.txt                                 |    0
 Tests/RunCMake/CMP0021/RunCMakeTest.cmake          |    5 ++
 Tests/RunCMake/CMakeLists.txt                      |    1 +
 12 files changed, 143 insertions(+), 13 deletions(-)
 create mode 100644 Tests/RunCMake/CMP0021/CMP0021-NEW.cmake
 create mode 100644 Tests/RunCMake/CMP0021/CMP0021-OLD.cmake
 create mode 100644 Tests/RunCMake/CMP0021/CMP0021-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/CMP0021/CMP0021-WARN.cmake
 create mode 100644 Tests/RunCMake/CMP0021/CMP0021-code.cmake
 copy Tests/RunCMake/{GeneratorExpression => CMP0021}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/CMP0021/RunCMakeTest.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list