summaryrefslogtreecommitdiffstats
path: root/Source/cmFindProgramCommand.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2019-12-11 18:01:09 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2019-12-19 13:09:49 (GMT)
commit204b8d9f4e9c5a64e1fa6a0ee4e6dc2911694bae (patch)
tree6b7eaf2f85d6b05e69e3980eff430129ae8d324f /Source/cmFindProgramCommand.cxx
parenta7ea20649d4593bbad70b8a99aab4c2bf6294b79 (diff)
downloadCMake-204b8d9f4e9c5a64e1fa6a0ee4e6dc2911694bae.zip
CMake-204b8d9f4e9c5a64e1fa6a0ee4e6dc2911694bae.tar.gz
CMake-204b8d9f4e9c5a64e1fa6a0ee4e6dc2911694bae.tar.bz2
find_*: Use debug logging infrastructure
Teach the find_package, find_library, find_program, find_path, and find_file commands to print debug log messages when enabled by the `--debug-find` command-line option or `CMAKE_FIND_DEBUG_MODE` variable.
Diffstat (limited to 'Source/cmFindProgramCommand.cxx')
-rw-r--r--Source/cmFindProgramCommand.cxx19
1 files changed, 14 insertions, 5 deletions
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index e0a3fbf..3e49172 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -15,7 +15,9 @@ class cmExecutionStatus;
struct cmFindProgramHelper
{
- cmFindProgramHelper()
+ cmFindProgramHelper(cmMakefile* makefile, cmFindBase const* base)
+ : DebugSearches("find_program", base)
+ , Makefile(makefile)
{
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
// Consider platform-specific extensions.
@@ -41,6 +43,10 @@ struct cmFindProgramHelper
// Current full path under consideration.
std::string TestPath;
+ // Debug state
+ cmFindBaseDebugState DebugSearches;
+ cmMakefile* Makefile;
+
void AddName(std::string const& name) { this->Names.push_back(name); }
void SetName(std::string const& name)
{
@@ -78,8 +84,10 @@ struct cmFindProgramHelper
this->TestNameExt = cmStrCat(name, ext);
this->TestPath =
cmSystemTools::CollapseFullPath(this->TestNameExt, path);
-
- if (cmSystemTools::FileExists(this->TestPath, true)) {
+ bool exists = cmSystemTools::FileExists(this->TestPath, true);
+ exists ? this->DebugSearches.FoundAt(this->TestPath)
+ : this->DebugSearches.FailedAt(this->TestPath);
+ if (exists) {
this->BestPath = this->TestPath;
return true;
}
@@ -97,6 +105,7 @@ cmFindProgramCommand::cmFindProgramCommand(cmExecutionStatus& status)
// cmFindProgramCommand
bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
{
+ this->DebugMode = ComputeIfDebugModeWanted();
this->VariableDocumentation = "Path to a program.";
this->CMakePathName = "PROGRAM";
// call cmFindBase::ParseArguments
@@ -158,7 +167,7 @@ std::string cmFindProgramCommand::FindNormalProgram()
std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
{
// Search for all names in each directory.
- cmFindProgramHelper helper;
+ cmFindProgramHelper helper(this->Makefile, this);
for (std::string const& n : this->Names) {
helper.AddName(n);
}
@@ -181,7 +190,7 @@ std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
{
// Search the entire path for each name.
- cmFindProgramHelper helper;
+ cmFindProgramHelper helper(this->Makefile, this);
for (std::string const& n : this->Names) {
// Switch to searching for this name.
helper.SetName(n);