mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
find_package: Fix assertion failure on empty sysroots
Previously we crashed if at least one root variable was set to empty and at least one to non-empty. Fixes: #26538
This commit is contained in:
@@ -248,19 +248,19 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths,
|
||||
// Construct the list of path roots with no trailing slashes.
|
||||
cmList roots;
|
||||
debugRoot("CMAKE_FIND_ROOT_PATH", rootPath);
|
||||
if (rootPath) {
|
||||
if (cmNonempty(rootPath)) {
|
||||
roots.assign(*rootPath);
|
||||
}
|
||||
debugRoot("CMAKE_SYSROOT_COMPILE", sysrootCompile);
|
||||
if (sysrootCompile) {
|
||||
if (cmNonempty(sysrootCompile)) {
|
||||
roots.emplace_back(*sysrootCompile);
|
||||
}
|
||||
debugRoot("CMAKE_SYSROOT_LINK", sysrootLink);
|
||||
if (sysrootLink) {
|
||||
if (cmNonempty(sysrootLink)) {
|
||||
roots.emplace_back(*sysrootLink);
|
||||
}
|
||||
debugRoot("CMAKE_SYSROOT", sysroot);
|
||||
if (sysroot) {
|
||||
if (cmNonempty(sysroot)) {
|
||||
roots.emplace_back(*sysroot);
|
||||
}
|
||||
for (auto& r : roots) {
|
||||
|
||||
10
Tests/RunCMake/find_package/EmptyRoots.cmake
Normal file
10
Tests/RunCMake/find_package/EmptyRoots.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
set(vars CMAKE_SYSROOT CMAKE_SYSROOT_COMPILE CMAKE_SYSROOT_LINK CMAKE_FIND_ROOT_PATH)
|
||||
foreach(v IN LISTS vars)
|
||||
set("${v}" "")
|
||||
endforeach()
|
||||
foreach(v IN LISTS vars)
|
||||
block()
|
||||
set("${v}" "/dummy")
|
||||
find_package(dummy CONFIG NO_DEFAULT_PATH PATHS "/")
|
||||
endblock()
|
||||
endforeach()
|
||||
@@ -3,6 +3,7 @@ include(RunCMake)
|
||||
run_cmake(CMP0074-WARN)
|
||||
run_cmake(CMP0074-OLD)
|
||||
run_cmake(ComponentRequiredAndOptional)
|
||||
run_cmake(EmptyRoots)
|
||||
run_cmake(FromPATHEnv)
|
||||
run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved)
|
||||
run_cmake(FromPrefixPath)
|
||||
|
||||
Reference in New Issue
Block a user