[Cmake-commits] CMake branch, next, updated. v3.2.0-rc1-412-g11fb11a

Brad King brad.king at kitware.com
Wed Feb 18 10:55:55 EST 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  11fb11ab1de4f238e89b7836a54b97a10291b4a1 (commit)
       via  7dea738b73f6427e8af0093b2e9b185a8d90ead6 (commit)
       via  4fb9e847c0c757ff6e1ee430bbb9fc2b6b4e2ae6 (commit)
      from  f6651af5d1ea6ba9699a66183285528be2723ac6 (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=11fb11ab1de4f238e89b7836a54b97a10291b4a1
commit 11fb11ab1de4f238e89b7836a54b97a10291b4a1
Merge: f6651af 7dea738
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Feb 18 10:55:53 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Feb 18 10:55:53 2015 -0500

    Merge topic 'find-command-prefix-from-PATH' into next
    
    7dea738b Teach find_(library|file|path) to get prefixes from PATH (#15370)
    4fb9e847 CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7dea738b73f6427e8af0093b2e9b185a8d90ead6
commit 7dea738b73f6427e8af0093b2e9b185a8d90ead6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Feb 18 10:54:45 2015 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Feb 18 10:54:45 2015 -0500

    Teach find_(library|file|path) to get prefixes from PATH (#15370)

diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt
index 5889e90..9358329 100644
--- a/Help/command/FIND_XXX.txt
+++ b/Help/command/FIND_XXX.txt
@@ -53,6 +53,10 @@ If NO_DEFAULT_PATH is not specified, the search process is as follows:
 .. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
    <prefix>/|XXX_SUBDIR| for each <prefix> in CMAKE_PREFIX_PATH
 
+.. |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR| replace::
+   <prefix>/|XXX_SUBDIR| for each <prefix>/[s]bin in PATH, and
+   <entry>/|XXX_SUBDIR| for other entries in PATH
+
 .. |CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR| replace::
    <prefix>/|XXX_SUBDIR| for each <prefix> in CMAKE_SYSTEM_PREFIX_PATH
 
diff --git a/Help/command/find_file.rst b/Help/command/find_file.rst
index db7e151..be309a5 100644
--- a/Help/command/find_file.rst
+++ b/Help/command/find_file.rst
@@ -13,7 +13,10 @@ find_file
 .. |CMAKE_XXX_PATH| replace:: CMAKE_INCLUDE_PATH
 .. |CMAKE_XXX_MAC_PATH| replace:: CMAKE_FRAMEWORK_PATH
 
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: PATH and INCLUDE
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in INCLUDE,
+   <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and
+   |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|,
+   and the directories in PATH itself.
 
 .. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
    <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and
diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst
index 91342ba..09df688 100644
--- a/Help/command/find_library.rst
+++ b/Help/command/find_library.rst
@@ -13,7 +13,10 @@ find_library
 .. |CMAKE_XXX_PATH| replace:: CMAKE_LIBRARY_PATH
 .. |CMAKE_XXX_MAC_PATH| replace:: CMAKE_FRAMEWORK_PATH
 
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: PATH and LIB
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in LIB,
+   <prefix>/lib/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and
+   |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|,
+   and the directories in PATH itself.
 
 .. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
    <prefix>/lib/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and
diff --git a/Help/command/find_path.rst b/Help/command/find_path.rst
index 95d49e7..b5a6e37 100644
--- a/Help/command/find_path.rst
+++ b/Help/command/find_path.rst
@@ -13,7 +13,10 @@ find_path
 .. |CMAKE_XXX_PATH| replace:: CMAKE_INCLUDE_PATH
 .. |CMAKE_XXX_MAC_PATH| replace:: CMAKE_FRAMEWORK_PATH
 
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: PATH and INCLUDE
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in INCLUDE,
+   <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and
+   |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|,
+   and the directories in PATH itself.
 
 .. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
    <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and
diff --git a/Help/release/dev/find-command-prefix-from-PATH.rst b/Help/release/dev/find-command-prefix-from-PATH.rst
new file mode 100644
index 0000000..f9aae2a
--- /dev/null
+++ b/Help/release/dev/find-command-prefix-from-PATH.rst
@@ -0,0 +1,6 @@
+find-command-prefix-from-PATH
+-----------------------------
+
+* The :command:`find_library`, :command:`find_path`, and :command:`find_file`
+  commands now search in installation prefixes derived from the ``PATH``
+  environment variable.
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 6e55533..4336e1c 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -275,6 +275,7 @@ void cmFindBase::FillSystemEnvironmentPath()
   if(!this->EnvironmentPath.empty())
     {
     paths.AddEnvPath(this->EnvironmentPath);
+    paths.AddEnvPrefixPath("PATH", true);
     }
   // Add PATH
   paths.AddEnvPath("PATH");
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
index 861dbf1..1e777ab 100644
--- a/Source/cmSearchPath.cxx
+++ b/Source/cmSearchPath.cxx
@@ -136,10 +136,30 @@ void cmSearchPath::AddCMakePrefixPath(const std::string& variable)
 }
 
 //----------------------------------------------------------------------------
-void cmSearchPath::AddEnvPrefixPath(const std::string& variable)
+static std::string cmSearchPathStripBin(std::string const& s)
+{
+  // If the path is a PREFIX/bin case then add its parent instead.
+  if((cmHasLiteralSuffix(s, "/bin")) ||
+     (cmHasLiteralSuffix(s, "/sbin")))
+    {
+    return cmSystemTools::GetFilenamePath(s);
+    }
+  else
+    {
+    return s;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddEnvPrefixPath(const std::string& variable, bool stripBin)
 {
   std::vector<std::string> expanded;
   cmSystemTools::GetPath(expanded, variable.c_str());
+  if (stripBin)
+    {
+    std::transform(expanded.begin(), expanded.end(), expanded.begin(),
+                   cmSearchPathStripBin);
+    }
   this->AddPrefixPaths(expanded);
 }
 
diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h
index 51a6149..41c680d 100644
--- a/Source/cmSearchPath.h
+++ b/Source/cmSearchPath.h
@@ -42,7 +42,7 @@ public:
   void AddCMakePath(const std::string& variable);
   void AddEnvPath(const std::string& variable);
   void AddCMakePrefixPath(const std::string& variable);
-  void AddEnvPrefixPath(const std::string& variable);
+  void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
   void AddSuffixes(const std::vector<std::string>& suffixes);
 
 protected:
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index f0426e5..fd01201 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -131,8 +131,10 @@ add_RunCMake_test(export)
 add_RunCMake_test(cmake_minimum_required)
 add_RunCMake_test(continue)
 add_RunCMake_test(file)
+add_RunCMake_test(find_file)
 add_RunCMake_test(find_library)
 add_RunCMake_test(find_package)
+add_RunCMake_test(find_path)
 add_RunCMake_test(get_filename_component)
 add_RunCMake_test(get_property)
 add_RunCMake_test(if)
diff --git a/Tests/RunCMake/find_file/CMakeLists.txt b/Tests/RunCMake/find_file/CMakeLists.txt
new file mode 100644
index 0000000..ef2163c
--- /dev/null
+++ b/Tests/RunCMake/find_file/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt
new file mode 100644
index 0000000..d73bc1d
--- /dev/null
+++ b/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
diff --git a/Tests/RunCMake/find_file/PrefixInPATH.cmake b/Tests/RunCMake/find_file/PrefixInPATH.cmake
new file mode 100644
index 0000000..79106e9
--- /dev/null
+++ b/Tests/RunCMake/find_file/PrefixInPATH.cmake
@@ -0,0 +1,6 @@
+foreach(path "/does_not_exist" "" "/bin" "/sbin")
+  unset(PrefixInPATH_INCLUDE_DIR CACHE)
+  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+  find_file(PrefixInPATH_INCLUDE_DIR NAMES PrefixInPATH.h)
+  message(STATUS "PrefixInPATH_INCLUDE_DIR='${PrefixInPATH_INCLUDE_DIR}'")
+endforeach()
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
new file mode 100644
index 0000000..014f397
--- /dev/null
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(PrefixInPATH)
diff --git a/Tests/RunCMake/find_file/include/PrefixInPATH.h b/Tests/RunCMake/find_file/include/PrefixInPATH.h
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt
new file mode 100644
index 0000000..1ab884c
--- /dev/null
+++ b/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
diff --git a/Tests/RunCMake/find_library/PrefixInPATH.cmake b/Tests/RunCMake/find_library/PrefixInPATH.cmake
new file mode 100644
index 0000000..6e37359
--- /dev/null
+++ b/Tests/RunCMake/find_library/PrefixInPATH.cmake
@@ -0,0 +1,9 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+
+foreach(path "/does_not_exist" "" "/bin" "/sbin")
+  unset(PrefixInPATH_LIBRARY CACHE)
+  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+  find_library(PrefixInPATH_LIBRARY NAMES PrefixInPATH)
+  message(STATUS "PrefixInPATH_LIBRARY='${PrefixInPATH_LIBRARY}'")
+endforeach()
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
index 4000679..136031c 100644
--- a/Tests/RunCMake/find_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -1,3 +1,4 @@
 include(RunCMake)
 
 run_cmake(Created)
+run_cmake(PrefixInPATH)
diff --git a/Tests/RunCMake/find_library/lib/libPrefixInPATH.a b/Tests/RunCMake/find_library/lib/libPrefixInPATH.a
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/find_path/CMakeLists.txt b/Tests/RunCMake/find_path/CMakeLists.txt
new file mode 100644
index 0000000..ef2163c
--- /dev/null
+++ b/Tests/RunCMake/find_path/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt
new file mode 100644
index 0000000..bb2ceb7
--- /dev/null
+++ b/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
diff --git a/Tests/RunCMake/find_path/PrefixInPATH.cmake b/Tests/RunCMake/find_path/PrefixInPATH.cmake
new file mode 100644
index 0000000..a321910
--- /dev/null
+++ b/Tests/RunCMake/find_path/PrefixInPATH.cmake
@@ -0,0 +1,6 @@
+foreach(path "/does_not_exist" "" "/bin" "/sbin")
+  unset(PrefixInPATH_INCLUDE_DIR CACHE)
+  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+  find_path(PrefixInPATH_INCLUDE_DIR NAMES PrefixInPATH.h)
+  message(STATUS "PrefixInPATH_INCLUDE_DIR='${PrefixInPATH_INCLUDE_DIR}'")
+endforeach()
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake
new file mode 100644
index 0000000..014f397
--- /dev/null
+++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(PrefixInPATH)
diff --git a/Tests/RunCMake/find_path/include/PrefixInPATH.h b/Tests/RunCMake/find_path/include/PrefixInPATH.h
new file mode 100644
index 0000000..e69de29

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

Summary of changes:
 Help/command/FIND_XXX.txt                          |    4 ++++
 Help/command/find_file.rst                         |    5 ++++-
 Help/command/find_library.rst                      |    5 ++++-
 Help/command/find_path.rst                         |    5 ++++-
 Help/release/dev/find-command-prefix-from-PATH.rst |    6 ++++++
 Source/CMakeVersion.cmake                          |    2 +-
 Source/cmFindBase.cxx                              |    1 +
 Source/cmSearchPath.cxx                            |   22 +++++++++++++++++++-
 Source/cmSearchPath.h                              |    2 +-
 Tests/RunCMake/CMakeLists.txt                      |    2 ++
 .../RunCMake/{CMP0055 => find_file}/CMakeLists.txt |    0
 Tests/RunCMake/find_file/PrefixInPATH-stdout.txt   |    4 ++++
 Tests/RunCMake/find_file/PrefixInPATH.cmake        |    6 ++++++
 Tests/RunCMake/find_file/RunCMakeTest.cmake        |    3 +++
 .../RunCMake/find_file/include/PrefixInPATH.h      |    0
 .../RunCMake/find_library/PrefixInPATH-stdout.txt  |    4 ++++
 Tests/RunCMake/find_library/PrefixInPATH.cmake     |    9 ++++++++
 Tests/RunCMake/find_library/RunCMakeTest.cmake     |    1 +
 .../RunCMake/find_library/lib/libPrefixInPATH.a    |    0
 .../RunCMake/{CMP0055 => find_path}/CMakeLists.txt |    0
 Tests/RunCMake/find_path/PrefixInPATH-stdout.txt   |    4 ++++
 Tests/RunCMake/find_path/PrefixInPATH.cmake        |    6 ++++++
 Tests/RunCMake/find_path/RunCMakeTest.cmake        |    3 +++
 .../RunCMake/find_path/include/PrefixInPATH.h      |    0
 24 files changed, 88 insertions(+), 6 deletions(-)
 create mode 100644 Help/release/dev/find-command-prefix-from-PATH.rst
 copy Tests/RunCMake/{CMP0055 => find_file}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/find_file/PrefixInPATH-stdout.txt
 create mode 100644 Tests/RunCMake/find_file/PrefixInPATH.cmake
 create mode 100644 Tests/RunCMake/find_file/RunCMakeTest.cmake
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/find_file/include/PrefixInPATH.h (100%)
 create mode 100644 Tests/RunCMake/find_library/PrefixInPATH-stdout.txt
 create mode 100644 Tests/RunCMake/find_library/PrefixInPATH.cmake
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/find_library/lib/libPrefixInPATH.a (100%)
 copy Tests/RunCMake/{CMP0055 => find_path}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/find_path/PrefixInPATH-stdout.txt
 create mode 100644 Tests/RunCMake/find_path/PrefixInPATH.cmake
 create mode 100644 Tests/RunCMake/find_path/RunCMakeTest.cmake
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/find_path/include/PrefixInPATH.h (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list