summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyedwards@nvidia.com>2024-08-02 20:18:44 (GMT)
committerKyle Edwards <kyedwards@nvidia.com>2024-08-02 20:18:44 (GMT)
commitf8264cf2ffc3daabffe25365a5e91865d97d147b (patch)
tree96055e7632a93148205b81512f071d5fc2b1b08e /Source
parent289c30ad3ab31dbdc5348bf5450344f6ec08ceca (diff)
downloadCMake-f8264cf2ffc3daabffe25365a5e91865d97d147b.zip
CMake-f8264cf2ffc3daabffe25365a5e91865d97d147b.tar.gz
CMake-f8264cf2ffc3daabffe25365a5e91865d97d147b.tar.bz2
find_package(): Debug re-rooting behavior
find_package()'s debug mode provides information about which prefixes are searched, but not which roots are prepended to each prefix. Display this information if debugging is enabled.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFindCommon.cxx31
-rw-r--r--Source/cmFindCommon.h6
-rw-r--r--Source/cmFindPackageCommand.cxx2
3 files changed, 33 insertions, 6 deletions
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 31cc14b..31243f6 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -212,7 +212,8 @@ void cmFindCommon::SelectDefaultSearchModes()
}
}
-void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
+void cmFindCommon::RerootPaths(std::vector<std::string>& paths,
+ std::string* debugBuffer)
{
#if 0
for(std::string const& p : paths)
@@ -238,17 +239,40 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
return;
}
+ if (this->DebugMode && debugBuffer) {
+ *debugBuffer = cmStrCat(
+ *debugBuffer, "Prepending the following roots to each prefix:\n");
+ }
+
+ auto debugRoot = [this, debugBuffer](const std::string& name,
+ cmValue value) {
+ if (this->DebugMode && debugBuffer) {
+ *debugBuffer = cmStrCat(*debugBuffer, name, "\n");
+ cmList roots{ value };
+ if (roots.empty()) {
+ *debugBuffer = cmStrCat(*debugBuffer, " none\n");
+ }
+ for (auto const& root : roots) {
+ *debugBuffer = cmStrCat(*debugBuffer, " ", root, "\n");
+ }
+ }
+ };
+
// Construct the list of path roots with no trailing slashes.
cmList roots;
+ debugRoot("CMAKE_FIND_ROOT_PATH", rootPath);
if (rootPath) {
roots.assign(*rootPath);
}
+ debugRoot("CMAKE_SYSROOT_COMPILE", sysrootCompile);
if (sysrootCompile) {
roots.emplace_back(*sysrootCompile);
}
+ debugRoot("CMAKE_SYSROOT_LINK", sysrootLink);
if (sysrootLink) {
roots.emplace_back(*sysrootLink);
}
+ debugRoot("CMAKE_SYSROOT", sysroot);
if (sysroot) {
roots.emplace_back(*sysroot);
}
@@ -411,7 +435,8 @@ static void AddTrailingSlash(std::string& s)
s += '/';
}
}
-void cmFindCommon::ComputeFinalPaths(IgnorePaths ignorePaths)
+void cmFindCommon::ComputeFinalPaths(IgnorePaths ignorePaths,
+ std::string* debugBuffer)
{
// Filter out ignored paths from the prefix list
std::set<std::string> ignoredPaths;
@@ -430,7 +455,7 @@ void cmFindCommon::ComputeFinalPaths(IgnorePaths ignorePaths)
}
// Expand list of paths inside all search roots.
- this->RerootPaths(this->SearchPaths);
+ this->RerootPaths(this->SearchPaths, debugBuffer);
// Add a trailing slash to all paths to aid the search process.
std::for_each(this->SearchPaths.begin(), this->SearchPaths.end(),
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 41de797..1abf567 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -81,7 +81,8 @@ protected:
void InitializeSearchPathGroups();
/** Place a set of search paths under the search roots. */
- void RerootPaths(std::vector<std::string>& paths);
+ void RerootPaths(std::vector<std::string>& paths,
+ std::string* debugBuffer = nullptr);
/** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PATH variables. */
void GetIgnoredPaths(std::vector<std::string>& ignore);
@@ -97,7 +98,8 @@ protected:
No,
Yes,
};
- void ComputeFinalPaths(IgnorePaths ignorePaths);
+ void ComputeFinalPaths(IgnorePaths ignorePaths,
+ std::string* debugBuffer = nullptr);
/** Compute the current default root path mode. */
void SelectDefaultRootPathMode();
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 344c250..59f5ce2 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -2013,7 +2013,7 @@ void cmFindPackageCommand::ComputePrefixes()
}
this->FillPrefixesUserGuess();
- this->ComputeFinalPaths(IgnorePaths::No);
+ this->ComputeFinalPaths(IgnorePaths::No, &this->DebugBuffer);
}
void cmFindPackageCommand::FillPrefixesPackageRedirect()