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.
This commit is contained in:
parent
289c30ad3a
commit
f8264cf2ff
@ -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(),
|
||||
|
@ -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();
|
||||
|
@ -2013,7 +2013,7 @@ void cmFindPackageCommand::ComputePrefixes()
|
||||
}
|
||||
this->FillPrefixesUserGuess();
|
||||
|
||||
this->ComputeFinalPaths(IgnorePaths::No);
|
||||
this->ComputeFinalPaths(IgnorePaths::No, &this->DebugBuffer);
|
||||
}
|
||||
|
||||
void cmFindPackageCommand::FillPrefixesPackageRedirect()
|
||||
|
52
Tests/RunCMake/find_package/DebugRoot-stderr.txt
Normal file
52
Tests/RunCMake/find_package/DebugRoot-stderr.txt
Normal file
@ -0,0 +1,52 @@
|
||||
^CMake Debug Log at DebugRoot\.cmake:[0-9]+ \(find_package\):
|
||||
The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR\.
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot-build/CMakeFiles/pkgRedirects
|
||||
|
||||
Paths specified by the find_package HINTS option\.
|
||||
|
||||
none
|
||||
|
||||
Paths specified by the find_package PATHS option\.
|
||||
|
||||
/DebugRoot
|
||||
|
||||
Prepending the following roots to each prefix:
|
||||
|
||||
CMAKE_FIND_ROOT_PATH
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot/NoExist
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot/Exist
|
||||
|
||||
CMAKE_SYSROOT_COMPILE
|
||||
|
||||
none
|
||||
|
||||
CMAKE_SYSROOT_LINK
|
||||
|
||||
none
|
||||
|
||||
CMAKE_SYSROOT
|
||||
|
||||
none
|
||||
|
||||
find_package considered the following locations for DebugRoot's Config
|
||||
module:
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot/NoExist/DebugRoot/DebugRootConfig\.cmake
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot/NoExist/DebugRoot/debugroot-config\.cmake
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot/Exist/DebugRoot/DebugRootConfig\.cmake
|
||||
|
||||
The file was found at
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/DebugRoot/Exist/DebugRoot/DebugRootConfig.cmake
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
15
Tests/RunCMake/find_package/DebugRoot.cmake
Normal file
15
Tests/RunCMake/find_package/DebugRoot.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/DebugRoot/NoExist ${CMAKE_CURRENT_LIST_DIR}/DebugRoot/Exist)
|
||||
set(CMAKE_FIND_DEBUG_MODE ON)
|
||||
find_package(DebugRoot
|
||||
NO_DEFAULT_PATH
|
||||
NO_PACKAGE_ROOT_PATH
|
||||
NO_CMAKE_PATH
|
||||
NO_CMAKE_ENVIRONMENT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_PACKAGE_REGISTRY
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_INSTALL_PREFIX
|
||||
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
|
||||
PATHS /DebugRoot
|
||||
)
|
||||
set(CMAKE_FIND_DEBUG_MODE OFF)
|
@ -0,0 +1 @@
|
||||
set(DebugRoot_FOUND TRUE)
|
@ -74,6 +74,7 @@ run_cmake(IgnorePrefixPath)
|
||||
run_cmake(REGISTRY_VIEW-no-view)
|
||||
run_cmake(REGISTRY_VIEW-wrong-view)
|
||||
run_cmake(REGISTRY_VIEW-propagated)
|
||||
run_cmake(DebugRoot)
|
||||
|
||||
if(CMAKE_HOST_WIN32 AND MINGW)
|
||||
run_cmake(MSYSTEM_PREFIX)
|
||||
|
Loading…
Reference in New Issue
Block a user