[Cmake-commits] CMake branch, next, updated. v3.0.1-5041-g250c4d4

Chuck Atkins chuck.atkins at kitware.com
Wed Aug 27 09:03:08 EDT 2014


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  250c4d44680295e0210dd78b20bb093f1771ffb6 (commit)
       via  2e08cf8e1d5116744cb9f8458f9374057ed585c9 (commit)
      from  2ca60fe320a698b12b43cfa9f1fca565f072a2f2 (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=250c4d44680295e0210dd78b20bb093f1771ffb6
commit 250c4d44680295e0210dd78b20bb093f1771ffb6
Merge: 2ca60fe 2e08cf8
Author:     Chuck Atkins <chuck.atkins at kitware.com>
AuthorDate: Wed Aug 27 09:03:07 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Aug 27 09:03:07 2014 -0400

    Merge topic 'add-find-root-system_only-mode' into next
    
    2e08cf8e Add a new SYSTEM_ONLY mode for CMAKE_FIND_ROOT_PATH.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2e08cf8e1d5116744cb9f8458f9374057ed585c9
commit 2e08cf8e1d5116744cb9f8458f9374057ed585c9
Author:     Chuck Atkins <chuck.atkins at kitware.com>
AuthorDate: Wed Aug 20 10:32:30 2014 -0400
Commit:     Chuck Atkins <chuck.atkins at kitware.com>
CommitDate: Wed Aug 20 10:32:30 2014 -0400

    Add a new SYSTEM_ONLY mode for CMAKE_FIND_ROOT_PATH.
    
    This new SYSTEM_ONLY mode allows for the intrinsic system paths
    used for find_* commands to get re-rooted from the CMAKE_FIND_ROOT_PATH
    variable while maintaining original user-specified paths.  The intent is
    for this to be the preferred mode for cross compiling.  It allows for a
    a restricted default search within a desired system root but also
    lets the user specify explicit search paths anythere on the host system.

diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt
index 5889e90..2d97e80 100644
--- a/Help/command/FIND_XXX.txt
+++ b/Help/command/FIND_XXX.txt
@@ -21,6 +21,7 @@ The general signature is:
              [NO_SYSTEM_ENVIRONMENT_PATH]
              [NO_CMAKE_SYSTEM_PATH]
              [CMAKE_FIND_ROOT_PATH_BOTH |
+              CMAKE_FIND_ROOT_PATH_SYSTEM_ONLY |
               ONLY_CMAKE_FIND_ROOT_PATH |
               NO_CMAKE_FIND_ROOT_PATH]
             )
diff --git a/Help/command/FIND_XXX_ROOT.txt b/Help/command/FIND_XXX_ROOT.txt
index b5cab68..a4a9a32 100644
--- a/Help/command/FIND_XXX_ROOT.txt
+++ b/Help/command/FIND_XXX_ROOT.txt
@@ -21,3 +21,5 @@ the search order will be as described above.  If
 NO_CMAKE_FIND_ROOT_PATH is used then :variable:`CMAKE_FIND_ROOT_PATH` will not be
 used.  If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted
 directories and directories below :variable:`CMAKE_STAGING_PREFIX` will be searched.
+If CMAKE_FIND_ROOT_PATH_SYSTEM_ONLY is used then the paths described above
+wll be re-rooted and searched followed by the original user-spefied paths.
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index 190d05c..3a1e17f 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -72,6 +72,7 @@ The complete Config mode command signature is::
                [NO_CMAKE_SYSTEM_PATH]
                [NO_CMAKE_SYSTEM_PACKAGE_REGISTRY]
                [CMAKE_FIND_ROOT_PATH_BOTH |
+                CMAKE_FIND_ROOT_PATH_SYSTEM_ONLY |
                 ONLY_CMAKE_FIND_ROOT_PATH |
                 NO_CMAKE_FIND_ROOT_PATH])
 
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index f36a43c..3be5e86 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -111,9 +111,9 @@ as:
   set(CMAKE_CXX_COMPILER /home/devel/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++)
 
   set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY SYSTEM_ONLY)
+  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE SYSTEM_ONLY)
+  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE SYSTEM_ONLY)
 
 The :variable:`CMAKE_SYSTEM_NAME` is the CMake-identifier of the target platform
 to build for.
diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt
index ab65e09..e2eb84e 100644
--- a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt
+++ b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt
@@ -4,5 +4,7 @@ This variable controls whether the :variable:`CMAKE_FIND_ROOT_PATH` and
 If set to ``ONLY``, then only the roots in :variable:`CMAKE_FIND_ROOT_PATH`
 will be searched. If set to ``NEVER``, then the roots in
 :variable:`CMAKE_FIND_ROOT_PATH` will be ignored and only the host system
