summaryrefslogtreecommitdiffstats
path: root/Source/cmFindBase.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-12-20 17:59:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-12-20 17:59:50 (GMT)
commit61960fa466ee5b1492a56fefcee6e47fd31dbfaf (patch)
tree83a76a795bbc3e835a956160550ce5026b7ee2f4 /Source/cmFindBase.cxx
parent1a81acdd229f066d7b50df984d84904e923a2f28 (diff)
parentf3c93962609f19ababd58b48db313f836bd8f0e7 (diff)
downloadCMake-61960fa466ee5b1492a56fefcee6e47fd31dbfaf.zip
CMake-61960fa466ee5b1492a56fefcee6e47fd31dbfaf.tar.gz
CMake-61960fa466ee5b1492a56fefcee6e47fd31dbfaf.tar.bz2
Merge topic 'add_find_call_debugging'
f3c9396260 Help: Document CMAKE_FIND_DEBUG_MODE 204b8d9f4e find_*: Use debug logging infrastructure a7ea20649d find_*: Add debug logging infrastructure Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3935
Diffstat (limited to 'Source/cmFindBase.cxx')
-rw-r--r--Source/cmFindBase.cxx131
1 files changed, 95 insertions, 36 deletions
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 97f6e14..bec99bb 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -4,8 +4,8 @@
#include <cstddef>
#include <deque>
-#include <iostream>
#include <map>
+#include <utility>
#include <cmext/algorithm>
@@ -117,17 +117,19 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
this->NoDefaultPath = true;
} else if (this->CheckCommonArgument(args[j])) {
doing = DoingNone;
+ } else {
// Some common arguments were accidentally supported by CMake
// 2.4 and 2.6.0 in the short-hand form of the command, so we
// must support it even though it is not documented.
- } else if (doing == DoingNames) {
- this->Names.push_back(args[j]);
- } else if (doing == DoingPaths) {
- this->UserGuessArgs.push_back(args[j]);
- } else if (doing == DoingHints) {
- this->UserHintsArgs.push_back(args[j]);
- } else if (doing == DoingPathSuffixes) {
- this->AddPathSuffix(args[j]);
+ if (doing == DoingNames) {
+ this->Names.push_back(args[j]);
+ } else if (doing == DoingPaths) {
+ this->UserGuessArgs.push_back(args[j]);
+ } else if (doing == DoingHints) {
+ this->UserHintsArgs.push_back(args[j]);
+ } else if (doing == DoingPathSuffixes) {
+ this->AddPathSuffix(args[j]);
+ }
}
}
@@ -289,33 +291,6 @@ void cmFindBase::FillUserGuessPath()
paths.AddSuffixes(this->SearchPathSuffixes);
}
-void cmFindBase::PrintFindStuff()
-{
- std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
- std::cerr << "SearchFrameworkOnly: " << this->SearchFrameworkOnly << "\n";
- std::cerr << "SearchFrameworkFirst: " << this->SearchFrameworkFirst << "\n";
- std::cerr << "SearchAppBundleLast: " << this->SearchAppBundleLast << "\n";
- std::cerr << "SearchAppBundleOnly: " << this->SearchAppBundleOnly << "\n";
- std::cerr << "SearchAppBundleFirst: " << this->SearchAppBundleFirst << "\n";
- std::cerr << "VariableName " << this->VariableName << "\n";
- std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n";
- std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
- std::cerr << "NoCMakeEnvironmentPath " << this->NoCMakeEnvironmentPath
- << "\n";
- std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
- std::cerr << "NoSystemEnvironmentPath " << this->NoSystemEnvironmentPath
- << "\n";
- std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
- std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
- std::cerr << "CMakePathName " << this->CMakePathName << "\n";
- std::cerr << "Names " << cmJoin(this->Names, " ") << "\n";
- std::cerr << "\n";
- std::cerr << "SearchPathSuffixes ";
- std::cerr << cmJoin(this->SearchPathSuffixes, "\n") << "\n";
- std::cerr << "SearchPaths\n";
- std::cerr << cmWrap("[", this->SearchPaths, "]", "\n") << "\n";
-}
-
bool cmFindBase::CheckForVariableInCache()
{
if (const char* cacheValue =
@@ -344,3 +319,87 @@ bool cmFindBase::CheckForVariableInCache()
}
return false;
}
+
+cmFindBaseDebugState::cmFindBaseDebugState(std::string commandName,
+ cmFindBase const* findBase)
+ : FindCommand(findBase)
+ , CommandName(std::move(commandName))
+{
+}
+
+cmFindBaseDebugState::~cmFindBaseDebugState()
+{
+ if (this->FindCommand->DebugMode) {
+ std::string buffer =
+ cmStrCat(this->CommandName, " called with the following settings:\n");
+ buffer += cmStrCat(" VAR: ", this->FindCommand->VariableName, "\n");
+ buffer += cmStrCat(
+ " NAMES: ", cmWrap("\"", this->FindCommand->Names, "\"", "\n "),
+ "\n");
+ buffer += cmStrCat(
+ " Documentation: ", this->FindCommand->VariableDocumentation, "\n");
+ buffer += " Framework\n";
+ buffer += cmStrCat(" Only Search Frameworks: ",
+ this->FindCommand->SearchFrameworkOnly, "\n");
+
+ buffer += cmStrCat(" Search Frameworks Last: ",
+ this->FindCommand->SearchFrameworkLast, "\n");
+ buffer += cmStrCat(" Search Frameworks First: ",
+ this->FindCommand->SearchFrameworkFirst, "\n");
+ buffer += " AppBundle\n";
+ buffer += cmStrCat(" Only Search AppBundle: ",
+ this->FindCommand->SearchAppBundleOnly, "\n");
+ buffer += cmStrCat(" Search AppBundle Last: ",
+ this->FindCommand->SearchAppBundleLast, "\n");
+ buffer += cmStrCat(" Search AppBundle First: ",
+ this->FindCommand->SearchAppBundleFirst, "\n");
+
+ if (this->FindCommand->NoDefaultPath) {
+ buffer += " NO_DEFAULT_PATH Enabled\n";
+ } else {
+ buffer += cmStrCat(
+ " CMAKE_FIND_USE_CMAKE_PATH: ", !this->FindCommand->NoCMakePath, "\n",
+ " CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: ",
+ !this->FindCommand->NoCMakeEnvironmentPath, "\n",
+ " CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: ",
+ !this->FindCommand->NoSystemEnvironmentPath, "\n",
+ " CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: ",
+ !this->FindCommand->NoCMakeSystemPath, "\n");
+ }
+
+ buffer +=
+ cmStrCat(this->CommandName, " considered the following locations:\n");
+ for (auto const& state : this->FailedSearchLocations) {
+ std::string path = cmStrCat(" ", state.path);
+ if (!state.regexName.empty()) {
+ path = cmStrCat(path, "/", state.regexName);
+ }
+ buffer += cmStrCat(path, "\n");
+ }
+
+ if (!this->FoundSearchLocation.path.empty()) {
+ buffer += cmStrCat("The item was found at\n ",
+ this->FoundSearchLocation.path, "\n");
+ } else {
+ buffer += "The item was not found.\n";
+ }
+
+ this->FindCommand->DebugMessage(buffer);
+ }
+}
+
+void cmFindBaseDebugState::FoundAt(std::string const& path,
+ std::string regexName)
+{
+ if (this->FindCommand->DebugMode) {
+ this->FoundSearchLocation = DebugLibState{ std::move(regexName), path };
+ }
+}
+
+void cmFindBaseDebugState::FailedAt(std::string const& path,
+ std::string regexName)
+{
+ if (this->FindCommand->DebugMode) {
+ this->FailedSearchLocations.emplace_back(std::move(regexName), path);
+ }
+}