summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-10 19:42:01 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-10 21:30:04 (GMT)
commit596e18540988a7c6a426c5997d0008444773fc02 (patch)
tree30887388b2949967b235d11ae7aa043a2a2747c8
parent2f435275743a345b8bbfe7de60796a1423ce92fc (diff)
downloadCMake-596e18540988a7c6a426c5997d0008444773fc02.zip
CMake-596e18540988a7c6a426c5997d0008444773fc02.tar.gz
CMake-596e18540988a7c6a426c5997d0008444773fc02.tar.bz2
find_package: Improve formatting of --debug-find output
Also spell out more complete content in the test's expect output.
-rw-r--r--Source/cmFindPackageCommand.cxx30
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnv-stderr.txt103
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnv.cmake5
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt104
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake5
5 files changed, 191 insertions, 56 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index c40fea0..d29201b 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -799,12 +799,12 @@ bool cmFindPackageCommand::FindModule(bool& found)
module, system, this->DebugMode, debugBuffer);
if (this->DebugMode) {
if (mfile.empty()) {
- debugBuffer = cmStrCat(debugBuffer, "The file was not found.");
+ debugBuffer = cmStrCat(debugBuffer, "The file was not found.\n");
} else {
debugBuffer =
cmStrCat(debugBuffer, "The file was found at\n ", mfile, "\n");
}
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
if (!mfile.empty()) {
@@ -1310,7 +1310,7 @@ inline std::size_t collectPathsForDebug(std::string& buffer,
{
const auto& paths = searchPath.GetPaths();
if (paths.empty()) {
- buffer += " none";
+ buffer += " none\n";
return 0;
}
for (std::size_t i = startIndex; i < paths.size(); i++) {
@@ -1370,7 +1370,7 @@ void cmFindPackageCommand::FillPrefixesPackageRoot()
std::string debugBuffer = "<PackageName>_ROOT CMake variable "
"[CMAKE_FIND_USE_PACKAGE_ROOT_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1393,7 +1393,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
paths.AddEnvPath("CMAKE_PREFIX_PATH");
if (this->DebugMode) {
debugBuffer = cmStrCat(debugBuffer,
- "\nCMAKE_PREFIX_PATH env variable "
+ "CMAKE_PREFIX_PATH env variable "
"[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].\n");
debugOffset = collectPathsForDebug(debugBuffer, paths, debugOffset);
}
@@ -1403,10 +1403,10 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
if (this->DebugMode) {
debugBuffer =
cmStrCat(debugBuffer,
- "\nCMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env "
+ "CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env "
"variables [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].\n");
collectPathsForDebug(debugBuffer, paths, debugOffset);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1427,10 +1427,10 @@ void cmFindPackageCommand::FillPrefixesCMakeVariable()
if (this->DebugMode) {
debugBuffer =
cmStrCat(debugBuffer,
- "\nCMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables "
+ "CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables "
"[CMAKE_FIND_USE_CMAKE_PATH].\n");
collectPathsForDebug(debugBuffer, paths, debugOffset);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1455,7 +1455,7 @@ void cmFindPackageCommand::FillPrefixesSystemEnvironment()
std::string debugBuffer = "Standard system environment variables "
"[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1485,7 +1485,7 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
"CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].\n";
collectPathsForDebug(debugBuffer,
this->LabeledPaths[PathLabel::UserRegistry]);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1505,7 +1505,7 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
"[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].\n";
collectPathsForDebug(debugBuffer,
this->LabeledPaths[PathLabel::SystemRegistry]);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1684,7 +1684,7 @@ void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
std::string debugBuffer = "CMake variables defined in the Platform file "
"[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1699,7 +1699,7 @@ void cmFindPackageCommand::FillPrefixesUserGuess()
std::string debugBuffer =
"Paths specified by the find_package PATHS option.\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1714,7 +1714,7 @@ void cmFindPackageCommand::FillPrefixesUserHints()
std::string debugBuffer =
"Paths specified by the find_package HINTS option.\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
diff --git a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt
index b35f05e..55b6a7a 100644
--- a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt
+++ b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt
@@ -1,20 +1,83 @@
-CMake Debug Log at FromPATHEnv.cmake:5 \(find_package\):
- find_package considered the following paths for Resolved.cmake.*
-.*/Modules/FindResolved.cmake.*
- The file was not found.*
- <PackageName>_ROOT CMake variable.*
- CMAKE_PREFIX_PATH variable.*
- CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.*
- Env variable Resolved_DIR.*
- CMAKE_PREFIX_PATH env variable.*
- Paths specified by the find_package HINTS option.*
- Standard system environment variables.*
-.*Tests/RunCMake/find_package/PackageRoot.*
- CMake User Package Registry.*
- CMake variables defined in the Platform file.*
- CMake System Package Registry.*
- Paths specified by the find_package PATHS option.*
- find_package considered the following locations for the Config module:.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake.*
- The file was found at.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake
+^CMake Debug Log at FromPATHEnv.cmake:[0-9]+ \(find_package\):
+ find_package considered the following paths for Resolved.cmake
+
+ [^
+]*/Modules/FindResolved.cmake
+
+ The file was not found.
+
+ <PackageName>_ROOT CMake variable \[CMAKE_FIND_USE_PACKAGE_ROOT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH variable \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
+ \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ Env variable Resolved_DIR \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH env variable \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
+ \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package HINTS option.
+
+ none
+
+ Standard system environment variables
+ \[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH\].
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot
+
+ CMake User Package Registry \[CMAKE_FIND_USE_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ CMake variables defined in the Platform file
+ \[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH\].
+(
+ [^
+]+)+
+
+ CMake System Package Registry
+ \[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package PATHS option.
+
+ none
+
+ find_package considered the following locations for the Config module:
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+ The file was found at
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Debug Log at FromPATHEnv.cmake:[0-9]+ \(find_package\):
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/find_package/FromPATHEnv.cmake b/Tests/RunCMake/find_package/FromPATHEnv.cmake
index ceb79b6..9158d4b 100644
--- a/Tests/RunCMake/find_package/FromPATHEnv.cmake
+++ b/Tests/RunCMake/find_package/FromPATHEnv.cmake
@@ -1,4 +1,7 @@
set(ENV_PATH "$ENV{PATH}")
+set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
+
+set(ENV{CMAKE_PREFIX_PATH} "")
set(CMAKE_FIND_DEBUG_MODE ON)
set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
@@ -30,4 +33,6 @@ foreach(path "/does_not_exist" "/PackageRoot" "")
find_package(Resolved NO_SYSTEM_ENVIRONMENT_PATH QUIET)
message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
endforeach()
+
+set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}")
set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
index 94ed178..e3685bc 100644
--- a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
@@ -1,21 +1,83 @@
-CMake Debug Log at FromPATHEnvDebugPkg.cmake:4 \(find_package\):
- find_package considered the following paths for Resolved.cmake.*
-.*/Modules/FindResolved.cmake.*
- The file was not found.*
- <PackageName>_ROOT CMake variable.*
- CMAKE_PREFIX_PATH variable.*
- CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.*
- Env variable Resolved_DIR.*
- CMAKE_PREFIX_PATH env variable.*
- CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables.*
- Paths specified by the find_package HINTS option.*
- Standard system environment variables.*
-.*Tests/RunCMake/find_package/PackageRoot.*
- CMake User Package Registry.*
- CMake variables defined in the Platform file.*
- CMake System Package Registry.*
- Paths specified by the find_package PATHS option.*
- find_package considered the following locations for the Config module:.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake.*
- The file was found at.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake
+^CMake Debug Log at FromPATHEnvDebugPkg.cmake:[0-9]+ \(find_package\):
+ find_package considered the following paths for Resolved.cmake
+
+ [^
+]*/Modules/FindResolved.cmake
+
+ The file was not found.
+
+ <PackageName>_ROOT CMake variable \[CMAKE_FIND_USE_PACKAGE_ROOT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH variable \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
+ \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ Env variable Resolved_DIR \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH env variable \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
+ \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package HINTS option.
+
+ none
+
+ Standard system environment variables
+ \[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH\].
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot
+
+ CMake User Package Registry \[CMAKE_FIND_USE_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ CMake variables defined in the Platform file
+ \[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH\].
+(
+ [^
+]+)+
+
+ CMake System Package Registry
+ \[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package PATHS option.
+
+ none
+
+ find_package considered the following locations for the Config module:
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+ The file was found at
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Debug Log at FromPATHEnvDebugPkg.cmake:[0-9]+ \(find_package\):
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
index 0ed8a12..72b03e6 100644
--- a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
@@ -1,4 +1,7 @@
set(ENV_PATH "$ENV{PATH}")
+set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
+
+set(ENV{CMAKE_PREFIX_PATH} "")
set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
find_package(Resolved QUIET)
@@ -28,4 +31,6 @@ foreach(path "/does_not_exist" "/PackageRoot" "")
find_package(ResolvedC NO_SYSTEM_ENVIRONMENT_PATH QUIET)
message(STATUS "Resolved_FOUND='${ResolvedC_FOUND}'")
endforeach()
+
+set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}")
set(ENV{PATH} "${ENV_PATH}")