mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Diagnostics: Switch state to new system
Add an additional state to the cmake instance to track diagnostics. Use
this to initialize any new/reset states we create so that other contexts
will inherit the diagnostic state from presets / command-line options.
Modify the front-end to map presets and -W command-line options to
manipulation of this new diagnostic state. Remove old members for
storing diagnostic state. Rework how diagnostic state is persisted.
Deprecate old, non-standard spellings for manipulating diagnostics.
Deprecate old 'dev' spelling for CMD_AUTHOR.
Note that this is a work in progress. Messaging has not yet been
updated, so the new state is not yet being used to control diagnostics,
and some of the logic to update the old state has been stripped (and
will eventually be removed entirely). Backward compatibility support for
the deprecated CMAKE_{WARN,ERROR}_DEPRECATED variables is only partially
implemented. The GUI's interface for manipulating warnings is partially
broken and needs to be overhauled. These tasks are being done in
separate commits in order to minimize review burden and keep the changes
per commit / per merge request more manageable.
This commit is contained in:
@@ -71,7 +71,7 @@ The CMake tooling may report warnings which are intended
|
||||
for the provider of the software, not intended for the
|
||||
consumer of the software. Such warnings end with "This
|
||||
warning is for project developers". Users may disable
|
||||
such warnings by passing the :option:`-Wno-dev <cmake -Wno-dev>`
|
||||
such warnings by passing the :option:`-Wno-author <cmake -Wno->`
|
||||
flag to :manual:`cmake(1)`.
|
||||
|
||||
cmake-gui tool
|
||||
|
||||
@@ -35,7 +35,7 @@ Diagnostic Actions
|
||||
|
||||
The action taken when a particular diagnostic is triggered depends on the
|
||||
diagnostic category. Most categories will warn by default. The
|
||||
:command:`cmake_diagnostic` command and ``-W`` options can be
|
||||
:command:`cmake_diagnostic` command and :option:`-W <cmake -W>` options can be
|
||||
used to control what action occurs when a diagnostic of a particular category
|
||||
is triggered. The possible actions are described in the documentation of the
|
||||
same.
|
||||
|
||||
@@ -623,22 +623,23 @@ Options
|
||||
|
||||
.. option:: --warn-uninitialized
|
||||
|
||||
Warn about uninitialized values.
|
||||
.. deprecated:: 4.4
|
||||
|
||||
Print a warning when an uninitialized variable is used.
|
||||
Compatibility synonym for ``-Wuninitialized``.
|
||||
|
||||
.. option:: --warn-unused-vars
|
||||
|
||||
.. deprecated:: 3.19
|
||||
|
||||
Does nothing. In CMake versions 3.2 and below this enabled warnings about
|
||||
unused variables. In CMake versions 3.3 through 3.18 the option was broken.
|
||||
In CMake 3.19 and above the option has been removed.
|
||||
|
||||
.. option:: --no-warn-unused-cli
|
||||
|
||||
Don't warn about command line options.
|
||||
.. deprecated:: 4.4
|
||||
|
||||
Don't find variables that are declared on the command line, but not
|
||||
used.
|
||||
Compatibility synonym for ``-Wno-unused-cli``.
|
||||
|
||||
.. option:: --check-system-vars
|
||||
|
||||
|
||||
@@ -138,59 +138,34 @@
|
||||
transition and not for publication of a final product. CMake will always emit
|
||||
a warning when the project file is anything other than ``CMakeLists.txt``.
|
||||
|
||||
.. option:: -Wno-dev
|
||||
.. option:: -W<category>
|
||||
|
||||
Suppress developer warnings.
|
||||
Promote the specified diagnostic category (and any children) to at least
|
||||
``WARN`` severity. Note that this has no effect on diagnostics already set to
|
||||
a higher severity.
|
||||
|
||||
Suppress warnings that are meant for the author of the
|
||||
``CMakeLists.txt`` files. By default this will also turn off
|
||||
deprecation warnings.
|
||||
See the :manual:`cmake-diagnostics(7)` manual for a list of accepted values
|
||||
for ``<category>``.
|
||||
|
||||
.. option:: -Wdev
|
||||
.. option:: -Wno-<category>
|
||||
|
||||
Enable developer warnings.
|
||||
Disable (ignore) all diagnostics of the specified category, including any
|
||||
child categories.
|
||||
|
||||
Enable warnings that are meant for the author of the ``CMakeLists.txt``
|
||||
files. By default this will also turn on deprecation warnings.
|
||||
.. option:: -Werror=<category>
|
||||
|
||||
.. option:: -Wdeprecated
|
||||
Promote the specified diagnostic category (and any children) to at least
|
||||
``SEND_ERROR`` severity. Note that this has no effect on diagnostics already
|
||||
set to a higher severity.
|
||||
|
||||
Enable deprecated functionality warnings.
|
||||
.. option:: -Wno-error=<category>
|
||||
|
||||
Enable warnings for usage of deprecated functionality, that are meant
|
||||
for the author of the ``CMakeLists.txt`` files.
|
||||
Demote the specified diagnostic category (and any children) to at most
|
||||
``WARN`` severity. Note that this has no effect on diagnostics already
|
||||
set to a lower severity.
|
||||
|
||||
.. option:: -Wno-deprecated
|
||||
.. option:: -Wdev, -Wno-dev
|
||||
|
||||
Suppress deprecated functionality warnings.
|
||||
.. deprecated:: 4.4
|
||||
|
||||
Suppress warnings for usage of deprecated functionality, that are meant
|
||||
for the author of the ``CMakeLists.txt`` files.
|
||||
|
||||
.. option:: -Werror=<what>
|
||||
|
||||
Treat CMake warnings as errors. ``<what>`` must be one of the following:
|
||||
|
||||
``dev``
|
||||
Make developer warnings errors.
|
||||
|
||||
Make warnings that are meant for the author of the ``CMakeLists.txt`` files
|
||||
errors. By default this will also turn on deprecated warnings as errors.
|
||||
|
||||
``deprecated``
|
||||
Make deprecated macro and function warnings errors.
|
||||
|
||||
Make warnings for usage of deprecated macros and functions, that are meant
|
||||
for the author of the ``CMakeLists.txt`` files, errors.
|
||||
|
||||
.. option:: -Wno-error=<what>
|
||||
|
||||
Do not treat CMake warnings as errors. ``<what>`` must be one of the following:
|
||||
|
||||
``dev``
|
||||
Make warnings that are meant for the author of the ``CMakeLists.txt`` files not
|
||||
errors. By default this will also turn off deprecated warnings as errors.
|
||||
|
||||
``deprecated``
|
||||
Make warnings for usage of deprecated macros and functions, that are meant
|
||||
for the author of the ``CMakeLists.txt`` files, not errors.
|
||||
Compatibility synonyms for ``-Wauthor`` / ``-Wno-author``.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
CMAKE_ERROR_DEPRECATED
|
||||
----------------------
|
||||
|
||||
.. deprecated:: 4.4
|
||||
|
||||
Whether to issue errors for deprecated functionality.
|
||||
|
||||
If ``TRUE``, use of deprecated functionality will issue fatal errors.
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
CMAKE_WARN_DEPRECATED
|
||||
---------------------
|
||||
|
||||
.. deprecated:: 4.4
|
||||
|
||||
Whether to issue warnings for deprecated functionality.
|
||||
|
||||
If not ``FALSE``, use of deprecated functionality will issue warnings.
|
||||
If this variable is not set, CMake behaves as if it were set to ``TRUE``.
|
||||
|
||||
When running :manual:`cmake(1)`, this option can be enabled with the
|
||||
:option:`-Wdeprecated <cmake -Wdeprecated>` option, or disabled with the
|
||||
:option:`-Wno-deprecated <cmake -Wno-deprecated>` option.
|
||||
:option:`-Wdeprecated <cmake -W>` option, or disabled with the
|
||||
:option:`-Wno-deprecated <cmake -Wno->` option.
|
||||
|
||||
+30
-21
@@ -11,6 +11,7 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExternalMakefileProjectGenerator.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMessageMetadata.h"
|
||||
@@ -172,18 +173,8 @@ void QCMake::setPreset(QString const& name, bool setBinary)
|
||||
QString::fromStdString(expandedPreset->BinaryDir);
|
||||
this->setBinaryDirectory(binaryDir);
|
||||
}
|
||||
this->CMakeInstance->SetWarningFromPreset(
|
||||
"dev", expandedPreset->Warnings, expandedPreset->Errors,
|
||||
cmDiagnostics::CMD_AUTHOR);
|
||||
this->CMakeInstance->SetWarningFromPreset(
|
||||
"deprecated", expandedPreset->Warnings, expandedPreset->Errors,
|
||||
cmDiagnostics::CMD_DEPRECATED);
|
||||
this->CMakeInstance->SetWarningFromPreset(
|
||||
&cmake::SetWarnUninitialized, expandedPreset->Warnings, true,
|
||||
cmDiagnostics::CMD_UNINITIALIZED);
|
||||
this->CMakeInstance->SetWarningFromPreset(
|
||||
&cmake::SetWarnUnusedCli, expandedPreset->Warnings, false,
|
||||
cmDiagnostics::CMD_UNUSED_CLI);
|
||||
this->CMakeInstance->SetDiagnosticsFromPreset(expandedPreset->Warnings,
|
||||
expandedPreset->Errors);
|
||||
this->Environment = this->StartEnvironment;
|
||||
for (auto const& v : expandedPreset->Environment) {
|
||||
if (v.second) {
|
||||
@@ -250,7 +241,8 @@ void QCMake::configure()
|
||||
this->CMakeInstance->SetGeneratorPlatform(this->Platform.toStdString());
|
||||
this->CMakeInstance->SetGeneratorToolset(this->Toolset.toStdString());
|
||||
this->CMakeInstance->LoadCache();
|
||||
this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
|
||||
// FIXME
|
||||
// this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
|
||||
this->CMakeInstance->PreLoadCMakeFiles();
|
||||
|
||||
InterruptFlag = 0;
|
||||
@@ -661,42 +653,59 @@ bool QCMake::getDebugOutput() const
|
||||
|
||||
bool QCMake::getSuppressDevWarnings()
|
||||
{
|
||||
return this->CMakeInstance->GetSuppressDevWarnings();
|
||||
cmDiagnosticAction const action =
|
||||
this->CMakeInstance->GetCurrentSnapshot().GetDiagnostic(
|
||||
cmDiagnostics::CMD_AUTHOR);
|
||||
return action == cmDiagnostics::Ignore;
|
||||
}
|
||||
|
||||
void QCMake::setSuppressDevWarnings(bool value)
|
||||
{
|
||||
this->CMakeInstance->SetSuppressDevWarnings(value);
|
||||
// FIXME
|
||||
// this->CMakeInstance->GetCurrentSnapshot().DemoteDiagnostic();
|
||||
// SetSuppressDevWarnings(value);
|
||||
}
|
||||
|
||||
bool QCMake::getSuppressDeprecatedWarnings()
|
||||
{
|
||||
return this->CMakeInstance->GetSuppressDeprecatedWarnings();
|
||||
cmDiagnosticAction const action =
|
||||
this->CMakeInstance->GetCurrentSnapshot().GetDiagnostic(
|
||||
cmDiagnostics::CMD_DEPRECATED);
|
||||
return action == cmDiagnostics::Ignore;
|
||||
}
|
||||
|
||||
void QCMake::setSuppressDeprecatedWarnings(bool value)
|
||||
{
|
||||
this->CMakeInstance->SetSuppressDeprecatedWarnings(value);
|
||||
// FIXME
|
||||
// this->CMakeInstance->SetSuppressDeprecatedWarnings(value);
|
||||
}
|
||||
|
||||
bool QCMake::getDevWarningsAsErrors()
|
||||
{
|
||||
return this->CMakeInstance->GetDevWarningsAsErrors();
|
||||
cmDiagnosticAction const action =
|
||||
this->CMakeInstance->GetCurrentSnapshot().GetDiagnostic(
|
||||
cmDiagnostics::CMD_AUTHOR);
|
||||
return action >= cmDiagnostics::SendError;
|
||||
}
|
||||
|
||||
void QCMake::setDevWarningsAsErrors(bool value)
|
||||
{
|
||||
this->CMakeInstance->SetDevWarningsAsErrors(value);
|
||||
// FIXME
|
||||
// this->CMakeInstance->SetDevWarningsAsErrors(value);
|
||||
}
|
||||
|
||||
bool QCMake::getDeprecatedWarningsAsErrors()
|
||||
{
|
||||
return this->CMakeInstance->GetDeprecatedWarningsAsErrors();
|
||||
cmDiagnosticAction const action =
|
||||
this->CMakeInstance->GetCurrentSnapshot().GetDiagnostic(
|
||||
cmDiagnostics::CMD_DEPRECATED);
|
||||
return action >= cmDiagnostics::SendError;
|
||||
}
|
||||
|
||||
void QCMake::setDeprecatedWarningsAsErrors(bool value)
|
||||
{
|
||||
this->CMakeInstance->SetDeprecatedWarningsAsErrors(value);
|
||||
// FIXME
|
||||
// this->CMakeInstance->SetDeprecatedWarningsAsErrors(value);
|
||||
}
|
||||
|
||||
void QCMake::setWarnUninitializedMode(bool value)
|
||||
|
||||
@@ -1965,7 +1965,9 @@ void cmMakefile::MaybeWarnUninitialized(std::string const& variable,
|
||||
// check to see if we need to print a warning
|
||||
// if strict mode is on and the variable has
|
||||
// not been "cleared"/initialized with a set(foo ) call
|
||||
if (this->GetCMakeInstance()->GetWarnUninitialized() &&
|
||||
cmDiagnosticAction const action =
|
||||
this->GetDiagnosticAction(cmDiagnostics::CMD_UNINITIALIZED);
|
||||
if (action != cmDiagnostics::Ignore &&
|
||||
!this->VariableInitialized(variable)) {
|
||||
if (this->CheckSystemVars ||
|
||||
(sourceFilename && this->IsProjectFile(sourceFilename))) {
|
||||
@@ -3317,7 +3319,7 @@ int cmMakefile::TryCompile(std::string const& srcdir,
|
||||
if (cmakeArgs) {
|
||||
// FIXME: Workaround to ignore unused CLI variables in try-compile.
|
||||
//
|
||||
// Ideally we should use SetArgs for options like --no-warn-unused-cli.
|
||||
// Ideally we should use SetArgs for options like -Wno-unused-cli.
|
||||
// However, there is a subtle problem when certain arguments are passed to
|
||||
// a macro wrapping around try_compile or try_run that does not escape
|
||||
// semicolons in its parameters but just passes ${ARGV} or ${ARGN}. In
|
||||
@@ -3336,8 +3338,9 @@ int cmMakefile::TryCompile(std::string const& srcdir,
|
||||
// the value VAR=a is sufficient for the try_compile or try_run to get the
|
||||
// correct result. Calling SetArgs here would break such projects that
|
||||
// previously built. Instead we work around the issue by never reporting
|
||||
// unused arguments and ignoring options such as --no-warn-unused-cli.
|
||||
cm.SetWarnUnusedCli(false);
|
||||
// unused arguments and ignoring options such as -Wno-unused-cli.
|
||||
cm.GetCurrentSnapshot().SetDiagnostic(cmDiagnostics::CMD_UNUSED_CLI,
|
||||
cmDiagnostics::Ignore, true);
|
||||
// cm.SetArgs(*cmakeArgs, true);
|
||||
|
||||
cm.SetCacheArgs(*cmakeArgs);
|
||||
|
||||
+28
-20
@@ -114,16 +114,20 @@ bool cmMessageCommand(std::vector<std::string> const& args,
|
||||
level = Message::LogLevel::LOG_WARNING;
|
||||
++i;
|
||||
} else if (*i == "AUTHOR_WARNING") {
|
||||
if (mf.IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
|
||||
!mf.IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
|
||||
fatal = true;
|
||||
type = MessageType::AUTHOR_ERROR;
|
||||
level = Message::LogLevel::LOG_ERROR;
|
||||
} else if (!mf.IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
|
||||
type = MessageType::AUTHOR_WARNING;
|
||||
level = Message::LogLevel::LOG_WARNING;
|
||||
} else {
|
||||
return true;
|
||||
switch (mf.GetDiagnosticAction(cmDiagnostics::CMD_AUTHOR)) {
|
||||
case cmDiagnostics::Ignore:
|
||||
return true;
|
||||
case cmDiagnostics::FatalError:
|
||||
fatal = true;
|
||||
CM_FALLTHROUGH;
|
||||
case cmDiagnostics::SendError:
|
||||
type = MessageType::AUTHOR_ERROR;
|
||||
level = Message::LogLevel::LOG_ERROR;
|
||||
break;
|
||||
default:
|
||||
type = MessageType::AUTHOR_WARNING;
|
||||
level = Message::LogLevel::LOG_WARNING;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
} else if (*i == "CHECK_START") {
|
||||
@@ -159,16 +163,20 @@ bool cmMessageCommand(std::vector<std::string> const& args,
|
||||
level = Message::LogLevel::LOG_TRACE;
|
||||
++i;
|
||||
} else if (*i == "DEPRECATION") {
|
||||
if (mf.IsOn("CMAKE_ERROR_DEPRECATED")) {
|
||||
fatal = true;
|
||||
type = MessageType::DEPRECATION_ERROR;
|
||||
level = Message::LogLevel::LOG_ERROR;
|
||||
} else if (!mf.IsSet("CMAKE_WARN_DEPRECATED") ||
|
||||
mf.IsOn("CMAKE_WARN_DEPRECATED")) {
|
||||
type = MessageType::DEPRECATION_WARNING;
|
||||
level = Message::LogLevel::LOG_WARNING;
|
||||
} else {
|
||||
return true;
|
||||
switch (mf.GetDiagnosticAction(cmDiagnostics::CMD_DEPRECATED)) {
|
||||
case cmDiagnostics::Ignore:
|
||||
return true;
|
||||
case cmDiagnostics::FatalError:
|
||||
fatal = true;
|
||||
CM_FALLTHROUGH;
|
||||
case cmDiagnostics::SendError:
|
||||
type = MessageType::DEPRECATION_ERROR;
|
||||
level = Message::LogLevel::LOG_ERROR;
|
||||
break;
|
||||
default:
|
||||
type = MessageType::DEPRECATION_WARNING;
|
||||
level = Message::LogLevel::LOG_WARNING;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
} else if (*i == "NOTICE") {
|
||||
|
||||
+12
-3
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "cmCacheManager.h"
|
||||
#include "cmDefinitions.h"
|
||||
#include "cmDiagnostics.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGlobCacheEntry.h" // IWYU pragma: keep
|
||||
#include "cmGlobVerificationManager.h"
|
||||
@@ -274,8 +275,12 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
|
||||
this->CacheManager->RemoveCacheEntryProperty(key, propertyName);
|
||||
}
|
||||
|
||||
cmStateSnapshot cmState::Reset()
|
||||
cmStateSnapshot cmState::Reset(cmStateSnapshot const& diagnosticState)
|
||||
{
|
||||
assert(diagnosticState.CanPopDiagnosticScope());
|
||||
cmDiagnostics::DiagnosticMap diagnostics =
|
||||
*diagnosticState.Position->Diagnostics;
|
||||
|
||||
this->GlobalProperties.Clear();
|
||||
this->PropertyDefinitions = {};
|
||||
this->GlobVerificationManager->Reset();
|
||||
@@ -302,11 +307,13 @@ cmStateSnapshot cmState::Reset()
|
||||
assert(pos->PolicyRoot.IsValid());
|
||||
|
||||
this->DiagnosticStack.Clear();
|
||||
pos->Diagnostics = this->DiagnosticStack.Root();
|
||||
pos->Diagnostics = this->DiagnosticStack.Push(this->DiagnosticStack.Root(),
|
||||
{ diagnostics, false });
|
||||
pos->DiagnosticRoot = this->DiagnosticStack.Root();
|
||||
pos->DiagnosticScope = this->DiagnosticStack.Root();
|
||||
assert(pos->Diagnostics.IsValid());
|
||||
assert(pos->DiagnosticRoot.IsValid());
|
||||
assert(pos->Diagnostics != pos->DiagnosticRoot);
|
||||
|
||||
{
|
||||
std::string srcDir =
|
||||
@@ -893,11 +900,13 @@ cmStateSnapshot cmState::CreateBaseSnapshot()
|
||||
pos->PolicyScope = this->PolicyStack.Root();
|
||||
assert(pos->Policies.IsValid());
|
||||
assert(pos->PolicyRoot.IsValid());
|
||||
pos->Diagnostics = this->DiagnosticStack.Root();
|
||||
pos->Diagnostics =
|
||||
this->DiagnosticStack.Push(this->DiagnosticStack.Root(), { {}, false });
|
||||
pos->DiagnosticRoot = this->DiagnosticStack.Root();
|
||||
pos->DiagnosticScope = this->DiagnosticStack.Root();
|
||||
assert(pos->Diagnostics.IsValid());
|
||||
assert(pos->DiagnosticRoot.IsValid());
|
||||
assert(pos->Diagnostics != pos->DiagnosticRoot);
|
||||
pos->Vars = this->VarTree.Push(this->VarTree.Root());
|
||||
assert(pos->Vars.IsValid());
|
||||
pos->Parent = this->VarTree.Root();
|
||||
|
||||
+2
-1
@@ -138,7 +138,6 @@ public:
|
||||
std::string& value,
|
||||
cmStateEnums::CacheEntryType& type);
|
||||
|
||||
cmStateSnapshot Reset();
|
||||
// Define a property
|
||||
void DefineProperty(std::string const& name, cmProperty::ScopeType scope,
|
||||
std::string const& ShortDescription,
|
||||
@@ -260,6 +259,8 @@ public:
|
||||
|
||||
private:
|
||||
friend class cmake;
|
||||
cmStateSnapshot Reset(cmStateSnapshot const& diagnosticState);
|
||||
|
||||
void AddCacheEntry(std::string const& key, cmValue value,
|
||||
std::string const& helpString,
|
||||
cmStateEnums::CacheEntryType type);
|
||||
|
||||
+232
-273
@@ -178,6 +178,19 @@ void cmWarnUnusedCliWarning(std::string const& variable, int /*unused*/,
|
||||
}
|
||||
#endif
|
||||
|
||||
void warnDeprecated(cm::string_view oldOption, cm::string_view newOption)
|
||||
{
|
||||
std::cerr << "The "_s << oldOption << " option is deprecated. Use "_s
|
||||
<< newOption << " instead.\n"_s;
|
||||
}
|
||||
|
||||
std::string normalizeCliWarningName(cm::string_view cliName)
|
||||
{
|
||||
std::string out = cmStrCat("CMD_"_s, cmSystemTools::UpperCase(cliName));
|
||||
std::replace(out.begin(), out.end(), '-', '_');
|
||||
return out;
|
||||
}
|
||||
|
||||
bool cmakeCheckStampFile(std::string const& stampName)
|
||||
{
|
||||
// The stamp file does not exist. Use the stamp dependencies to
|
||||
@@ -270,9 +283,16 @@ bool cmakeCheckStampList(std::string const& stampList)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isDiagnosticSet(cmStateSnapshot const& state,
|
||||
cmDiagnosticCategory category)
|
||||
{
|
||||
constexpr cmDiagnosticAction unset = cmDiagnostics::Undefined;
|
||||
return (state.GetDiagnostic(category, unset) == unset);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
cmDocumentationEntry cmake::CMAKE_STANDARD_OPTIONS_TABLE[19] = {
|
||||
cmDocumentationEntry cmake::CMAKE_STANDARD_OPTIONS_TABLE[15] = {
|
||||
{ "-S <path-to-source>", "Explicitly specify a source directory." },
|
||||
{ "-B <path-to-build>", "Explicitly specify a build directory." },
|
||||
{ "-C <initial-cache>", "Pre-load a script to populate the cache." },
|
||||
@@ -286,18 +306,11 @@ cmDocumentationEntry cmake::CMAKE_STANDARD_OPTIONS_TABLE[19] = {
|
||||
"Specify install directory [CMAKE_INSTALL_PREFIX]." },
|
||||
{ "--project-file <project-file-name>",
|
||||
"Specify an alternate project file name." },
|
||||
{ "-Wdev", "Enable developer warnings." },
|
||||
{ "-Wno-dev", "Suppress developer warnings." },
|
||||
{ "-Werror=dev", "Make developer warnings errors." },
|
||||
{ "-Wno-error=dev", "Make developer warnings not errors." },
|
||||
{ "-Wdeprecated", "Enable deprecation warnings." },
|
||||
{ "-Wno-deprecated", "Suppress deprecation warnings." },
|
||||
{ "-Werror=deprecated",
|
||||
"Make deprecated macro and function warnings "
|
||||
"errors." },
|
||||
{ "-Wno-error=deprecated",
|
||||
"Make deprecated macro and function warnings "
|
||||
"not errors." }
|
||||
{ "-W<category>", "Enable the specified category of warnings." },
|
||||
{ "-Wno-<category>", "Suppress the specified category of warnings." },
|
||||
{ "-Werror=<category>", "Make the specified category of warnings errors." },
|
||||
{ "-Wno-error=<category>",
|
||||
"Make the specified category of warnings not errors." },
|
||||
};
|
||||
|
||||
cmake::cmake(cmState::Role role, cmState::TryCompile isTryCompile)
|
||||
@@ -472,7 +485,7 @@ cmake::CommandFailureAction cmake::GetCommandFailureAction() const
|
||||
|
||||
void cmake::CleanupCommandsAndMacros()
|
||||
{
|
||||
this->CurrentSnapshot = this->State->Reset();
|
||||
this->CurrentSnapshot = this->State->Reset(this->CurrentSnapshot);
|
||||
this->State->RemoveUserDefinedCommands();
|
||||
this->CurrentSnapshot.SetDefaultDefinitions();
|
||||
// FIXME: InstalledFiles probably belongs in the global generator.
|
||||
@@ -480,38 +493,28 @@ void cmake::CleanupCommandsAndMacros()
|
||||
}
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
using DiagnosticMap = std::map<cmDiagnosticCategory, bool>;
|
||||
|
||||
void cmake::SetWarningFromPreset(std::string const& name,
|
||||
DiagnosticMap const& warnings,
|
||||
DiagnosticMap const& errors,
|
||||
cmDiagnosticCategory key)
|
||||
void cmake::SetDiagnosticsFromPreset(
|
||||
std::map<cmDiagnosticCategory, bool> const& warnings,
|
||||
std::map<cmDiagnosticCategory, bool> const& errors)
|
||||
{
|
||||
auto const wi = warnings.find(key);
|
||||
if (wi != warnings.end()) {
|
||||
if (wi->second) {
|
||||
this->DiagLevels[name] = std::max(this->DiagLevels[name], DIAG_WARN);
|
||||
for (auto const& wi : warnings) {
|
||||
if (wi.second) {
|
||||
this->CurrentSnapshot.PromoteDiagnostic( // clang-format: break
|
||||
wi.first, cmDiagnostics::Warn, true);
|
||||
} else {
|
||||
this->DiagLevels[name] = DIAG_IGNORE;
|
||||
this->CurrentSnapshot.DemoteDiagnostic( // clang-format: break
|
||||
wi.first, cmDiagnostics::Ignore, true);
|
||||
}
|
||||
}
|
||||
auto const ei = errors.find(key);
|
||||
if (ei != errors.end()) {
|
||||
if (ei->second) {
|
||||
this->DiagLevels[name] = DIAG_ERROR;
|
||||
} else {
|
||||
this->DiagLevels[name] = std::min(this->DiagLevels[name], DIAG_WARN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmake::SetWarningFromPreset(void (cmake::*func)(bool),
|
||||
DiagnosticMap const& warnings,
|
||||
bool allowedValue, cmDiagnosticCategory key)
|
||||
{
|
||||
auto const wi = warnings.find(key);
|
||||
if (wi != warnings.end() && wi->second == allowedValue) {
|
||||
(this->*func)(wi->second);
|
||||
for (auto const& ei : errors) {
|
||||
if (ei.second) {
|
||||
this->CurrentSnapshot.PromoteDiagnostic( // clang-format: break
|
||||
ei.first, cmDiagnostics::SendError, true);
|
||||
} else {
|
||||
this->CurrentSnapshot.DemoteDiagnostic( // clang-format: break
|
||||
ei.first, cmDiagnostics::Warn, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,44 +623,51 @@ bool cmake::SetCacheArgs(std::vector<std::string> const& args)
|
||||
return true;
|
||||
};
|
||||
|
||||
auto WarningLambda = [](cm::string_view entry, cmake* state) -> bool {
|
||||
auto WarningLambda = [](cm::string_view option, cmake* state) -> bool {
|
||||
bool foundNo = false;
|
||||
bool foundError = false;
|
||||
|
||||
if (cmHasLiteralPrefix(entry, "no-")) {
|
||||
cm::string_view cname = option;
|
||||
if (cmHasLiteralPrefix(cname, "no-")) {
|
||||
foundNo = true;
|
||||
entry.remove_prefix(3);
|
||||
cname.remove_prefix(3);
|
||||
}
|
||||
|
||||
if (cmHasLiteralPrefix(entry, "error=")) {
|
||||
if (cmHasLiteralPrefix(cname, "error=")) {
|
||||
foundError = true;
|
||||
entry.remove_prefix(6);
|
||||
cname.remove_prefix(6);
|
||||
}
|
||||
|
||||
if (entry.empty()) {
|
||||
if (cname.empty()) {
|
||||
cmSystemTools::Error("No warning name provided.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const name = std::string(entry);
|
||||
if (!foundNo && !foundError) {
|
||||
// -W<name>
|
||||
state->DiagLevels[name] = std::max(state->DiagLevels[name], DIAG_WARN);
|
||||
} else if (foundNo && !foundError) {
|
||||
// -Wno<name>
|
||||
state->DiagLevels[name] = DIAG_IGNORE;
|
||||
} else if (!foundNo && foundError) {
|
||||
// -Werror=<name>
|
||||
state->DiagLevels[name] = DIAG_ERROR;
|
||||
cm::optional<cmDiagnosticCategory> category;
|
||||
if (cname == "dev"_s) {
|
||||
warnDeprecated(
|
||||
option,
|
||||
cmStrCat("-W"_s, option.substr(0, option.size() - 3), "author"_s));
|
||||
category = cmDiagnostics::CMD_AUTHOR;
|
||||
} else {
|
||||
// -Wno-error=<name>
|
||||
// This can downgrade an error to a warning, but should not enable
|
||||
// or disable a warning in the first place.
|
||||
auto dli = state->DiagLevels.find(name);
|
||||
if (dli != state->DiagLevels.end()) {
|
||||
dli->second = std::min(dli->second, DIAG_WARN);
|
||||
category =
|
||||
cmDiagnostics::GetDiagnosticCategory(normalizeCliWarningName(cname));
|
||||
if (!category) {
|
||||
cmSystemTools::Error(
|
||||
cmStrCat("The warning category \""_s, cname, "\" is not known."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundNo) {
|
||||
state->CurrentSnapshot.DemoteDiagnostic(
|
||||
*category, foundError ? cmDiagnostics::Warn : cmDiagnostics::Ignore,
|
||||
true);
|
||||
} else {
|
||||
state->CurrentSnapshot.PromoteDiagnostic(
|
||||
*category, foundError ? cmDiagnostics::SendError : cmDiagnostics::Warn,
|
||||
true);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -801,12 +811,15 @@ bool cmake::SetCacheArgs(std::vector<std::string> const& args)
|
||||
void cmake::ProcessCacheArg(std::string const& var, std::string const& value,
|
||||
cmStateEnums::CacheEntryType type)
|
||||
{
|
||||
cmDiagnosticAction const warnUnusedCli =
|
||||
this->CurrentSnapshot.GetDiagnostic(cmDiagnostics::CMD_UNUSED_CLI);
|
||||
|
||||
// The value is transformed if it is a filepath for example, so
|
||||
// we can't compare whether the value is already in the cache until
|
||||
// after we call AddCacheEntry.
|
||||
bool haveValue = false;
|
||||
std::string cachedValue;
|
||||
if (this->WarnUnusedCli) {
|
||||
if (warnUnusedCli != cmDiagnostics::Ignore) {
|
||||
if (cmValue v = this->State->GetInitializedCacheValue(var)) {
|
||||
haveValue = true;
|
||||
cachedValue = *v;
|
||||
@@ -816,7 +829,7 @@ void cmake::ProcessCacheArg(std::string const& var, std::string const& value,
|
||||
this->AddCacheEntry(
|
||||
var, value, "No help, variable specified on the command line.", type);
|
||||
|
||||
if (this->WarnUnusedCli) {
|
||||
if (warnUnusedCli != cmDiagnostics::Ignore) {
|
||||
if (!haveValue ||
|
||||
cachedValue != *this->State->GetInitializedCacheValue(var)) {
|
||||
this->WatchUnusedCli(var);
|
||||
@@ -839,7 +852,7 @@ void cmake::ReadListFile(std::vector<std::string> const& args,
|
||||
|
||||
// read in the list file to fill the cache
|
||||
if (!path.empty()) {
|
||||
this->CurrentSnapshot = this->State->Reset();
|
||||
this->CurrentSnapshot = this->State->Reset(this->CurrentSnapshot);
|
||||
cmStateSnapshot snapshot = this->GetCurrentSnapshot();
|
||||
snapshot.GetDirectory().SetCurrentBinary(this->GetHomeOutputDirectory());
|
||||
snapshot.GetDirectory().SetCurrentSource(this->GetHomeDirectory());
|
||||
@@ -1287,22 +1300,24 @@ void cmake::SetArgs(std::vector<std::string> const& args)
|
||||
state->SetTrace(true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--warn-uninitialized", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
std::cout << "Warn about uninitialized values.\n";
|
||||
state->SetWarnUninitialized(true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{
|
||||
"--warn-uninitialized", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
warnDeprecated("--warn-uninitialized"_s, "-Wuninitialized"_s);
|
||||
state->CurrentSnapshot.PromoteDiagnostic(
|
||||
cmDiagnostics::CMD_UNINITIALIZED, cmDiagnostics::Warn, true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--warn-unused-vars", CommandArgument::Values::Zero,
|
||||
IgnoreAndTrueLambda }, // Option was removed.
|
||||
CommandArgument{ "--no-warn-unused-cli", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
std::cout
|
||||
<< "Not searching for unused variables given on the "
|
||||
"command line.\n";
|
||||
state->SetWarnUnusedCli(false);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{
|
||||
"--no-warn-unused-cli", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
warnDeprecated("--no-warn-unused-cli"_s, "-Wno-unused-cli"_s);
|
||||
state->CurrentSnapshot.DemoteDiagnostic(cmDiagnostics::CMD_UNUSED_CLI,
|
||||
cmDiagnostics::Ignore, true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{
|
||||
"--check-system-vars", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
@@ -2096,18 +2111,8 @@ bool cmake::SetArgsFromPreset(std::string const& presetName,
|
||||
}
|
||||
}
|
||||
|
||||
this->SetWarningFromPreset("dev", expandedPreset->Warnings,
|
||||
expandedPreset->Errors,
|
||||
cmDiagnostics::CMD_AUTHOR);
|
||||
this->SetWarningFromPreset("deprecated", expandedPreset->Warnings,
|
||||
expandedPreset->Errors,
|
||||
cmDiagnostics::CMD_DEPRECATED);
|
||||
this->SetWarningFromPreset(&cmake::SetWarnUninitialized,
|
||||
expandedPreset->Warnings, true,
|
||||
cmDiagnostics::CMD_UNINITIALIZED);
|
||||
this->SetWarningFromPreset(&cmake::SetWarnUnusedCli,
|
||||
expandedPreset->Warnings, false,
|
||||
cmDiagnostics::CMD_UNUSED_CLI);
|
||||
this->SetDiagnosticsFromPreset(expandedPreset->Warnings,
|
||||
expandedPreset->Errors);
|
||||
if (expandedPreset->WarnSystemVars == true) {
|
||||
this->SetCheckSystemVars(true);
|
||||
}
|
||||
@@ -2388,78 +2393,133 @@ int cmake::Configure()
|
||||
auto profilingRAII = this->CreateProfilingEntry("project", "configure");
|
||||
#endif
|
||||
|
||||
DiagLevel diagLevel;
|
||||
// We now need to harmonize the previous initial diagnostic state with any
|
||||
// changes requested via command line options. This is a bit tricky, because
|
||||
// we need to underlay what is specified by the cache beneath whatever state
|
||||
// has been built from command line processing.
|
||||
|
||||
if (this->DiagLevels.count("deprecated") == 1) {
|
||||
cmDiagnosticAction deprecated = this->CurrentSnapshot.GetDiagnostic(
|
||||
cmDiagnostics::CMD_DEPRECATED, cmDiagnostics::Undefined);
|
||||
bool const deprecatedAlreadySet = (deprecated != cmDiagnostics::Undefined);
|
||||
|
||||
diagLevel = this->DiagLevels["deprecated"];
|
||||
if (diagLevel == DIAG_IGNORE) {
|
||||
this->SetSuppressDeprecatedWarnings(true);
|
||||
this->SetDeprecatedWarningsAsErrors(false);
|
||||
} else if (diagLevel == DIAG_WARN) {
|
||||
this->SetSuppressDeprecatedWarnings(false);
|
||||
this->SetDeprecatedWarningsAsErrors(false);
|
||||
} else if (diagLevel == DIAG_ERROR) {
|
||||
this->SetSuppressDeprecatedWarnings(false);
|
||||
this->SetDeprecatedWarningsAsErrors(true);
|
||||
}
|
||||
}
|
||||
if (cmValue cachedDiagnostics =
|
||||
this->State->GetCacheEntryValue("CMAKE_DIAGNOSTIC_INIT")) {
|
||||
for (std::string const& item : cmList{ cachedDiagnostics }) {
|
||||
std::string::size_type n = item.find('=');
|
||||
if (n != std::string::npos) {
|
||||
cm::string_view v = item;
|
||||
cm::optional<cmDiagnosticCategory> const& category =
|
||||
cmDiagnostics::GetDiagnosticCategory(v.substr(0, n));
|
||||
cm::optional<cmDiagnosticAction> const& action =
|
||||
cmDiagnostics::GetDiagnosticAction(v.substr(n + 1));
|
||||
|
||||
if (this->DiagLevels.count("dev") == 1) {
|
||||
bool setDeprecatedVariables = false;
|
||||
|
||||
cmValue cachedWarnDeprecated =
|
||||
this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
|
||||
cmValue cachedErrorDeprecated =
|
||||
this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
|
||||
|
||||
// don't overwrite deprecated warning setting from a previous invocation
|
||||
if (!cachedWarnDeprecated && !cachedErrorDeprecated) {
|
||||
setDeprecatedVariables = true;
|
||||
}
|
||||
|
||||
diagLevel = this->DiagLevels["dev"];
|
||||
if (diagLevel == DIAG_IGNORE) {
|
||||
this->SetSuppressDevWarnings(true);
|
||||
this->SetDevWarningsAsErrors(false);
|
||||
|
||||
if (setDeprecatedVariables) {
|
||||
this->SetSuppressDeprecatedWarnings(true);
|
||||
this->SetDeprecatedWarningsAsErrors(false);
|
||||
}
|
||||
} else if (diagLevel == DIAG_WARN) {
|
||||
this->SetSuppressDevWarnings(false);
|
||||
this->SetDevWarningsAsErrors(false);
|
||||
|
||||
if (setDeprecatedVariables) {
|
||||
this->SetSuppressDeprecatedWarnings(false);
|
||||
this->SetDeprecatedWarningsAsErrors(false);
|
||||
}
|
||||
} else if (diagLevel == DIAG_ERROR) {
|
||||
this->SetSuppressDevWarnings(false);
|
||||
this->SetDevWarningsAsErrors(true);
|
||||
|
||||
if (setDeprecatedVariables) {
|
||||
this->SetSuppressDeprecatedWarnings(false);
|
||||
this->SetDeprecatedWarningsAsErrors(true);
|
||||
if (category && action) {
|
||||
// Only use the cache if command-line options have not modified the
|
||||
// diagnostic.
|
||||
if (isDiagnosticSet(this->CurrentSnapshot, *category)) {
|
||||
this->CurrentSnapshot.SetDiagnostic(*category, *action, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache variables may have already been set by a previous invocation,
|
||||
// so we cannot rely on command line options alone. Always ensure our
|
||||
// messenger is in sync with the cache.
|
||||
cmValue value = this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
|
||||
this->Messenger->SetSuppressDeprecatedWarnings(value && value.IsOff());
|
||||
cmValue cachedWarnDeprecated =
|
||||
this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
|
||||
if (cachedWarnDeprecated) {
|
||||
std::cerr << "The CMAKE_WARN_DEPRECATED variable is deprecated. "
|
||||
"Use CMAKE_DIAGNOSTIC_INIT instead.\n"_s;
|
||||
if (cachedWarnDeprecated.IsOn()) {
|
||||
deprecated = cmDiagnostics::Warn;
|
||||
} else {
|
||||
deprecated = cmDiagnostics::Ignore;
|
||||
}
|
||||
}
|
||||
|
||||
value = this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
|
||||
this->Messenger->SetDeprecatedWarningsAsErrors(value.IsOn());
|
||||
cmValue cachedErrorDeprecated =
|
||||
this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
|
||||
if (cachedErrorDeprecated) {
|
||||
std::cerr << "The CMAKE_ERROR_DEPRECATED variable is deprecated. "
|
||||
"Use CMAKE_DIAGNOSTIC_INIT instead.\n"_s;
|
||||
if (cachedErrorDeprecated.IsOn()) {
|
||||
deprecated = cmDiagnostics::SendError;
|
||||
}
|
||||
}
|
||||
|
||||
value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
||||
this->Messenger->SetSuppressDevWarnings(value.IsOn());
|
||||
if (!deprecatedAlreadySet && deprecated != cmDiagnostics::Undefined) {
|
||||
// CMD_DEPRECATED was not set by command-line options, but was altered by
|
||||
// one or both of CMAKE_{WARN,ERROR}_DEPRECATED.
|
||||
this->CurrentSnapshot.SetDiagnostic(cmDiagnostics::CMD_DEPRECATED,
|
||||
deprecated, false);
|
||||
}
|
||||
|
||||
value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS");
|
||||
this->Messenger->SetDevWarningsAsErrors(value && value.IsOff());
|
||||
// Copy diagnostic state to cmMessenger.
|
||||
switch (this->CurrentSnapshot.GetDiagnostic(cmDiagnostics::CMD_AUTHOR)) {
|
||||
case cmDiagnostics::Ignore:
|
||||
this->Messenger->SetSuppressDevWarnings(true);
|
||||
this->Messenger->SetDevWarningsAsErrors(false);
|
||||
break;
|
||||
case cmDiagnostics::SendError:
|
||||
case cmDiagnostics::FatalError:
|
||||
this->Messenger->SetSuppressDevWarnings(false);
|
||||
this->Messenger->SetDevWarningsAsErrors(true);
|
||||
break;
|
||||
default:
|
||||
this->Messenger->SetSuppressDevWarnings(false);
|
||||
this->Messenger->SetDevWarningsAsErrors(false);
|
||||
break;
|
||||
}
|
||||
switch (this->CurrentSnapshot.GetDiagnostic(cmDiagnostics::CMD_DEPRECATED)) {
|
||||
case cmDiagnostics::Ignore:
|
||||
this->Messenger->SetSuppressDeprecatedWarnings(true);
|
||||
this->Messenger->SetDeprecatedWarningsAsErrors(false);
|
||||
break;
|
||||
case cmDiagnostics::SendError:
|
||||
case cmDiagnostics::FatalError:
|
||||
this->Messenger->SetSuppressDeprecatedWarnings(false);
|
||||
this->Messenger->SetDeprecatedWarningsAsErrors(true);
|
||||
break;
|
||||
default:
|
||||
this->Messenger->SetSuppressDeprecatedWarnings(false);
|
||||
this->Messenger->SetDeprecatedWarningsAsErrors(false);
|
||||
break;
|
||||
}
|
||||
|
||||
// Now write the diagnostic state back to the cache.
|
||||
cmList diagnostics;
|
||||
for (unsigned i = 1; i < cmDiagnostics::CategoryCount; ++i) {
|
||||
auto const category = static_cast<cmDiagnosticCategory>(i);
|
||||
auto const action = this->CurrentSnapshot.GetDiagnostic(category);
|
||||
|
||||
diagnostics.emplace_back(
|
||||
cmStrCat(cmDiagnostics::GetCategoryString(category), '=',
|
||||
cmDiagnostics::GetActionString(action)));
|
||||
|
||||
if (category == cmDiagnostics::CMD_DEPRECATED) {
|
||||
// Set deprecated CMAKE_{WARN,ERROR}_DEPRECATED, but only in the cache,
|
||||
// and only if they were already set in the cache.
|
||||
if (cachedWarnDeprecated) {
|
||||
std::string const value =
|
||||
(action >= cmDiagnostics::Warn ? "ON" : "OFF");
|
||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value,
|
||||
"Deprecated. Use CMAKE_DIAGNOSTIC_INIT instead.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
if (cachedErrorDeprecated) {
|
||||
std::string const value =
|
||||
(action >= cmDiagnostics::SendError ? "ON" : "OFF");
|
||||
this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value,
|
||||
"Deprecated. Use CMAKE_DIAGNOSTIC_INIT instead.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_DIAGNOSTIC_INIT", cmJoin(diagnostics, ";"_s),
|
||||
"Set initial state for CMake diagnostics; "
|
||||
"used to persist state set by command-line options "
|
||||
"across invocations.",
|
||||
cmStateEnums::INTERNAL);
|
||||
|
||||
int ret = this->ActualConfigure();
|
||||
cmValue delCacheVars =
|
||||
@@ -3214,9 +3274,7 @@ int cmake::Generate()
|
||||
std::cout << "Generate graphviz: " << this->GraphVizFile << '\n';
|
||||
this->GenerateGraphViz(this->GraphVizFile);
|
||||
}
|
||||
if (this->WarnUnusedCli) {
|
||||
this->RunCheckForUnusedVariables();
|
||||
}
|
||||
this->RunCheckForUnusedVariables();
|
||||
if (cmSystemTools::GetErrorOccurredFlag()) {
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
this->FileAPI->WriteReplies(cmFileAPI::IndexFor::FailedGenerate);
|
||||
@@ -3244,16 +3302,6 @@ void cmake::AddCacheEntry(std::string const& key, cmValue value,
|
||||
this->State->AddCacheEntry(key, value, helpString,
|
||||
static_cast<cmStateEnums::CacheEntryType>(type));
|
||||
this->UnwatchUnusedCli(key);
|
||||
|
||||
if (key == "CMAKE_WARN_DEPRECATED"_s) {
|
||||
this->Messenger->SetSuppressDeprecatedWarnings(value && value.IsOff());
|
||||
} else if (key == "CMAKE_ERROR_DEPRECATED"_s) {
|
||||
this->Messenger->SetDeprecatedWarningsAsErrors(value.IsOn());
|
||||
} else if (key == "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"_s) {
|
||||
this->Messenger->SetSuppressDevWarnings(value.IsOn());
|
||||
} else if (key == "CMAKE_SUPPRESS_DEVELOPER_ERRORS"_s) {
|
||||
this->Messenger->SetDevWarningsAsErrors(value && value.IsOff());
|
||||
}
|
||||
}
|
||||
|
||||
bool cmake::DoWriteGlobVerifyTarget() const
|
||||
@@ -4450,117 +4498,28 @@ void cmake::UnwatchUnusedCli(std::string const& var)
|
||||
void cmake::RunCheckForUnusedVariables()
|
||||
{
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
bool haveUnused = false;
|
||||
std::ostringstream msg;
|
||||
msg << "Manually-specified variables were not used by the project:";
|
||||
for (auto const& it : this->UsedCliVariables) {
|
||||
if (!it.second) {
|
||||
haveUnused = true;
|
||||
msg << "\n " << it.first;
|
||||
cmDiagnosticAction const action =
|
||||
this->CurrentSnapshot.GetDiagnostic(cmDiagnostics::CMD_UNUSED_CLI);
|
||||
if (action != cmDiagnostics::Ignore) {
|
||||
bool haveUnused = false;
|
||||
std::ostringstream msg;
|
||||
msg << "Manually-specified variables were not used by the project:";
|
||||
for (auto const& it : this->UsedCliVariables) {
|
||||
if (!it.second) {
|
||||
haveUnused = true;
|
||||
msg << "\n " << it.first;
|
||||
}
|
||||
}
|
||||
if (haveUnused) {
|
||||
this->IssueMessage(action > cmDiagnostics::Warn
|
||||
? MessageType::FATAL_ERROR
|
||||
: MessageType::WARNING,
|
||||
msg.str());
|
||||
}
|
||||
}
|
||||
if (haveUnused) {
|
||||
this->IssueMessage(MessageType::WARNING, msg.str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cmake::GetSuppressDevWarnings() const
|
||||
{
|
||||
return this->Messenger->GetSuppressDevWarnings();
|
||||
}
|
||||
|
||||
void cmake::SetSuppressDevWarnings(bool b)
|
||||
{
|
||||
std::string value;
|
||||
|
||||
// equivalent to -Wno-dev
|
||||
if (b) {
|
||||
value = "TRUE";
|
||||
}
|
||||
// equivalent to -Wdev
|
||||
else {
|
||||
value = "FALSE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", value,
|
||||
"Suppress Warnings that are meant for"
|
||||
" the author of the CMakeLists.txt files.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
bool cmake::GetSuppressDeprecatedWarnings() const
|
||||
{
|
||||
return this->Messenger->GetSuppressDeprecatedWarnings();
|
||||
}
|
||||
|
||||
void cmake::SetSuppressDeprecatedWarnings(bool b)
|
||||
{
|
||||
std::string value;
|
||||
|
||||
// equivalent to -Wno-deprecated
|
||||
if (b) {
|
||||
value = "FALSE";
|
||||
}
|
||||
// equivalent to -Wdeprecated
|
||||
else {
|
||||
value = "TRUE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value,
|
||||
"Whether to issue warnings for deprecated "
|
||||
"functionality.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
bool cmake::GetDevWarningsAsErrors() const
|
||||
{
|
||||
return this->Messenger->GetDevWarningsAsErrors();
|
||||
}
|
||||
|
||||
void cmake::SetDevWarningsAsErrors(bool b)
|
||||
{
|
||||
std::string value;
|
||||
|
||||
// equivalent to -Werror=dev
|
||||
if (b) {
|
||||
value = "FALSE";
|
||||
}
|
||||
// equivalent to -Wno-error=dev
|
||||
else {
|
||||
value = "TRUE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", value,
|
||||
"Suppress errors that are meant for"
|
||||
" the author of the CMakeLists.txt files.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
bool cmake::GetDeprecatedWarningsAsErrors() const
|
||||
{
|
||||
return this->Messenger->GetDeprecatedWarningsAsErrors();
|
||||
}
|
||||
|
||||
void cmake::SetDeprecatedWarningsAsErrors(bool b)
|
||||
{
|
||||
std::string value;
|
||||
|
||||
// equivalent to -Werror=deprecated
|
||||
if (b) {
|
||||
value = "TRUE";
|
||||
}
|
||||
// equivalent to -Wno-error=deprecated
|
||||
else {
|
||||
value = "FALSE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value,
|
||||
"Whether to issue deprecation errors for macros"
|
||||
" and functions.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
void cmake::SetDebugFindOutputPkgs(std::string const& args)
|
||||
{
|
||||
this->DebugFindPkgs.emplace(args);
|
||||
|
||||
+3
-67
@@ -86,13 +86,6 @@ struct cmGlobCacheEntry;
|
||||
class cmake
|
||||
{
|
||||
public:
|
||||
enum DiagLevel
|
||||
{
|
||||
DIAG_IGNORE,
|
||||
DIAG_WARN,
|
||||
DIAG_ERROR
|
||||
};
|
||||
|
||||
/** \brief Describes the working modes of cmake */
|
||||
enum WorkingMode
|
||||
{
|
||||
@@ -396,15 +389,9 @@ public:
|
||||
bool GetIsInTryCompile() const;
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
void SetWarningFromPreset(
|
||||
std::string const& name,
|
||||
void SetDiagnosticsFromPreset(
|
||||
std::map<cmDiagnosticCategory, bool> const& warnings,
|
||||
std::map<cmDiagnosticCategory, bool> const& errors,
|
||||
cmDiagnosticCategory key);
|
||||
void SetWarningFromPreset(
|
||||
void (cmake::*func)(bool),
|
||||
std::map<cmDiagnosticCategory, bool> const& warnings, bool allowedValue,
|
||||
cmDiagnosticCategory key);
|
||||
std::map<cmDiagnosticCategory, bool> const& errors);
|
||||
void ProcessPresetVariables();
|
||||
void PrintPresetVariables();
|
||||
void ProcessPresetEnvironment();
|
||||
@@ -577,10 +564,6 @@ public:
|
||||
//! Use trace from another ::cmake instance.
|
||||
void SetTraceRedirect(cmake* other);
|
||||
|
||||
bool GetWarnUninitialized() const { return this->WarnUninitialized; }
|
||||
void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
|
||||
bool GetWarnUnusedCli() const { return this->WarnUnusedCli; }
|
||||
void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
|
||||
bool GetCheckSystemVars() const { return this->CheckSystemVars; }
|
||||
void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
|
||||
bool GetIgnoreCompileWarningAsError() const
|
||||
@@ -626,50 +609,6 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the state of the suppression of developer (author) warnings.
|
||||
* Returns false, by default, if developer warnings should be shown, true
|
||||
* otherwise.
|
||||
*/
|
||||
bool GetSuppressDevWarnings() const;
|
||||
/**
|
||||
* Set the state of the suppression of developer (author) warnings.
|
||||
*/
|
||||
void SetSuppressDevWarnings(bool v);
|
||||
|
||||
/**
|
||||
* Get the state of the suppression of deprecated warnings.
|
||||
* Returns false, by default, if deprecated warnings should be shown, true
|
||||
* otherwise.
|
||||
*/
|
||||
bool GetSuppressDeprecatedWarnings() const;
|
||||
/**
|
||||
* Set the state of the suppression of deprecated warnings.
|
||||
*/
|
||||
void SetSuppressDeprecatedWarnings(bool v);
|
||||
|
||||
/**
|
||||
* Get the state of treating developer (author) warnings as errors.
|
||||
* Returns false, by default, if warnings should not be treated as errors,
|
||||
* true otherwise.
|
||||
*/
|
||||
bool GetDevWarningsAsErrors() const;
|
||||
/**
|
||||
* Set the state of treating developer (author) warnings as errors.
|
||||
*/
|
||||
void SetDevWarningsAsErrors(bool v);
|
||||
|
||||
/**
|
||||
* Get the state of treating deprecated warnings as errors.
|
||||
* Returns false, by default, if warnings should not be treated as errors,
|
||||
* true otherwise.
|
||||
*/
|
||||
bool GetDeprecatedWarningsAsErrors() const;
|
||||
/**
|
||||
* Set the state of treating developer (author) warnings as errors.
|
||||
*/
|
||||
void SetDeprecatedWarningsAsErrors(bool v);
|
||||
|
||||
/** Display a message to the user. */
|
||||
void IssueMessage(
|
||||
MessageType t, std::string const& text,
|
||||
@@ -797,7 +736,6 @@ protected:
|
||||
void AddDefaultGenerators();
|
||||
void AddDefaultExtraGenerators();
|
||||
|
||||
std::map<std::string, DiagLevel> DiagLevels;
|
||||
std::string GeneratorInstance;
|
||||
std::string GeneratorPlatform;
|
||||
std::string GeneratorToolset;
|
||||
@@ -848,8 +786,6 @@ private:
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
std::unique_ptr<cmConfigureLog> ConfigureLog;
|
||||
#endif
|
||||
bool WarnUninitialized = false;
|
||||
bool WarnUnusedCli = true;
|
||||
bool CheckSystemVars = false;
|
||||
bool IgnoreCompileWarningAsError = false;
|
||||
bool IgnoreLinkWarningAsError = false;
|
||||
@@ -947,7 +883,7 @@ public:
|
||||
void SetScriptModeExitCode(int code) { ScriptModeExitCode = code; }
|
||||
int GetScriptModeExitCode() const { return ScriptModeExitCode.value_or(-1); }
|
||||
|
||||
static cmDocumentationEntry CMAKE_STANDARD_OPTIONS_TABLE[19];
|
||||
static cmDocumentationEntry CMAKE_STANDARD_OPTIONS_TABLE[15];
|
||||
};
|
||||
|
||||
#define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes)
|
||||
|
||||
@@ -73,7 +73,7 @@ cmDocumentationEntry const cmDocumentationUsageNote = {
|
||||
"Run 'cmake --help' for more information."
|
||||
};
|
||||
|
||||
cmDocumentationEntry const cmDocumentationOptions[35] = {
|
||||
cmDocumentationEntry const cmDocumentationOptions[] = {
|
||||
{ "--preset <preset>,--preset=<preset>", "Specify a configure preset." },
|
||||
{ "--list-presets[=<type>]", "List available presets." },
|
||||
{ "--workflow [<options>]", "Run a workflow preset." },
|
||||
@@ -118,8 +118,6 @@ cmDocumentationEntry const cmDocumentationOptions[35] = {
|
||||
"Trace only this CMake file/module. Multiple options allowed." },
|
||||
{ "--trace-redirect=<file>",
|
||||
"Redirect trace output to a file instead of stderr." },
|
||||
{ "--warn-uninitialized", "Warn about uninitialized values." },
|
||||
{ "--no-warn-unused-cli", "Don't warn about command line options." },
|
||||
{ "--check-system-vars",
|
||||
"Find problems with variable usage in system files." },
|
||||
{ "--compile-no-warning-as-error",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"default" ?- Default Config
|
||||
"ninja-multi" ?- Ninja Multi-Config(
|
||||
|
||||
@@ -5,4 +5,12 @@ Call Stack \(most recent call first\):
|
||||
[^
|
||||
]*/Tests/RunCMake/CMakePresets/ErrorDev\.cmake:[0-9]+ \(include\)
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This error is for project developers\. Use -Wno-error=dev to suppress it\.$
|
||||
This error is for project developers\. Use -Wno-error=dev to suppress it\.
|
||||
|
||||
CMake Deprecation Error at [^
|
||||
]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\):
|
||||
Deprecation warning
|
||||
Call Stack \(most recent call first\):
|
||||
[^
|
||||
]*/Tests/RunCMake/CMakePresets/ErrorDev\.cmake:[0-9]+ \(include\)
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
CMake Warning:
|
||||
Manually-specified variables were not used by the project:
|
||||
|
||||
RunCMake_GENERATOR
|
||||
UNUSED_VARIABLE$
|
||||
@@ -0,0 +1,6 @@
|
||||
cmake_diagnostic(GET CMD_UNINITIALIZED action)
|
||||
if(NOT "${action}" STREQUAL SEND_ERROR)
|
||||
message(SEND_ERROR
|
||||
"wrong action for diagnostic CMD_UNINITIALIZED"
|
||||
" (expected 'SEND_ERROR', actual '${action}')")
|
||||
endif()
|
||||
@@ -0,0 +1,7 @@
|
||||
CMake Error:
|
||||
Manually-specified variables were not used by the project:
|
||||
|
||||
RunCMake_GENERATOR
|
||||
UNUSED_VARIABLE
|
||||
+
|
||||
CMake Generate step failed\. Build files cannot be regenerated correctly\.$
|
||||
@@ -0,0 +1,6 @@
|
||||
cmake_diagnostic(GET CMD_UNUSED_CLI action)
|
||||
if(NOT "${action}" STREQUAL SEND_ERROR)
|
||||
message(SEND_ERROR
|
||||
"wrong action for diagnostic CMD_UNUSED_CLI"
|
||||
" (expected 'SEND_ERROR', actual '${action}')")
|
||||
endif()
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"IncludeUser"
|
||||
"IncludeUserCommon"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"Include"
|
||||
"IncludeCommon"$
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"Include"
|
||||
"IncludeCommon"$
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"default"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"default"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"zzzzzz" - Sleepy
|
||||
"aaaaaaaa" - Screaming
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"zzzzzz" - Sleepy
|
||||
"aaaaaaaa" - Screaming
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"zzzzzz" - Sleepy
|
||||
"aaaaaaaa" - Screaming
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"zzzzzz" - Sleepy
|
||||
"aaaaaaaa" - Screaming
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
^Available configure presets:
|
||||
|
||||
"zzzzzz" - Sleepy
|
||||
"aaaaaaaa" - Screaming
|
||||
|
||||
@@ -1 +1 @@
|
||||
^Not searching for unused variables given on the command line\.$
|
||||
^$
|
||||
|
||||
@@ -66,7 +66,7 @@ function(run_cmake_presets name)
|
||||
if(CMakePresets_NO_SOURCE_ARGS)
|
||||
set(_source_args)
|
||||
endif()
|
||||
set(_unused_cli --no-warn-unused-cli)
|
||||
set(_unused_cli -Wno-unused-cli)
|
||||
if(CMakePresets_WARN_UNUSED_CLI)
|
||||
set(_unused_cli)
|
||||
endif()
|
||||
@@ -363,6 +363,8 @@ run_cmake_presets(NoWarningFlags)
|
||||
run_cmake_presets(WarningFlags)
|
||||
run_cmake_presets(DisableWarningFlags)
|
||||
run_cmake_presets(ErrorDev)
|
||||
run_cmake_presets(ErrorUninitialized)
|
||||
run_cmake_presets(ErrorUnusedCli)
|
||||
unset(CMakePresets_WARN_UNUSED_CLI)
|
||||
|
||||
# Test debug
|
||||
|
||||
@@ -1040,37 +1040,39 @@ set(RunCMake_TEST_OPTIONS
|
||||
"-DFOO:STRING=-DBAR:BOOL=BAZ")
|
||||
run_cmake(D_typed_nested_cache)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wno-dev)
|
||||
run_cmake(Wno-dev)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# -Wdev is a deprecated synonym for -Wauthor
|
||||
set(RunCMake_TEST_OPTIONS -Wdev)
|
||||
run_cmake(Wdev)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Werror=dev)
|
||||
run_cmake(Werror_dev)
|
||||
set(RunCMake_TEST_OPTIONS -Wno-author)
|
||||
run_cmake(Wno-author)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wno-error=dev)
|
||||
run_cmake(Wno-error_dev)
|
||||
set(RunCMake_TEST_OPTIONS -Wauthor)
|
||||
run_cmake(Wauthor)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# -Wdev should not override deprecated options if specified
|
||||
set(RunCMake_TEST_OPTIONS -Wdev -Wno-deprecated)
|
||||
run_cmake(Wno-deprecated)
|
||||
set(RunCMake_TEST_OPTIONS -Werror=author)
|
||||
run_cmake(Werror_author)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
set(RunCMake_TEST_OPTIONS -Wno-deprecated -Wdev)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wno-error=author)
|
||||
run_cmake(Wno-error_author)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# -Wauthor should not override deprecated options if specified
|
||||
set(RunCMake_TEST_OPTIONS -Wauthor -Wno-deprecated)
|
||||
run_cmake(Wno-deprecated)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# -Wdev should enable deprecated warnings as well
|
||||
set(RunCMake_TEST_OPTIONS -Wdev)
|
||||
# -Wauthor should enable deprecated warnings as well
|
||||
set(RunCMake_TEST_OPTIONS -Wauthor)
|
||||
run_cmake(Wdeprecated)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# -Werror=dev should enable deprecated errors as well
|
||||
set(RunCMake_TEST_OPTIONS -Werror=dev)
|
||||
# -Werror=author should enable deprecated errors as well
|
||||
set(RunCMake_TEST_OPTIONS -Werror=author)
|
||||
run_cmake(Werror_deprecated)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
@@ -1094,23 +1096,28 @@ set(RunCMake_TEST_OPTIONS -Werror=deprecated -Wno-error=deprecated)
|
||||
run_cmake(Wno-error_deprecated)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# Dev warnings should be on by default
|
||||
run_cmake(Wdev)
|
||||
# Author warnings should be on by default
|
||||
run_cmake(Wauthor)
|
||||
|
||||
# Deprecated warnings should be on by default
|
||||
run_cmake(Wdeprecated)
|
||||
|
||||
# Conflicting -W options should honor the last value
|
||||
set(RunCMake_TEST_OPTIONS -Wno-dev -Wdev)
|
||||
run_cmake(Wdev)
|
||||
set(RunCMake_TEST_OPTIONS -Wno-author -Wauthor)
|
||||
run_cmake(Wauthor)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
set(RunCMake_TEST_OPTIONS -Wdev -Wno-dev)
|
||||
run_cmake(Wno-dev)
|
||||
set(RunCMake_TEST_OPTIONS -Wauthor -Wno-author)
|
||||
run_cmake(Wno-author)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wno-deprecated -Wuninitialized)
|
||||
run_cmake(Wuninitialized)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -B DummyBuildDir -W)
|
||||
run_cmake_command(W_bad-arg2 ${CMAKE_COMMAND} -B DummyBuildDir -Wno-)
|
||||
run_cmake_command(W_bad-arg3 ${CMAKE_COMMAND} -B DummyBuildDir -Werror=)
|
||||
run_cmake_command(W_bad-arg4 ${CMAKE_COMMAND} -B DummyBuildDir -Wimaginary)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --debug-output)
|
||||
run_cmake(debug-output)
|
||||
@@ -1125,7 +1132,7 @@ set(RunCMake_TEST_OPTIONS --trace-expand)
|
||||
run_cmake(trace-expand)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
|
||||
set(RunCMake_TEST_OPTIONS --trace-expand -Wuninitialized)
|
||||
run_cmake(trace-expand-warn-uninitialized)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
@@ -1146,10 +1153,6 @@ set(RunCMake_TEST_OPTIONS --trace-expand --trace-format=json-v1 --trace-redirect
|
||||
run_cmake(trace-json-v1-expand)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized)
|
||||
run_cmake(warn-uninitialized)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake)
|
||||
run_cmake(trace-source)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,2 @@
|
||||
CMake Error: The warning category "imaginary" is not known.
|
||||
CMake Error: Run 'cmake --help' for all supported options\.
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
^CMake Warning \(dev\) at Wno-error_dev\.cmake:2 \(message\):
|
||||
^CMake Warning \(dev\) at Wauthor\.cmake:1 \(message\):
|
||||
Some author warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
|
||||
CMake Warning \(dev\) at Wno-error_dev\.cmake:7 \(include\):
|
||||
CMake Warning \(dev\) at Wauthor\.cmake:6 \(include\):
|
||||
include\(\) given empty file name \(ignored\)\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
@@ -1,6 +1,6 @@
|
||||
message(AUTHOR_WARNING "Some author warning")
|
||||
|
||||
# without -Wno-dev this will also cause an AUTHOR_WARNING message, checks that
|
||||
# with -Wauthor this will also cause an AUTHOR_WARNING message, checks that
|
||||
# messages issued outside of the message command, by other CMake commands, also
|
||||
# are affected by -Wno-dev
|
||||
# are affected by -Wauthor
|
||||
include("")
|
||||
@@ -1,4 +1,5 @@
|
||||
^CMake Warning \(dev\) at Wdev\.cmake:1 \(message\):
|
||||
^The dev option is deprecated\. Use -Wauthor instead\.
|
||||
CMake Warning \(dev\) at Wdev\.cmake:1 \(message\):
|
||||
Some author warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
^CMake Error \(dev\) at Werror_dev\.cmake:4 \(include\):
|
||||
^CMake Error \(dev\) at Werror_author\.cmake:4 \(include\):
|
||||
include\(\) given empty file name \(ignored\)\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This error is for project developers\. Use -Wno-error=dev to suppress it\.
|
||||
|
||||
CMake Error \(dev\) at Werror_dev\.cmake:7 \(message\):
|
||||
CMake Error \(dev\) at Werror_author\.cmake:7 \(message\):
|
||||
Some author warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# with -Werror=dev this will also cause an (upgraded) AUTHOR_ERROR message,
|
||||
# with -Werror=author this will also cause an (upgraded) AUTHOR_ERROR message,
|
||||
# checks that messages issued outside of the message command, by other CMake
|
||||
# commands, also are affected by -Werror=dev
|
||||
# commands, also are affected by -Werror=author
|
||||
include("")
|
||||
|
||||
# message command sets fatal occurred flag, so run it last
|
||||
@@ -0,0 +1,6 @@
|
||||
message(AUTHOR_WARNING "Some author warning")
|
||||
|
||||
# without -Wno-author this will also cause an AUTHOR_WARNING message, checks
|
||||
# that messages issued outside of the message command, by other CMake commands,
|
||||
# also are affected by -Wno-author
|
||||
include("")
|
||||
@@ -0,0 +1,11 @@
|
||||
^CMake Warning \(dev\) at Wno-error_author\.cmake:2 \(message\):
|
||||
Some author warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
|
||||
CMake Warning \(dev\) at Wno-error_author\.cmake:7 \(include\):
|
||||
include\(\) given empty file name \(ignored\)\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.$
|
||||
@@ -0,0 +1,7 @@
|
||||
# This should still produce a warning when -Wno-error=author is specified
|
||||
message(AUTHOR_WARNING "Some author warning")
|
||||
|
||||
# with -Wno-error=author this will also cause an AUTHOR_WARNING message, checks
|
||||
# that messages issued outside of the message command, by other CMake commands,
|
||||
# also are affected by -Wno-error=author
|
||||
include("")
|
||||
@@ -1,7 +0,0 @@
|
||||
# This should still produce a warning when -Wno-error=dev is specified
|
||||
message(AUTHOR_WARNING "Some author warning")
|
||||
|
||||
# with -Wno-error=dev this will also cause an AUTHOR_WARNING message, checks
|
||||
# that messages issued outside of the message command, by other CMake commands,
|
||||
# also are affected by -Wno-error=dev
|
||||
include("")
|
||||
+4
-4
@@ -1,22 +1,22 @@
|
||||
CMake Warning \(dev\) at warn-uninitialized\.cmake:1 \(set\):
|
||||
CMake Warning \(dev\) at Wuninitialized\.cmake:1 \(set\):
|
||||
uninitialized variable 'NEW_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES'
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
|
||||
CMake Warning \(dev\) at warn-uninitialized\.cmake:2 \(string\):
|
||||
CMake Warning \(dev\) at Wuninitialized\.cmake:2 \(string\):
|
||||
uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES'
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
|
||||
CMake Warning \(dev\) at warn-uninitialized\.cmake:4 \(configure_file\):
|
||||
CMake Warning \(dev\) at Wuninitialized\.cmake:4 \(configure_file\):
|
||||
uninitialized variable 'NEW_WARN_FROM_CONFIGURE_FILE_INSIDE_AT'
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
|
||||
CMake Warning \(dev\) at warn-uninitialized\.cmake:5 \(string\):
|
||||
CMake Warning \(dev\) at Wuninitialized\.cmake:5 \(string\):
|
||||
uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_AT'
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
@@ -1,14 +1,14 @@
|
||||
function(run_test ACTION INIT TARGET EXPECTED)
|
||||
cmake_diagnostic(SET CMD_AUTHOR ${INIT})
|
||||
cmake_diagnostic(SET CMD_DEPRECATED ${INIT})
|
||||
|
||||
cmake_diagnostic(GET CMD_AUTHOR action)
|
||||
cmake_diagnostic(GET CMD_DEPRECATED action)
|
||||
if(NOT "${action}" STREQUAL "${INIT}")
|
||||
message(SEND_ERROR "failed to set diagnostic state")
|
||||
endif()
|
||||
|
||||
cmake_diagnostic(${ACTION} CMD_AUTHOR ${TARGET})
|
||||
cmake_diagnostic(${ACTION} CMD_AUTHOR ${TARGET} RECURSE)
|
||||
|
||||
cmake_diagnostic(GET CMD_AUTHOR action)
|
||||
cmake_diagnostic(GET CMD_DEPRECATED action)
|
||||
if(NOT "${action}" STREQUAL "${EXPECTED}")
|
||||
message(SEND_ERROR
|
||||
"failed to change diagnostic state"
|
||||
@@ -17,6 +17,7 @@ function(run_test ACTION INIT TARGET EXPECTED)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Run tests for altering a diagnostic from a known state
|
||||
run_test(SET IGNORE WARN WARN)
|
||||
run_test(SET IGNORE SEND_ERROR SEND_ERROR)
|
||||
run_test(SET IGNORE FATAL_ERROR FATAL_ERROR)
|
||||
@@ -60,3 +61,14 @@ run_test(DEMOTE FATAL_ERROR IGNORE IGNORE)
|
||||
run_test(DEMOTE FATAL_ERROR WARN WARN)
|
||||
run_test(DEMOTE FATAL_ERROR SEND_ERROR SEND_ERROR)
|
||||
run_test(DEMOTE FATAL_ERROR FATAL_ERROR FATAL_ERROR)
|
||||
|
||||
# Ensure that altering a diagnostic that is still in the default state
|
||||
# uses the default state as the basis for alteration
|
||||
cmake_diagnostic(DEMOTE CMD_UNINITIALIZED WARN)
|
||||
|
||||
cmake_diagnostic(GET CMD_UNINITIALIZED action)
|
||||
if(NOT "${action}" STREQUAL "IGNORE")
|
||||
message(SEND_ERROR
|
||||
"CMD_UNINITIALIZED has unexpected state '${action}' (expected 'IGNORE')"
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
function(expect CATEGORY EXPECTED)
|
||||
cmake_diagnostic(GET ${CATEGORY} actual)
|
||||
if(NOT "${actual}" STREQUAL "${EXPECTED}")
|
||||
message(SEND_ERROR
|
||||
"wrong action for diagnostic ${CATEGORY}"
|
||||
" (expected '${EXPECTED}', actual '${actual}')")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(expect_cached CATEGORY EXPECTED)
|
||||
expect(${CATEGORY} ${EXPECTED})
|
||||
|
||||
if(NOT "${CATEGORY}=${EXPECTED}" IN_LIST CMAKE_DIAGNOSTIC_INIT)
|
||||
list(JOIN CMAKE_DIAGNOSTIC_INIT ", " pretty_state)
|
||||
message(SEND_ERROR
|
||||
"Cached state for ${CATEGORY} missing or incorrect"
|
||||
" (expected '${EXPECTED}' in ${pretty_state})")
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -0,0 +1,4 @@
|
||||
include(Assertions.cmake)
|
||||
|
||||
expect(CMD_AUTHOR IGNORE)
|
||||
expect(CMD_DEPRECATED SEND_ERROR)
|
||||
@@ -0,0 +1,4 @@
|
||||
include(Assertions.cmake)
|
||||
|
||||
expect_cached(CMD_AUTHOR SEND_ERROR)
|
||||
expect_cached(CMD_DEPRECATED SEND_ERROR)
|
||||
@@ -0,0 +1,4 @@
|
||||
include(Assertions.cmake)
|
||||
|
||||
expect_cached(CMD_AUTHOR SEND_ERROR)
|
||||
expect_cached(CMD_DEPRECATED IGNORE)
|
||||
@@ -0,0 +1,3 @@
|
||||
include(Assertions.cmake)
|
||||
|
||||
expect_cached(CMD_UNINITIALIZED IGNORE)
|
||||
@@ -1,3 +1,15 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(Actions)
|
||||
|
||||
run_cmake_with_options(
|
||||
CacheInit
|
||||
"-DCMAKE_DIAGNOSTIC_INIT=CMD_AUTHOR=IGNORE\;CMD_DEPRECATED=SEND_ERROR"
|
||||
)
|
||||
|
||||
run_cmake_with_options(CommandLine1 -Wno-author -Werror=author)
|
||||
run_cmake_with_options(CommandLine1 -Werror=author)
|
||||
run_cmake_with_options(CommandLine1 -Werror=author -Wdeprecated)
|
||||
run_cmake_with_options(CommandLine1 -Wno-deprecated -Werror=author)
|
||||
run_cmake_with_options(CommandLine2 -Werror=author -Wno-deprecated)
|
||||
run_cmake_with_options(CommandLine3 -Wno-error=uninitialized)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
set(common_test_options
|
||||
-Wno-dev
|
||||
-Wno-author
|
||||
"-DCMAKE_EXPERIMENTAL_GENERATE_SBOM:STRING=ca494ed3-b261-4205-a01f-603c95e4cae0"
|
||||
"-DCMAKE_INSTALL_SBOM_FORMATS:STRING=JSON"
|
||||
"-DCMAKE_INSTALL_LIBDIR=lib"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
set(common_test_options
|
||||
-Wno-dev
|
||||
-Wno-author
|
||||
"-DCMAKE_EXPERIMENTAL_GENERATE_SBOM:STRING=ca494ed3-b261-4205-a01f-603c95e4cae0"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Test add_compiler_export_flags without deprecation warning.
|
||||
set(CMAKE_WARN_DEPRECATED OFF)
|
||||
cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
|
||||
|
||||
project(GenerateExportHeader)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ run_cmake(ExperimentalWarning)
|
||||
|
||||
# Enable experimental feature and suppress warnings
|
||||
set(RunCMake_TEST_OPTIONS
|
||||
-Wno-dev
|
||||
-Wno-author
|
||||
"-DCMAKE_EXPERIMENTAL_MAPPED_PACKAGE_INFO:STRING=ababa1b5-7099-495f-a9cd-e22d38f274f2"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
set(common_test_options
|
||||
-Wno-dev
|
||||
-Wno-author
|
||||
"-DCMAKE_EXPERIMENTAL_GENERATE_SBOM:STRING=ca494ed3-b261-4205-a01f-603c95e4cae0"
|
||||
)
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ run_cmake_build(ExternalProject debug-in-release-graph "Release" all:Debug)
|
||||
#run_cmake_configure(AutoMocExecutable)
|
||||
#run_cmake_build(AutoMocExecutable debug-in-release-graph Release exe)
|
||||
|
||||
# Need to test this manually because run_cmake() adds --no-warn-unused-cli
|
||||
# Need to test this manually because run_cmake() adds -Wno-unused-cli
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoUnusedVariables-build)
|
||||
run_cmake_command(NoUnusedVariables ${CMAKE_COMMAND} ${CMAKE_CURRENT_LIST_DIR}
|
||||
-G "Ninja Multi-Config"
|
||||
|
||||
@@ -134,7 +134,7 @@ function(run_cmake test)
|
||||
endif()
|
||||
list(APPEND RunCMake_TEST_COMMAND
|
||||
-DRunCMake_TEST=${test}
|
||||
--no-warn-unused-cli
|
||||
-Wno-unused-cli
|
||||
)
|
||||
else()
|
||||
set(RunCMake_TEST_OPTIONS "")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
Not searching for unused variables given on the command line.
|
||||
-- Configuring done \([.0-9]+s\)
|
||||
-- Generating done \([.0-9]+s\)
|
||||
-- Build files have been written to: .*[\\/]Editions-build
|
||||
|
||||
@@ -7,9 +7,18 @@ run_cmake(ConfigureLog)
|
||||
run_cmake(defaultmessage)
|
||||
run_cmake(nomessage)
|
||||
run_cmake(message-internal-warning)
|
||||
run_cmake(nomessage-internal-warning)
|
||||
# run_cmake(nomessage-internal-warning)
|
||||
run_cmake(warnmessage)
|
||||
|
||||
# TODO: We currently do not have a way to change diagnostic state in a way that
|
||||
# is visible to internally issued diagnostic. This will be remedied when we
|
||||
# switch to the new methods for issuing diagnostics, but for a brief window,
|
||||
# this test will only pass if author warnings are disabled by command-line
|
||||
# option.
|
||||
set(RunCMake_TEST_OPTIONS -Wno-author)
|
||||
run_cmake(nomessage-internal-warning)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# Have to explicitly give the command for the working dir to be honored
|
||||
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY /)
|
||||
run_cmake_command(
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
set(CMAKE_ERROR_DEPRECATED ON)
|
||||
cmake_diagnostic(SET CMD_DEPRECATED SEND_ERROR)
|
||||
|
||||
message(DEPRECATION "This is a deprecation error")
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_ERRORS OFF)
|
||||
cmake_diagnostic(SET CMD_AUTHOR SEND_ERROR)
|
||||
|
||||
message(AUTHOR_WARNING "This is a author error")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS ON)
|
||||
cmake_diagnostic(SET CMD_AUTHOR WARN)
|
||||
|
||||
macro(mymacro)
|
||||
endmacro(notmymacro)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS ON CACHE BOOL "")
|
||||
cmake_diagnostic(SET CMD_AUTHOR IGNORE)
|
||||
|
||||
macro(mymacro)
|
||||
endmacro(notmymacro)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
set(CMAKE_WARN_DEPRECATED OFF)
|
||||
cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
|
||||
|
||||
message(DEPRECATION "This is not issued")
|
||||
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS ON)
|
||||
cmake_diagnostic(SET CMD_AUTHOR IGNORE)
|
||||
|
||||
message(AUTHOR_WARNING "This is not issued")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
set(CMAKE_WARN_DEPRECATED ON)
|
||||
cmake_diagnostic(SET CMD_DEPRECATED WARN)
|
||||
|
||||
message(DEPRECATION "This is a deprecation warning")
|
||||
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS OFF)
|
||||
cmake_diagnostic(SET CMD_AUTHOR WARN)
|
||||
|
||||
message(AUTHOR_WARNING "This is a author warning")
|
||||
|
||||
@@ -36,6 +36,21 @@ else:
|
||||
|
||||
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
# BEGIN sphinx tweaks
|
||||
|
||||
# Adjust the 'std' domain regex used to parse options so that it recognizes
|
||||
# e.g. `-W<name>` as the option `-W` with a value `<name>`, rather than
|
||||
# treating the entire string as the option name.
|
||||
#
|
||||
# See also https://github.com/sphinx-doc/sphinx/issues/14323.
|
||||
|
||||
sphinx.domains.std.option_desc_re = (
|
||||
re.compile(r'((?:/|--|-|\+)?[^\s=<]+)(=?\s*.*)'))
|
||||
|
||||
# END sphinx tweaks
|
||||
|
||||
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
# BEGIN pygments tweaks
|
||||
|
||||
# Override much of pygments' CMakeLexer.
|
||||
|
||||
Reference in New Issue
Block a user