-root will be used. If set to ``BOTH``, then the host system paths and the
+root will be used. If set to ``SYSTEM_ONLY``, then the host system paths
+will be re-rooted and searched followed by the original user specified
+paths. If set to ``BOTH``, then the host system paths and the
 paths in :variable:`CMAKE_FIND_ROOT_PATH` will be searched.
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index e4e819a..caf9b10 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -376,13 +376,15 @@ void cmFindBase::AddCMakeSystemVariablePath()
 //----------------------------------------------------------------------------
 void cmFindBase::AddUserHintsPath()
 {
-  this->AddPathsInternal(this->UserHints, CMakePath);
+  this->AddPathsInternal(this->UserHints, CMakePath,
+                         this->FindRootPathMode != RootPathModeSystemOnly);
 }
 
 //----------------------------------------------------------------------------
 void cmFindBase::AddUserGuessPath()
 {
-  this->AddPathsInternal(this->UserPaths, CMakePath);
+  this->AddPathsInternal(this->UserPaths, CMakePath,
+                         this->FindRootPathMode != RootPathModeSystemOnly);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 10241f2..0ef2904 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -64,6 +64,10 @@ void cmFindCommon::SelectDefaultRootPathMode()
     {
     this->FindRootPathMode = RootPathModeBoth;
     }
+  else if (rootPathMode=="SYSTEM_ONLY")
+    {
+    this->FindRootPathMode = RootPathModeSystemOnly;
+    }
 }
 
 //----------------------------------------------------------------------------
@@ -125,6 +129,14 @@ void cmFindCommon::SelectDefaultMacMode()
 //----------------------------------------------------------------------------
 void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
 {
+  std::vector<bool> pathsRerootable(paths.size(), true);
+  this->RerootPaths(paths, pathsRerootable);
+}
+
+//----------------------------------------------------------------------------
+void cmFindCommon::RerootPaths(std::vector<std::string>& paths,
+                               const std::vector<bool> &pathsRerootable)
+{
 #if 0
   for(std::vector<std::string>::const_iterator i = paths.begin();
       i != paths.end(); ++i)
@@ -138,12 +150,12 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
     {
     return;
     }
-  const char* sysroot =
-    this->Makefile->GetDefinition("CMAKE_SYSROOT");
   const char* rootPath =
     this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH");
-  const bool noSysroot = !sysroot || !*sysroot;
+  const char* sysroot =
+    this->Makefile->GetDefinition("CMAKE_SYSROOT");
   const bool noRootPath = !rootPath || !*rootPath;
+  const bool noSysroot = !sysroot || !*sysroot;
   if(noSysroot && noRootPath)
     {
     return;
@@ -175,16 +187,19 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
   for(std::vector<std::string>::const_iterator ri = roots.begin();
       ri != roots.end(); ++ri)
     {
-    for(std::vector<std::string>::const_iterator ui = unrootedPaths.begin();
-        ui != unrootedPaths.end(); ++ui)
+    std::vector<std::string>::const_iterator ui;
+    std::vector<bool>::const_iterator rri;
+    for(ui = unrootedPaths.begin(), rri = pathsRerootable.begin();
+        ui != unrootedPaths.end(); ++ui, ++rri)
       {
       // Place the unrooted path under the current root if it is not
       // already inside.  Skip the unrooted path if it is relative to
       // a user home directory or is empty.
       std::string rootedDir;
-      if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str())
-          || (stagePrefix
-            && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix)))
+      if(!*rri
+         || cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str())
+         || (stagePrefix
+             && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix)))
         {
         rootedDir = *ui;
         }
@@ -303,6 +318,10 @@ bool cmFindCommon::CheckCommonArgument(std::string const& arg)
     {
     this->FindRootPathMode = RootPathModeBoth;
     }
