From d4bf7d80c618930e6b88c35d271a5b0a0656bb7b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jan 2023 11:49:35 -0500 Subject: try_compile: Add a NO_LOG option to skip recording in the configure log --- Help/command/try_compile.rst | 9 +++++++++ Help/command/try_run.rst | 2 ++ Help/release/dev/configure-log.rst | 4 ++++ Source/cmCoreTryCompile.cxx | 1 + Source/cmCoreTryCompile.h | 1 + Source/cmTryCompileCommand.cxx | 7 ++++--- Source/cmTryRunCommand.cxx | 2 +- Tests/RunCMake/try_compile/ConfigureLog.cmake | 5 +++++ Tests/RunCMake/try_run/ConfigureLog.cmake | 5 +++++ 9 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 208be46..8f6a4eb 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -20,6 +20,7 @@ Try Compiling Whole Projects [TARGET ] [LOG_DESCRIPTION ] [NO_CACHE] + [NO_LOG] [CMAKE_FLAGS ...] [OUTPUT_VARIABLE ]) @@ -50,6 +51,7 @@ which was present in older versions of CMake: [] [LOG_DESCRIPTION ] [NO_CACHE] + [NO_LOG] [CMAKE_FLAGS ...] [OUTPUT_VARIABLE ]) @@ -67,6 +69,7 @@ Try Compiling Source Files SOURCE_FROM_FILE >... [LOG_DESCRIPTION ] [NO_CACHE] + [NO_LOG] [CMAKE_FLAGS ...] [COMPILE_DEFINITIONS ...] [LINK_OPTIONS ...] @@ -120,6 +123,7 @@ which was present in older versions of CMake: try_compile( [LOG_DESCRIPTION ] [NO_CACHE] + [NO_LOG] [CMAKE_FLAGS ...] [COMPILE_DEFINITIONS ...] [LINK_OPTIONS ...] @@ -201,6 +205,11 @@ The options are: the test is part of a larger inspection), ``NO_CACHE`` may be useful to avoid leaking the intermediate result variable into the cache. +``NO_LOG`` + .. versionadded:: 3.26 + + Do not record a :manual:`cmake-configure-log(7)` entry for this call. + ``OUTPUT_VARIABLE `` Store the output from the build process in the given variable. diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst index ab4742e..ef8ec96 100644 --- a/Help/command/try_run.rst +++ b/Help/command/try_run.rst @@ -19,6 +19,7 @@ Try Compiling and Running Source Files SOURCE_FROM_FILE >... [LOG_DESCRIPTION ] [NO_CACHE] + [NO_LOG] [CMAKE_FLAGS ...] [COMPILE_DEFINITIONS ...] [LINK_OPTIONS ...] @@ -58,6 +59,7 @@ which was present in older versions of CMake: [LOG_DESCRIPTION ] [NO_CACHE] + [NO_LOG] [CMAKE_FLAGS ...] [COMPILE_DEFINITIONS ...] [LINK_OPTIONS ...] diff --git a/Help/release/dev/configure-log.rst b/Help/release/dev/configure-log.rst index 298137b..f802a8c 100644 --- a/Help/release/dev/configure-log.rst +++ b/Help/release/dev/configure-log.rst @@ -10,3 +10,7 @@ Configure Log * The :command:`try_compile` and :command:`try_run` commands gained a ``LOG_DESCRIPTION`` option specifying text to be recorded in the :manual:`cmake-configure-log(7)`. + +* The :command:`try_compile` and :command:`try_run` commands gained a + ``NO_LOG`` option to skip recording a :manual:`cmake-configure-log(7)` + entry. diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 29f6a98..2084b33 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -153,6 +153,7 @@ auto const TryCompileBaseArgParser = .Bind(0, &Arguments::CompileResultVariable) .Bind("LOG_DESCRIPTION"_s, &Arguments::LogDescription) .Bind("NO_CACHE"_s, &Arguments::NoCache) + .Bind("NO_LOG"_s, &Arguments::NoLog) .Bind("CMAKE_FLAGS"_s, &Arguments::CMakeFlags) .Bind("__CMAKE_INTERNAL"_s, &Arguments::CMakeInternal) /* keep semicolon on own line */; diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index efd58e5..1ec4405 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -75,6 +75,7 @@ public: cm::optional CopyFileError; cm::optional> LogDescription; bool NoCache = false; + bool NoLog = false; // Argument for try_run only. // Keep in sync with warnings in cmCoreTryCompile::ParseArgs. diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index c70c03e..ebbb4f2 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -81,14 +81,15 @@ bool cmTryCompileCommand(std::vector const& args, return true; } - if (cm::optional compileResult = - tc.TryCompileCode(arguments, targetType)) { + cm::optional compileResult = + tc.TryCompileCode(arguments, targetType); #ifndef CMAKE_BOOTSTRAP + if (compileResult && !arguments.NoLog) { if (cmConfigureLog* log = mf.GetCMakeInstance()->GetConfigureLog()) { WriteTryCompileEvent(*log, mf, *compileResult); } -#endif } +#endif // if They specified clean then we clean up what we can if (tc.SrcFileSignature) { diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index ef59c32..a8e8b48 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -246,7 +246,7 @@ bool TryRunCommandImpl::TryRunCode(std::vector const& argv) } #ifndef CMAKE_BOOTSTRAP - if (compileResult) { + if (compileResult && !arguments.NoLog) { cmMakefile const& mf = *(this->Makefile); if (cmConfigureLog* log = mf.GetCMakeInstance()->GetConfigureLog()) { WriteTryRunEvent(*log, mf, *compileResult, runResult); diff --git a/Tests/RunCMake/try_compile/ConfigureLog.cmake b/Tests/RunCMake/try_compile/ConfigureLog.cmake index 4502d24..511ade9 100644 --- a/Tests/RunCMake/try_compile/ConfigureLog.cmake +++ b/Tests/RunCMake/try_compile/ConfigureLog.cmake @@ -7,5 +7,10 @@ try_compile(COMPILE_RESULT try_compile(COMPILE_RESULT SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c + NO_LOG + ) + +try_compile(COMPILE_RESULT + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c LOG_DESCRIPTION "Source that should compile." ) diff --git a/Tests/RunCMake/try_run/ConfigureLog.cmake b/Tests/RunCMake/try_run/ConfigureLog.cmake index 8a4b8a7..e39310c 100644 --- a/Tests/RunCMake/try_run/ConfigureLog.cmake +++ b/Tests/RunCMake/try_run/ConfigureLog.cmake @@ -5,6 +5,11 @@ try_run(RUN_RESULT COMPILE_RESULT try_run(RUN_RESULT COMPILE_RESULT SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c + NO_LOG + ) + +try_run(RUN_RESULT COMPILE_RESULT + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c LOG_DESCRIPTION "Source that should compile." ) -- cgit v0.12