diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-12-11 18:01:09 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-12-19 13:09:49 (GMT) |
commit | 204b8d9f4e9c5a64e1fa6a0ee4e6dc2911694bae (patch) | |
tree | 6b7eaf2f85d6b05e69e3980eff430129ae8d324f /Source/cmFindPathCommand.cxx | |
parent | a7ea20649d4593bbad70b8a99aab4c2bf6294b79 (diff) | |
download | CMake-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/cmFindPathCommand.cxx')
-rw-r--r-- | Source/cmFindPathCommand.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index f5e2631..908f0c1 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -21,6 +21,7 @@ cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status) // cmFindPathCommand bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn) { + this->DebugMode = ComputeIfDebugModeWanted(); this->VariableDocumentation = "Path to a file."; this->CMakePathName = "INCLUDE"; if (!this->ParseArguments(argsIn)) { @@ -55,16 +56,19 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn) std::string cmFindPathCommand::FindHeader() { + std::string debug_name = this->IncludeFileInPath ? "find_file" : "find_path"; + cmFindBaseDebugState debug(debug_name, this); std::string header; if (this->SearchFrameworkFirst || this->SearchFrameworkOnly) { - header = this->FindFrameworkHeader(); + header = this->FindFrameworkHeader(debug); } if (header.empty() && !this->SearchFrameworkOnly) { - header = this->FindNormalHeader(); + header = this->FindNormalHeader(debug); } if (header.empty() && this->SearchFrameworkLast) { - header = this->FindFrameworkHeader(); + header = this->FindFrameworkHeader(debug); } + return header; } @@ -116,28 +120,31 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file, return ""; } -std::string cmFindPathCommand::FindNormalHeader() +std::string cmFindPathCommand::FindNormalHeader(cmFindBaseDebugState& debug) { std::string tryPath; for (std::string const& n : this->Names) { for (std::string const& sp : this->SearchPaths) { tryPath = cmStrCat(sp, n); if (cmSystemTools::FileExists(tryPath)) { + debug.FoundAt(tryPath); if (this->IncludeFileInPath) { return tryPath; } return sp; } + debug.FailedAt(tryPath); } } return ""; } -std::string cmFindPathCommand::FindFrameworkHeader() +std::string cmFindPathCommand::FindFrameworkHeader(cmFindBaseDebugState& debug) { for (std::string const& n : this->Names) { for (std::string const& sp : this->SearchPaths) { std::string fwPath = this->FindHeaderInFramework(n, sp); + fwPath.empty() ? debug.FailedAt(fwPath) : debug.FoundAt(fwPath); if (!fwPath.empty()) { return fwPath; } |