mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
cmFindCommon: support suppressing implicit event logging
`find_package` has different behavior where not all modes support reliably knowing if a search has already happened in order to not always report failing searches.
This commit is contained in:
@@ -507,6 +507,11 @@ void cmFindCommonDebugState::FailedAt(std::string const& path,
|
||||
this->FailedAtImpl(path, regexName);
|
||||
}
|
||||
|
||||
bool cmFindCommonDebugState::ShouldImplicitlyLogEvents() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmFindCommonDebugState::Write()
|
||||
{
|
||||
auto const* const fc = this->FindCommand;
|
||||
@@ -517,11 +522,13 @@ void cmFindCommonDebugState::Write()
|
||||
fc->Makefile->GetCMakeInstance()->GetConfigureLog()) {
|
||||
// Write event if any of:
|
||||
// - debug mode is enabled
|
||||
// - the variable was not defined (first run)
|
||||
// - the variable found state does not match the new found state (state
|
||||
// transition)
|
||||
if (fc->DebugModeEnabled() || !fc->IsDefined() ||
|
||||
fc->IsFound() != this->IsFound) {
|
||||
// - implicit logging should happen and:
|
||||
// - the variable was not defined (first run)
|
||||
// - the variable found state does not match the new found state (state
|
||||
// transition)
|
||||
if (fc->DebugModeEnabled() ||
|
||||
(this->ShouldImplicitlyLogEvents() &&
|
||||
(!fc->IsDefined() || fc->IsFound() != this->IsFound))) {
|
||||
this->WriteEvent(*log, *fc->Makefile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ protected:
|
||||
virtual void FoundAtImpl(std::string const& path, std::string regexName) = 0;
|
||||
virtual void FailedAtImpl(std::string const& path,
|
||||
std::string regexName) = 0;
|
||||
virtual bool ShouldImplicitlyLogEvents() const;
|
||||
|
||||
virtual void WriteDebug() const = 0;
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
|
||||
Reference in New Issue
Block a user