[Cmake-commits] CMake branch, next, updated. v3.3.1-2708-ga4ee0be
Brad King
brad.king at kitware.com
Wed Sep 2 09:59:39 EDT 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 a4ee0be8ac1c472c69b442b5c73c053d9f13c8bb (commit)
via ccb0e424db31ee42e571db6f8ecc80954a43f165 (commit)
via dfa4dfab869ba282d4c96c285ecc4e542d05f3eb (commit)
via 1f6e7a550275e2d561b5fdd70ab84ebaa616c473 (commit)
via 1e467c89c581a55903a18cc8e1e78ae2b399bc4b (commit)
via c385ba9ce373becde24fe12da0f7f9d8aa43e25c (commit)
via 265baffacf353df0a5e1cca0422b3b8dd67eb619 (commit)
from d1d01e4adcb36b23a37489a5d6a940f4536aa4dc (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=a4ee0be8ac1c472c69b442b5c73c053d9f13c8bb
commit a4ee0be8ac1c472c69b442b5c73c053d9f13c8bb
Merge: d1d01e4 ccb0e42
Author: Brad King <brad.king at kitware.com>
AuthorDate: Wed Sep 2 09:59:37 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Sep 2 09:59:37 2015 -0400
Merge topic 'find_program-NAMES_PER_DIR' into next
ccb0e424 find_program: Optionally consider all names in each directory
dfa4dfab cmFindProgramCommand: Re-implement search using more flexible approach
1f6e7a55 Tests: Add explicit testing for find_program
1e467c89 cmSystemTools: Drop unused StringEndsWith method
c385ba9c cmFindProgramCommand: Use Names member instead of passing it
265baffa cmFindLibraryCommand: Avoid repeating search for the same name
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ccb0e424db31ee42e571db6f8ecc80954a43f165
commit ccb0e424db31ee42e571db6f8ecc80954a43f165
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 1 16:25:57 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Wed Sep 2 09:49:22 2015 -0400
find_program: Optionally consider all names in each directory
When more than one value is given to the NAMES option this command by
default will consider one name at a time and search every directory for
it. Add a NAMES_PER_DIR option to tell this command to consider one
directory at a time and search for all names in it.
diff --git a/Help/command/find_program.rst b/Help/command/find_program.rst
index 2a5ce9a..d3430c0 100644
--- a/Help/command/find_program.rst
+++ b/Help/command/find_program.rst
@@ -2,7 +2,7 @@ find_program
------------
.. |FIND_XXX| replace:: find_program
-.. |NAMES| replace:: NAMES name1 [name2 ...]
+.. |NAMES| replace:: NAMES name1 [name2 ...] [NAMES_PER_DIR]
.. |SEARCH_XXX| replace:: program
.. |SEARCH_XXX_DESC| replace:: program
.. |prefix_XXX_SUBDIR| replace:: ``<prefix>/[s]bin``
@@ -26,3 +26,8 @@ find_program
:variable:`CMAKE_FIND_ROOT_PATH_MODE_PROGRAM`
.. include:: FIND_XXX.txt
+
+When more than one value is given to the ``NAMES`` option this command by
+default will consider one name at a time and search every directory
+for it. The ``NAMES_PER_DIR`` option tells this command to consider one
+directory at a time and search for all names in it.
diff --git a/Help/release/dev/find_program-NAMES_PER_DIR.rst b/Help/release/dev/find_program-NAMES_PER_DIR.rst
new file mode 100644
index 0000000..04cd170
--- /dev/null
+++ b/Help/release/dev/find_program-NAMES_PER_DIR.rst
@@ -0,0 +1,6 @@
+find_program-NAMES_PER_DIR
+--------------------------
+
+* The :command:`find_program` command learned a ``NAMES_PER_DIR``
+ option to consdier all given ``NAMES`` in each directory before
+ moving on to the next directory.
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index c9bc56d..e64ed87 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -85,6 +85,11 @@ struct cmFindProgramHelper
}
};
+cmFindProgramCommand::cmFindProgramCommand()
+{
+ this->NamesPerDirAllowed = true;
+}
+
// cmFindProgramCommand
bool cmFindProgramCommand
::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
@@ -151,6 +156,42 @@ std::string cmFindProgramCommand::FindProgram()
//----------------------------------------------------------------------------
std::string cmFindProgramCommand::FindNormalProgram()
{
+ if(this->NamesPerDir)
+ {
+ return this->FindNormalProgramNamesPerDir();
+ }
+ else
+ {
+ return this->FindNormalProgramDirsPerName();
+ }
+}
+
+//----------------------------------------------------------------------------
+std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
+{
+ // Search for all names in each directory.
+ cmFindProgramHelper helper;
+ for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+ ni != this->Names.end() ; ++ni)
+ {
+ helper.AddName(*ni);
+ }
+ // Search every directory.
+ for (std::vector<std::string>::const_iterator
+ p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p)
+ {
+ if(helper.CheckDirectory(*p))
+ {
+ return helper.BestPath;
+ }
+ }
+ // Couldn't find the program.
+ return "";
+}
+
+//----------------------------------------------------------------------------
+std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
+{
// Search the entire path for each name.
cmFindProgramHelper helper;
for (std::vector<std::string>::const_iterator ni = this->Names.begin();
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index df39b14..f88186b 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -25,6 +25,7 @@
class cmFindProgramCommand : public cmFindBase
{
public:
+ cmFindProgramCommand();
/**
* This is a virtual constructor for the command.
*/
@@ -55,6 +56,8 @@ public:
private:
std::string FindProgram();
std::string FindNormalProgram();
+ std::string FindNormalProgramDirsPerName();
+ std::string FindNormalProgramNamesPerDir();
std::string FindAppBundle();
std::string GetBundleExecutable(std::string bundlePath);
diff --git a/Tests/RunCMake/find_program/NamesPerDir-stdout.txt b/Tests/RunCMake/find_program/NamesPerDir-stdout.txt
new file mode 100644
index 0000000..964e259
--- /dev/null
+++ b/Tests/RunCMake/find_program/NamesPerDir-stdout.txt
@@ -0,0 +1 @@
+-- PROG='[^']*/Tests/RunCMake/find_program/A/testA'
diff --git a/Tests/RunCMake/find_program/NamesPerDir.cmake b/Tests/RunCMake/find_program/NamesPerDir.cmake
new file mode 100644
index 0000000..49ce49d
--- /dev/null
+++ b/Tests/RunCMake/find_program/NamesPerDir.cmake
@@ -0,0 +1,6 @@
+find_program(PROG
+ NAMES testB testA NAMES_PER_DIR
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG='${PROG}'")
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index 1a99f0a..2adec11 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -1,6 +1,7 @@
include(RunCMake)
run_cmake(DirsPerName)
+run_cmake(NamesPerDir)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$")
run_cmake(WindowsCom)
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dfa4dfab869ba282d4c96c285ecc4e542d05f3eb
commit dfa4dfab869ba282d4c96c285ecc4e542d05f3eb
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 1 13:54:33 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Wed Sep 2 09:48:53 2015 -0400
cmFindProgramCommand: Re-implement search using more flexible approach
Avoid using KWSys SystemTools::FindProgram because it does much more
than we actually need for find_program and does not allow us to control
the order of preference between directories and names. Create our own
cmFindProgramHelper much like cmFindLibraryHelper but without all the
find_library-specific parts.
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index ef1c16b..c9bc56d 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -16,6 +16,75 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
+//----------------------------------------------------------------------------
+struct cmFindProgramHelper
+{
+ cmFindProgramHelper()
+ {
+#if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
+ // Consider platform-specific extensions.
+ this->Extensions.push_back(".com");
+ this->Extensions.push_back(".exe");
+#endif
+ // Consider original name with no extensions.
+ this->Extensions.push_back("");
+ }
+
+ // List of valid extensions.
+ std::vector<std::string> Extensions;
+
+ // Keep track of the best program file found so far.
+ std::string BestPath;
+
+ // Current names under consideration.
+ std::vector<std::string> Names;
+
+ // Current full path under consideration.
+ std::string TestPath;
+
+ void AddName(std::string const& name)
+ {
+ this->Names.push_back(name);
+ }
+ void SetName(std::string const& name)
+ {
+ this->Names.clear();
+ this->AddName(name);
+ }
+ bool CheckDirectory(std::string const& path)
+ {
+ for (std::vector<std::string>::iterator i = this->Names.begin();
+ i != this->Names.end(); ++i)
+ {
+ if (this->CheckDirectoryForName(path, *i))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ bool CheckDirectoryForName(std::string const& path, std::string const& name)
+ {
+ for (std::vector<std::string>::iterator ext = this->Extensions.begin();
+ ext != this->Extensions.end(); ++ext)
+ {
+ this->TestPath = path;
+ this->TestPath += name;
+ if (!ext->empty() && cmSystemTools::StringEndsWith(name, ext->c_str()))
+ {
+ continue;
+ }
+ this->TestPath += *ext;
+ if (cmSystemTools::FileExists(this->TestPath, true))
+ {
+ this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
+ return true;
+ }
+ }
+ return false;
+ }
+};
+
// cmFindProgramCommand
bool cmFindProgramCommand
::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
@@ -69,7 +138,7 @@ std::string cmFindProgramCommand::FindProgram()
}
if(program.empty() && !this->SearchAppBundleOnly)
{
- program = cmSystemTools::FindProgram(this->Names, this->SearchPaths, true);
+ program = this->FindNormalProgram();
}
if(program.empty() && this->SearchAppBundleLast)
@@ -79,6 +148,32 @@ std::string cmFindProgramCommand::FindProgram()
return program;
}
+//----------------------------------------------------------------------------
+std::string cmFindProgramCommand::FindNormalProgram()
+{
+ // Search the entire path for each name.
+ cmFindProgramHelper helper;
+ for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+ ni != this->Names.end() ; ++ni)
+ {
+ // Switch to searching for this name.
+ helper.SetName(*ni);
+
+ // Search every directory.
+ for (std::vector<std::string>::const_iterator
+ p = this->SearchPaths.begin();
+ p != this->SearchPaths.end(); ++p)
+ {
+ if (helper.CheckDirectory(*p))
+ {
+ return helper.BestPath;
+ }
+ }
+ }
+ // Couldn't find the program.
+ return "";
+}
+
std::string cmFindProgramCommand::FindAppBundle()
{
for(std::vector<std::string>::const_iterator name = this->Names.begin();
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index 2881aac..df39b14 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -54,6 +54,7 @@ public:
private:
std::string FindProgram();
+ std::string FindNormalProgram();
std::string FindAppBundle();
std::string GetBundleExecutable(std::string bundlePath);
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f6e7a550275e2d561b5fdd70ab84ebaa616c473
commit 1f6e7a550275e2d561b5fdd70ab84ebaa616c473
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 1 16:33:24 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Wed Sep 2 09:38:47 2015 -0400
Tests: Add explicit testing for find_program
Previously this command was tested only implicitly as part of larger
tests. Add a RunCMake.find_program test to cover find_program cases
specifically and independently.
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 2955db2..5bc9af8 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -183,6 +183,7 @@ add_RunCMake_test(find_file)
add_RunCMake_test(find_library)
add_RunCMake_test(find_package)
add_RunCMake_test(find_path)
+add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
add_RunCMake_test(get_filename_component)
add_RunCMake_test(get_property)
add_RunCMake_test(if)
diff --git a/Tests/RunCMake/find_program/A/testA b/Tests/RunCMake/find_program/A/testA
new file mode 100755
index 0000000..1a24852
--- /dev/null
+++ b/Tests/RunCMake/find_program/A/testA
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/Tests/RunCMake/find_program/B/testB b/Tests/RunCMake/find_program/B/testB
new file mode 100755
index 0000000..1a24852
--- /dev/null
+++ b/Tests/RunCMake/find_program/B/testB
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/Tests/RunCMake/find_program/CMakeLists.txt b/Tests/RunCMake/find_program/CMakeLists.txt
new file mode 100644
index 0000000..74b3ff8
--- /dev/null
+++ b/Tests/RunCMake/find_program/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.3)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/find_program/DirsPerName-stdout.txt b/Tests/RunCMake/find_program/DirsPerName-stdout.txt
new file mode 100644
index 0000000..f763bb0
--- /dev/null
+++ b/Tests/RunCMake/find_program/DirsPerName-stdout.txt
@@ -0,0 +1 @@
+-- PROG='[^']*/Tests/RunCMake/find_program/B/testB'
diff --git a/Tests/RunCMake/find_program/DirsPerName.cmake b/Tests/RunCMake/find_program/DirsPerName.cmake
new file mode 100644
index 0000000..54db6dd
--- /dev/null
+++ b/Tests/RunCMake/find_program/DirsPerName.cmake
@@ -0,0 +1,6 @@
+find_program(PROG
+ NAMES testB testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG='${PROG}'")
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
new file mode 100644
index 0000000..1a99f0a
--- /dev/null
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(DirsPerName)
+
+if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$")
+ run_cmake(WindowsCom)
+ run_cmake(WindowsExe)
+endif()
diff --git a/Tests/RunCMake/find_program/Win/testCom.com b/Tests/RunCMake/find_program/Win/testCom.com
new file mode 100755
index 0000000..e69de29
diff --git a/Tests/RunCMake/find_program/Win/testCom.exe b/Tests/RunCMake/find_program/Win/testCom.exe
new file mode 100755
index 0000000..e69de29
diff --git a/Tests/RunCMake/find_program/Win/testExe.exe b/Tests/RunCMake/find_program/Win/testExe.exe
new file mode 100755
index 0000000..e69de29
diff --git a/Tests/RunCMake/find_program/WindowsCom-stdout.txt b/Tests/RunCMake/find_program/WindowsCom-stdout.txt
new file mode 100644
index 0000000..e386fce
--- /dev/null
+++ b/Tests/RunCMake/find_program/WindowsCom-stdout.txt
@@ -0,0 +1 @@
+-- PROG='[^']*/Tests/RunCMake/find_program/Win/testCom.com'
diff --git a/Tests/RunCMake/find_program/WindowsCom.cmake b/Tests/RunCMake/find_program/WindowsCom.cmake
new file mode 100644
index 0000000..b32d9e8
--- /dev/null
+++ b/Tests/RunCMake/find_program/WindowsCom.cmake
@@ -0,0 +1,6 @@
+find_program(PROG
+ NAMES testCom
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Win
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG='${PROG}'")
diff --git a/Tests/RunCMake/find_program/WindowsExe-stdout.txt b/Tests/RunCMake/find_program/WindowsExe-stdout.txt
new file mode 100644
index 0000000..bdf48aa
--- /dev/null
+++ b/Tests/RunCMake/find_program/WindowsExe-stdout.txt
@@ -0,0 +1 @@
+-- PROG='[^']*/Tests/RunCMake/find_program/Win/testExe.exe'
diff --git a/Tests/RunCMake/find_program/WindowsExe.cmake b/Tests/RunCMake/find_program/WindowsExe.cmake
new file mode 100644
index 0000000..3a336ec
--- /dev/null
+++ b/Tests/RunCMake/find_program/WindowsExe.cmake
@@ -0,0 +1,6 @@
+find_program(PROG
+ NAMES testExe
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Win
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG='${PROG}'")
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e467c89c581a55903a18cc8e1e78ae2b399bc4b
commit 1e467c89c581a55903a18cc8e1e78ae2b399bc4b
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 1 13:50:13 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Sep 1 13:51:45 2015 -0400
cmSystemTools: Drop unused StringEndsWith method
It has no callers and we can inherit one from KWSys SystemTools anyway.
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index cac6a12..65bfe79 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1409,15 +1409,6 @@ std::string cmSystemTools::ConvertToRunCommandPath(const char* path)
#endif
}
-bool cmSystemTools::StringEndsWith(const char* str1, const char* str2)
-{
- if ( !str1 || !str2 || strlen(str1) < strlen(str2) )
- {
- return 0;
- }
- return !strncmp(str1 + (strlen(str1)-strlen(str2)), str2, strlen(str2));
-}
-
// compute the relative path from here to there
std::string cmSystemTools::RelativePath(const char* local, const char* remote)
{
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index c12a1db..d14897f 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -336,8 +336,6 @@ public:
// be used when RunCommand is called from cmake, because the
// running cmake needs paths to be in its format
static std::string ConvertToRunCommandPath(const char* path);
- //! Check if the first string ends with the second one.
- static bool StringEndsWith(const char* str1, const char* str2);
/** compute the relative path from local to remote. local must
be a directory. remote can be a file or a directory.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c385ba9ce373becde24fe12da0f7f9d8aa43e25c
commit c385ba9ce373becde24fe12da0f7f9d8aa43e25c
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 1 13:42:14 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Sep 1 13:48:05 2015 -0400
cmFindProgramCommand: Use Names member instead of passing it
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index fbd9fd3..ef1c16b 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -41,7 +41,7 @@ bool cmFindProgramCommand
return true;
}
- std::string result = FindProgram(this->Names);
+ std::string result = FindProgram();
if(result != "")
{
// Save the value in the cache
@@ -59,31 +59,30 @@ bool cmFindProgramCommand
return true;
}
-std::string cmFindProgramCommand::FindProgram(std::vector<std::string> names)
+std::string cmFindProgramCommand::FindProgram()
{
std::string program = "";
if(this->SearchAppBundleFirst || this->SearchAppBundleOnly)
{
- program = FindAppBundle(names);
+ program = FindAppBundle();
}
if(program.empty() && !this->SearchAppBundleOnly)
{
- program = cmSystemTools::FindProgram(names, this->SearchPaths, true);
+ program = cmSystemTools::FindProgram(this->Names, this->SearchPaths, true);
}
if(program.empty() && this->SearchAppBundleLast)
{
- program = this->FindAppBundle(names);
+ program = this->FindAppBundle();
}
return program;
}
-std::string cmFindProgramCommand
-::FindAppBundle(std::vector<std::string> names)
+std::string cmFindProgramCommand::FindAppBundle()
{
- for(std::vector<std::string>::const_iterator name = names.begin();
- name != names.end() ; ++name)
+ for(std::vector<std::string>::const_iterator name = this->Names.begin();
+ name != this->Names.end() ; ++name)
{
std::string appName = *name + std::string(".app");
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index 70f758f..2881aac 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -52,11 +52,9 @@ public:
cmTypeMacro(cmFindProgramCommand, cmFindBase);
-protected:
- std::string FindProgram(std::vector<std::string> names);
-
private:
- std::string FindAppBundle(std::vector<std::string> names);
+ std::string FindProgram();
+ std::string FindAppBundle();
std::string GetBundleExecutable(std::string bundlePath);
};
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=265baffacf353df0a5e1cca0422b3b8dd67eb619
commit 265baffacf353df0a5e1cca0422b3b8dd67eb619
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 1 13:39:55 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Sep 1 13:42:12 2015 -0400
cmFindLibraryCommand: Avoid repeating search for the same name
In FindNormalLibraryDirsPerName we consider one name at a time and
search the entire path. Avoid repeated consideration of names by
removing each one from the list of candidates before considering the
next one. This will not change behavior because we already know the
earlier candidates were not found on repeated considering anyway.
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index e8d158e..e7696af 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -203,6 +203,7 @@ struct cmFindLibraryHelper
}
bool HasValidSuffix(std::string const& name);
void AddName(std::string const& name);
+ void SetName(std::string const& name);
bool CheckDirectory(std::string const& path);
bool CheckDirectoryForName(std::string const& path, Name& name);
};
@@ -322,6 +323,13 @@ void cmFindLibraryHelper::AddName(std::string const& name)
}
//----------------------------------------------------------------------------
+void cmFindLibraryHelper::SetName(std::string const& name)
+{
+ this->Names.clear();
+ this->AddName(name);
+}
+
+//----------------------------------------------------------------------------
bool cmFindLibraryHelper::CheckDirectory(std::string const& path)
{
for(std::vector<Name>::iterator i = this->Names.begin();
@@ -459,8 +467,7 @@ std::string cmFindLibraryCommand::FindNormalLibraryDirsPerName()
ni != this->Names.end() ; ++ni)
{
// Switch to searching for this name.
- std::string const& name = *ni;
- helper.AddName(name);
+ helper.SetName(*ni);
// Search every directory.
for(std::vector<std::string>::const_iterator
-----------------------------------------------------------------------
Summary of changes:
Help/command/find_program.rst | 7 +-
Help/release/dev/find_program-NAMES_PER_DIR.rst | 6 +
Source/cmFindLibraryCommand.cxx | 11 +-
Source/cmFindProgramCommand.cxx | 153 ++++++++++++++++++--
Source/cmFindProgramCommand.h | 10 +-
Source/cmSystemTools.cxx | 9 --
Source/cmSystemTools.h | 2 -
Tests/RunCMake/CMakeLists.txt | 1 +
Tests/RunCMake/find_program/A/testA | 1 +
Tests/RunCMake/find_program/B/testB | 1 +
.../{CMP0064 => find_program}/CMakeLists.txt | 0
Tests/RunCMake/find_program/DirsPerName-stdout.txt | 1 +
Tests/RunCMake/find_program/DirsPerName.cmake | 6 +
Tests/RunCMake/find_program/NamesPerDir-stdout.txt | 1 +
Tests/RunCMake/find_program/NamesPerDir.cmake | 6 +
Tests/RunCMake/find_program/RunCMakeTest.cmake | 9 ++
.../RunCMake/find_program/Win/testCom.com | 0
.../RunCMake/find_program/Win/testCom.exe | 0
.../RunCMake/find_program/Win/testExe.exe | 0
Tests/RunCMake/find_program/WindowsCom-stdout.txt | 1 +
Tests/RunCMake/find_program/WindowsCom.cmake | 6 +
Tests/RunCMake/find_program/WindowsExe-stdout.txt | 1 +
Tests/RunCMake/find_program/WindowsExe.cmake | 6 +
23 files changed, 211 insertions(+), 27 deletions(-)
create mode 100644 Help/release/dev/find_program-NAMES_PER_DIR.rst
create mode 100755 Tests/RunCMake/find_program/A/testA
create mode 100755 Tests/RunCMake/find_program/B/testB
copy Tests/RunCMake/{CMP0064 => find_program}/CMakeLists.txt (100%)
create mode 100644 Tests/RunCMake/find_program/DirsPerName-stdout.txt
create mode 100644 Tests/RunCMake/find_program/DirsPerName.cmake
create mode 100644 Tests/RunCMake/find_program/NamesPerDir-stdout.txt
create mode 100644 Tests/RunCMake/find_program/NamesPerDir.cmake
create mode 100644 Tests/RunCMake/find_program/RunCMakeTest.cmake
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/find_program/Win/testCom.com (100%)
mode change 100644 => 100755
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/find_program/Win/testCom.exe (100%)
mode change 100644 => 100755
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/find_program/Win/testExe.exe (100%)
mode change 100644 => 100755
create mode 100644 Tests/RunCMake/find_program/WindowsCom-stdout.txt
create mode 100644 Tests/RunCMake/find_program/WindowsCom.cmake
create mode 100644 Tests/RunCMake/find_program/WindowsExe-stdout.txt
create mode 100644 Tests/RunCMake/find_program/WindowsExe.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list