+  else if(arg == "CMAKE_FIND_ROOT_PATH_SYSTEM_ONLY")
+    {
+    this->FindRootPathMode = RootPathModeSystemOnly;
+    }
   else
     {
     // The argument is not one of the above.
@@ -401,18 +420,18 @@ void cmFindCommon::AddEnvPath(const char* variable)
 
 //----------------------------------------------------------------------------
 void cmFindCommon::AddPathsInternal(std::vector<std::string> const& in_paths,
-                                    PathType pathType)
+                                    PathType pathType, bool reRootable)
 {
   for(std::vector<std::string>::const_iterator i = in_paths.begin();
       i != in_paths.end(); ++i)
     {
-    this->AddPathInternal(*i, pathType);
+    this->AddPathInternal(*i, pathType, reRootable);
     }
 }
 
 //----------------------------------------------------------------------------
 void cmFindCommon::AddPathInternal(std::string const& in_path,
-                                   PathType pathType)
+                                   PathType pathType, bool reRootable)
 {
   if(in_path.empty())
     {
@@ -434,20 +453,19 @@ void cmFindCommon::AddPathInternal(std::string const& in_path,
   if(this->SearchPathsEmitted.insert(fullPath).second)
     {
     this->SearchPaths.push_back(fullPath);
+    this->SearchPathsRerootable.push_back(reRootable);
     }
 }
 
 //----------------------------------------------------------------------------
 void cmFindCommon::ComputeFinalPaths()
 {
-  std::vector<std::string>& paths = this->SearchPaths;
-
   // Expand list of paths inside all search roots.
-  this->RerootPaths(paths);
+  this->RerootPaths(this->SearchPaths, this->SearchPathsRerootable);
 
   // Add a trailing slash to all paths to aid the search process.
-  for(std::vector<std::string>::iterator i = paths.begin();
-      i != paths.end(); ++i)
+  for(std::vector<std::string>::iterator i = this->SearchPaths.begin();
+      i != this->SearchPaths.end(); ++i)
     {
     std::string& p = *i;
     if(!p.empty() && p[p.size()-1] != '/')
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 5a905cd..9ae0e6a 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -32,12 +32,15 @@ protected:
 
   enum RootPathMode { RootPathModeBoth,
                       RootPathModeOnlyRootPath,
-                      RootPathModeNoRootPath };
+                      RootPathModeNoRootPath,
+                      RootPathModeSystemOnly };
 
   enum PathType { FullPath, CMakePath, EnvPath };
 
   /** Place a set of search paths under the search roots.  */
   void RerootPaths(std::vector<std::string>& paths);
+  void RerootPaths(std::vector<std::string>& paths,
+                   const std::vector<bool> &pathsRerootable);
 
   /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_path variables.  */
   void GetIgnoredPaths(std::vector<std::string>& ignore);
@@ -66,8 +69,9 @@ protected:
   void AddCMakePath(const std::string& variable);
   void AddEnvPath(const char* variable);
   void AddPathsInternal(std::vector<std::string> const& in_paths,
-                        PathType pathType);
-  void AddPathInternal(std::string const& in_path, PathType pathType);
+                        PathType pathType, bool reRootable = true);
+  void AddPathInternal(std::string const& in_path, PathType pathType,
+                       bool reRootable = true);
 
   void SetMakefile(cmMakefile* makefile);
 
@@ -81,6 +85,7 @@ protected:
   std::vector<std::string> UserPaths;
   std::vector<std::string> UserHints;
   std::vector<std::string> SearchPaths;
+  std::vector<bool> SearchPathsRerootable;
   std::set<std::string> SearchPathsEmitted;
 
   bool SearchFrameworkFirst;
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 55a61f5..e07927d 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1442,14 +1442,16 @@ void cmFindPackageCommand::AddPrefixesCMakeSystemVariable()
 void cmFindPackageCommand::AddPrefixesUserGuess()
 {
   // Add guesses specified by the caller.
-  this->AddPathsInternal(this->UserPaths, CMakePath);
+  this->AddPathsInternal(this->UserPaths, CMakePath,
+                         this->FindRootPathMode != RootPathModeSystemOnly);
 }
 
 //----------------------------------------------------------------------------
 void cmFindPackageCommand::AddPrefixesUserHints()
 {
   // Add hints specified by the caller.
-  this->AddPathsInternal(this->UserHints, CMakePath);
+  this->AddPathsInternal(this->UserHints, CMakePath,
+                         this->FindRootPathMode != RootPathModeSystemOnly);
 }
 
 //----------------------------------------------------------------------------

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

Summary of changes:
 Help/command/FIND_XXX.txt                       |    1 +
 Help/command/FIND_XXX_ROOT.txt                  |    2 +
 Help/command/find_package.rst                   |    1 +
 Help/manual/cmake-toolchains.7.rst              |    6 +--
 Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt |    4 +-
 Source/cmFindBase.cxx                           |    6 ++-
 Source/cmFindCommon.cxx                         |   50 +++++++++++++++--------
 Source/cmFindCommon.h                           |   11 +++--
 Source/cmFindPackageCommand.cxx                 |    6 ++-
 9 files changed, 60 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list