mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
find_package: Improve --debug-find-pkg= when using a find module
Extend the feature added by commit d7b18895bc (cmake: Add filtered
debug-find options, 2021-12-07, v3.23.0-rc1~217^2) to enable debug
output for `find_*` calls within a find module or cmake package
configuration file.
Fixes: #23211
This commit is contained in:
@@ -73,7 +73,8 @@ void cmFindCommon::DebugMessage(std::string const& msg) const
|
||||
|
||||
bool cmFindCommon::ComputeIfDebugModeWanted()
|
||||
{
|
||||
return this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE") ||
|
||||
return this->Makefile->GetDebugFindPkgMode() ||
|
||||
this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE") ||
|
||||
this->Makefile->GetCMakeInstance()->GetDebugFindOutput();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmValue.h"
|
||||
#include "cmVersion.h"
|
||||
#include "cmake.h"
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
# include <FindDirectory.h>
|
||||
@@ -235,8 +234,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
|
||||
this->SearchPathSuffixes.emplace_back();
|
||||
|
||||
// Process debug mode
|
||||
this->DebugMode = this->ComputeIfDebugModeWanted() ||
|
||||
this->Makefile->GetCMakeInstance()->GetDebugFindPkgOutput(this->Name);
|
||||
cmMakefile::DebugFindPkgRAII debugFindPkgRAII(this->Makefile, this->Name);
|
||||
this->DebugMode = this->ComputeIfDebugModeWanted();
|
||||
|
||||
// Parse the arguments.
|
||||
enum Doing
|
||||
|
||||
@@ -4519,3 +4519,22 @@ cmMakefile::MacroPushPop::~MacroPushPop()
|
||||
{
|
||||
this->Makefile->PopMacroScope(this->ReportError);
|
||||
}
|
||||
|
||||
cmMakefile::DebugFindPkgRAII::DebugFindPkgRAII(cmMakefile* mf,
|
||||
std::string const& pkg)
|
||||
: Makefile(mf)
|
||||
, OldValue(this->Makefile->DebugFindPkg)
|
||||
{
|
||||
this->Makefile->DebugFindPkg =
|
||||
this->Makefile->GetCMakeInstance()->GetDebugFindPkgOutput(pkg);
|
||||
}
|
||||
|
||||
cmMakefile::DebugFindPkgRAII::~DebugFindPkgRAII()
|
||||
{
|
||||
this->Makefile->DebugFindPkg = this->OldValue;
|
||||
}
|
||||
|
||||
bool cmMakefile::GetDebugFindPkgMode() const
|
||||
{
|
||||
return this->DebugFindPkg;
|
||||
}
|
||||
|
||||
@@ -931,6 +931,18 @@ public:
|
||||
// searches
|
||||
std::deque<std::vector<std::string>> FindPackageRootPathStack;
|
||||
|
||||
class DebugFindPkgRAII
|
||||
{
|
||||
cmMakefile* Makefile;
|
||||
bool OldValue;
|
||||
|
||||
public:
|
||||
DebugFindPkgRAII(cmMakefile* mf, std::string const& pkg);
|
||||
~DebugFindPkgRAII();
|
||||
};
|
||||
|
||||
bool GetDebugFindPkgMode() const;
|
||||
|
||||
void MaybeWarnCMP0074(std::string const& pkg);
|
||||
void MaybeWarnUninitialized(std::string const& variable,
|
||||
const char* sourceFilename) const;
|
||||
@@ -1104,6 +1116,8 @@ private:
|
||||
std::vector<BT<GeneratorAction>> GeneratorActions;
|
||||
bool GeneratorActionsInvoked = false;
|
||||
|
||||
bool DebugFindPkg = false;
|
||||
|
||||
bool CheckSystemVars;
|
||||
bool CheckCMP0000;
|
||||
std::set<std::string> WarnedCMP0074;
|
||||
|
||||
128
Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt
Normal file
128
Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt
Normal file
@@ -0,0 +1,128 @@
|
||||
^CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_program\):
|
||||
find_program called with the following settings:
|
||||
|
||||
VAR: FOO_EXE
|
||||
NAMES: "ModuleModeDebugPkgFooExe"
|
||||
Documentation: Path to a program.
|
||||
Framework
|
||||
Only Search Frameworks: 0
|
||||
Search Frameworks Last: 0
|
||||
Search Frameworks First: [01]
|
||||
AppBundle
|
||||
Only Search AppBundle: 0
|
||||
Search AppBundle Last: 0
|
||||
Search AppBundle First: [01]
|
||||
NO_DEFAULT_PATH Enabled
|
||||
|
||||
find_program considered the following locations:
|
||||
|
||||
The item was not found.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
+
|
||||
CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_library\):
|
||||
find_library called with the following settings:
|
||||
|
||||
VAR: FOO_LIB
|
||||
NAMES: "ModuleModeDebugPkgFooLib"
|
||||
Documentation: Path to a library.
|
||||
Framework
|
||||
Only Search Frameworks: 0
|
||||
Search Frameworks Last: 0
|
||||
Search Frameworks First: [01]
|
||||
AppBundle
|
||||
Only Search AppBundle: 0
|
||||
Search AppBundle Last: 0
|
||||
Search AppBundle First: [01]
|
||||
NO_DEFAULT_PATH Enabled
|
||||
|
||||
find_library considered the following locations:
|
||||
|
||||
The item was not found.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
+
|
||||
CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_path\):
|
||||
find_path called with the following settings:
|
||||
|
||||
VAR: FOO_PATH
|
||||
NAMES: "ModuleModeDebugPkgFoo.h"
|
||||
Documentation: Path to a file.
|
||||
Framework
|
||||
Only Search Frameworks: 0
|
||||
Search Frameworks Last: 0
|
||||
Search Frameworks First: [01]
|
||||
AppBundle
|
||||
Only Search AppBundle: 0
|
||||
Search AppBundle Last: 0
|
||||
Search AppBundle First: [01]
|
||||
NO_DEFAULT_PATH Enabled
|
||||
|
||||
find_path considered the following locations:
|
||||
|
||||
The item was not found.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
+
|
||||
CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_file\):
|
||||
find_file called with the following settings:
|
||||
|
||||
VAR: FOO_FILE
|
||||
NAMES: "ModuleModeDebugPkgFoo.h"
|
||||
Documentation: Path to a file.
|
||||
Framework
|
||||
Only Search Frameworks: 0
|
||||
Search Frameworks Last: 0
|
||||
Search Frameworks First: [01]
|
||||
AppBundle
|
||||
Only Search AppBundle: 0
|
||||
Search AppBundle Last: 0
|
||||
Search AppBundle First: [01]
|
||||
NO_DEFAULT_PATH Enabled
|
||||
|
||||
find_file considered the following locations:
|
||||
|
||||
The item was not found.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
+
|
||||
FindBar processed here.
|
||||
+
|
||||
CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_package\):
|
||||
Paths specified by the find_package HINTS option.
|
||||
|
||||
none
|
||||
|
||||
Paths specified by the find_package PATHS option.
|
||||
|
||||
none
|
||||
|
||||
find_package considered the following locations for Zot's Config module:
|
||||
|
||||
The file was not found.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
+
|
||||
CMake Debug Log at ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\):
|
||||
find_package considered the following paths for FindFoo.cmake:
|
||||
|
||||
[^
|
||||
]*/Modules/FindFoo.cmake
|
||||
|
||||
The file was found at
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindFoo.cmake
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
2
Tests/RunCMake/find_package/ModuleModeDebugPkg.cmake
Normal file
2
Tests/RunCMake/find_package/ModuleModeDebugPkg.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ModuleModeDebugPkg)
|
||||
find_package(Foo)
|
||||
@@ -0,0 +1,2 @@
|
||||
message("FindBar processed here.\n")
|
||||
find_program(BAR_EXE NAMES ModuleModeDebugPkgBarExe NO_DEFAULT_PATH)
|
||||
@@ -0,0 +1,6 @@
|
||||
find_program(FOO_EXE NAMES ModuleModeDebugPkgFooExe NO_DEFAULT_PATH)
|
||||
find_library(FOO_LIB NAMES ModuleModeDebugPkgFooLib NO_DEFAULT_PATH)
|
||||
find_path(FOO_PATH NAMES ModuleModeDebugPkgFoo.h NO_DEFAULT_PATH)
|
||||
find_file(FOO_FILE NAMES ModuleModeDebugPkgFoo.h NO_DEFAULT_PATH)
|
||||
find_package(Bar) # not included
|
||||
find_package(Zot NO_MODULE NO_DEFAULT_PATH) # is included
|
||||
@@ -21,6 +21,7 @@ run_cmake(MissingConfigOneName)
|
||||
run_cmake(MissingConfigRequired)
|
||||
run_cmake(MissingConfigVersion)
|
||||
run_cmake(MixedModeOptions)
|
||||
run_cmake_with_options(ModuleModeDebugPkg --debug-find-pkg=Foo,Zot)
|
||||
run_cmake(PackageRoot)
|
||||
run_cmake(PackageRootNestedConfig)
|
||||
run_cmake(PackageRootNestedModule)
|
||||
|
||||
Reference in New Issue
Block a user