1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 19:08:07 +08:00

cmFindCommon: use DebugModeEnabled to query for debug mode

This simplifies changing how debug mode is represented.
This commit is contained in:
Ben Boeckel
2025-04-09 14:11:59 +02:00
parent 76ea613f4c
commit bd5cb1f8e6
4 changed files with 28 additions and 28 deletions

View File

@@ -660,7 +660,7 @@ cmFindBaseDebugState::~cmFindBaseDebugState()
}
#endif
if (!this->FindCommand->DebugMode) {
if (!this->FindCommand->DebugModeEnabled()) {
return;
}

View File

@@ -226,14 +226,14 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths,
return;
}
if (this->DebugMode && debugBuffer) {
if (this->DebugModeEnabled() && debugBuffer) {
*debugBuffer = cmStrCat(
*debugBuffer, "Prepending the following roots to each prefix:\n");
}
auto debugRoot = [this, debugBuffer](std::string const& name,
cmValue value) {
if (this->DebugMode && debugBuffer) {
if (this->DebugModeEnabled() && debugBuffer) {
*debugBuffer = cmStrCat(*debugBuffer, name, '\n');
cmList roots{ value };
if (roots.empty()) {

View File

@@ -85,7 +85,7 @@ void cmFindLibraryCommand::AddArchitecturePaths(char const* suffix)
original.swap(this->SearchPaths);
for (std::string const& o : original) {
this->AddArchitecturePath(o, 0, suffix);
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string msg = cmStrCat(
"find_library(", this->VariableName, ") removed original suffix ", o,
" from PATH_SUFFIXES while adding architecture paths for suffix '",
@@ -153,7 +153,7 @@ void cmFindLibraryCommand::AddArchitecturePath(
if (use_dirX) {
dirX += "/";
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string msg = cmStrCat(
"find_library(", this->VariableName, ") added replacement path ",
dirX, " to PATH_SUFFIXES for architecture suffix '", suffix, "'");
@@ -164,7 +164,7 @@ void cmFindLibraryCommand::AddArchitecturePath(
if (use_dir) {
this->SearchPaths.push_back(dir);
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string msg = cmStrCat(
"find_library(", this->VariableName, ") added replacement path ",
dir, " to PATH_SUFFIXES for architecture suffix '", suffix, "'");

View File

@@ -1073,12 +1073,12 @@ bool cmFindPackageCommand::FindPackage(
cmState::Command const providerCommand = state->GetDependencyProviderCommand(
cmDependencyProvider::Method::FindPackage);
if (argsForProvider.empty()) {
if (this->DebugMode && providerCommand) {
if (this->DebugModeEnabled() && providerCommand) {
this->DebugMessage(
"BYPASS_PROVIDER given, skipping dependency provider");
}
} else if (providerCommand) {
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
this->DebugMessage(cmStrCat("Trying dependency provider command: ",
state->GetDependencyProvider()->GetCommand(),
"()"));
@@ -1095,7 +1095,7 @@ bool cmFindPackageCommand::FindPackage(
return false;
}
if (this->Makefile->IsOn(cmStrCat(this->Name, "_FOUND"))) {
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
this->DebugMessage("Package was found by the dependency provider");
}
this->AppendSuccessInformation();
@@ -1447,8 +1447,8 @@ bool cmFindPackageCommand::FindModule(bool& found)
std::string debugBuffer = cmStrCat(
"find_package considered the following paths for ", moduleFileName, ":\n");
std::string mfile = this->Makefile->GetModulesFile(
moduleFileName, system, this->DebugMode, debugBuffer);
if (this->DebugMode) {
moduleFileName, system, this->DebugModeEnabled(), debugBuffer);
if (this->DebugModeEnabled()) {
if (mfile.empty()) {
debugBuffer = cmStrCat(debugBuffer, "The file was not found.\n");
} else {
@@ -1487,7 +1487,7 @@ bool cmFindPackageCommand::FindModule(bool& found)
bool result = this->ReadListFile(mfile, DoPolicyScope);
this->Makefile->RemoveDefinition(var);
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string const foundVar = cmStrCat(this->Name, "_FOUND");
if (this->Makefile->IsDefinitionSet(foundVar) &&
!this->Makefile->IsOn(foundVar)) {
@@ -1797,7 +1797,7 @@ bool cmFindPackageCommand::FindConfig()
// Look for the project's configuration file.
bool found = false;
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
this->DebugBuffer = cmStrCat(this->DebugBuffer,
"find_package considered the following "
"locations for ",
@@ -1833,7 +1833,7 @@ bool cmFindPackageCommand::FindConfig()
found = this->FindAppBundleConfig();
}
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
if (found) {
this->DebugBuffer = cmStrCat(
this->DebugBuffer, "The file was found at\n ", this->FileFound, '\n');
@@ -2322,7 +2322,7 @@ void cmFindPackageCommand::FillPrefixesPackageRedirect()
if (redirectDir && !redirectDir->empty()) {
paths.AddPath(*redirectDir);
}
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer =
"The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.\n";
collectPathsForDebug(debugBuffer, paths);
@@ -2342,7 +2342,7 @@ void cmFindPackageCommand::FillPrefixesPackageRoot()
paths.AddPath(path);
}
}
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer = "<PackageName>_ROOT CMake variable "
"[CMAKE_FIND_USE_PACKAGE_ROOT_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
@@ -2359,7 +2359,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
// Check the environment variable with the same name as the cache
// entry.
paths.AddEnvPath(this->Variable);
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
debugBuffer = cmStrCat("Env variable ", this->Variable,
" [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].\n");
debugOffset = collectPathsForDebug(debugBuffer, paths);
@@ -2367,7 +2367,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
// And now the general CMake environment variables
paths.AddEnvPath("CMAKE_PREFIX_PATH");
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
debugBuffer = cmStrCat(debugBuffer,
"CMAKE_PREFIX_PATH env variable "
"[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].\n");
@@ -2376,7 +2376,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
debugBuffer =
cmStrCat(debugBuffer,
"CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env "
@@ -2393,14 +2393,14 @@ void cmFindPackageCommand::FillPrefixesCMakeVariable()
std::size_t debugOffset = 0;
paths.AddCMakePath("CMAKE_PREFIX_PATH");
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
debugBuffer = "CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].\n";
debugOffset = collectPathsForDebug(debugBuffer, paths);
}
paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
debugBuffer =
cmStrCat(debugBuffer,
"CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables "
@@ -2427,7 +2427,7 @@ void cmFindPackageCommand::FillPrefixesSystemEnvironment()
paths.AddPath(i);
}
}
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer = "Standard system environment variables "
"[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
@@ -2456,7 +2456,7 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
this->LabeledPaths[PathLabel::UserRegistry]);
}
#endif
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer =
"CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].\n";
collectPathsForDebug(debugBuffer,
@@ -2475,7 +2475,7 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
this->LoadPackageRegistryWinSystem();
#endif
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer =
"CMake System Package Registry "
"[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].\n";
@@ -2679,7 +2679,7 @@ void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer = "CMake variables defined in the Platform file "
"[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
@@ -2694,7 +2694,7 @@ void cmFindPackageCommand::FillPrefixesUserGuess()
for (std::string const& p : this->UserGuessArgs) {
paths.AddUserPath(p);
}
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer =
"Paths specified by the find_package PATHS option.\n";
collectPathsForDebug(debugBuffer, paths);
@@ -2709,7 +2709,7 @@ void cmFindPackageCommand::FillPrefixesUserHints()
for (std::string const& p : this->UserHintsArgs) {
paths.AddUserPath(p);
}
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
std::string debugBuffer =
"Paths specified by the find_package HINTS option.\n";
collectPathsForDebug(debugBuffer, paths);
@@ -2764,7 +2764,7 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
continue;
}
file = cmStrCat(dir, '/', config.Name);
if (this->DebugMode) {
if (this->DebugModeEnabled()) {
this->DebugBuffer = cmStrCat(this->DebugBuffer, " ", file, '\n');
}
if (cmSystemTools::FileExists(file, true) && this->CheckVersion(file)) {