Browse Source

Presets: Only print presets variables for verbose log level or higher

Fixes: #26664
pull/376/head
Craig Scott 6 months ago
parent
commit
5303ad3823
No known key found for this signature in database GPG Key ID: 6FF37CBDCCADED9F
  1. 6
      Help/release/4.0.rst
  2. 8
      Source/cmake.cxx
  3. 8
      Tests/RunCMake/CMakePresets/RunCMakeTest.cmake

6
Help/release/4.0.rst

@ -226,3 +226,9 @@ Other Changes
* On AIX, ``SHARED`` library targets now produce a shared library archive
by default. See policy :policy:`CMP0182`.
* The :option:`cmake --preset` command no longer outputs a summary of the
preset's CMake cache and environment variables by default. That summary is
now only shown when the message log level is set to ``VERBOSE``, ``DEBUG``,
or ``TRACE`` via the :option:`cmake --log-level` option or the
:variable:`CMAKE_MESSAGE_LOG_LEVEL` cache variable.

8
Source/cmake.cxx

@ -2935,8 +2935,12 @@ int cmake::Run(std::vector<std::string> const& args, bool noconfigure)
return -1;
}
#ifndef CMAKE_BOOTSTRAP
this->PrintPresetVariables();
this->PrintPresetEnvironment();
if (this->GetLogLevel() == Message::LogLevel::LOG_VERBOSE ||
this->GetLogLevel() == Message::LogLevel::LOG_DEBUG ||
this->GetLogLevel() == Message::LogLevel::LOG_TRACE) {
this->PrintPresetVariables();
this->PrintPresetEnvironment();
}
#endif
// In script mode we terminate after running the script.

8
Tests/RunCMake/CMakePresets/RunCMakeTest.cmake

@ -76,6 +76,11 @@ function(run_cmake_presets name)
set(_preset)
endif()
set(_log_level)
if(CMakePresets_LOG_LEVEL)
set(_log_level "--log-level=${CMakePresets_LOG_LEVEL}")
endif()
set(_make_program)
if(RunCMake_MAKE_PROGRAM)
set(_make_program -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM})
@ -88,6 +93,7 @@ function(run_cmake_presets name)
${_make_program}
${_unused_cli}
${_preset}
${_log_level}
${ARGN}
)
run_cmake(${name})
@ -192,6 +198,7 @@ unset(ENV{TEST_D_ENV_REF})
set(ENV{TEST_ENV_OVERRIDE} "This environment variable will be overridden")
set(ENV{TEST_PENV} "Process environment variable")
set(ENV{TEST_ENV_REF_PENV} "suffix")
set(CMakePresets_LOG_LEVEL "verbose")
run_cmake_presets(Good "-DTEST_OVERRIDE_1=Overridden value" "-DTEST_OVERRIDE_2:STRING=Overridden value" -C "${RunCMake_SOURCE_DIR}/CacheOverride.cmake" "-UTEST_UNDEF")
unset(ENV{TEST_ENV_OVERRIDE})
unset(ENV{TEST_PENV})
@ -209,6 +216,7 @@ if(WIN32)
endif()
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/GoodBOM.json.in")
run_cmake_presets(GoodBOM)
unset(CMakePresets_LOG_LEVEL)
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/CMakePresets.json.in")
file(REMOVE_RECURSE ${RunCMake_BINARY_DIR}/GoodBinaryCmdLine-build)
run_cmake_presets(GoodBinaryCmdLine -B ${RunCMake_BINARY_DIR}/GoodBinaryCmdLine-build)

Loading…
Cancel
Save