diff options
Diffstat (limited to 'Source/cmTryCompileCommand.cxx')
| -rw-r--r-- | Source/cmTryCompileCommand.cxx | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index a2c4ce1..c70c03e 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -2,6 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTryCompileCommand.h" +#include <cm/optional> + +#include "cmConfigureLog.h" #include "cmCoreTryCompile.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" @@ -13,6 +16,24 @@ #include "cmValue.h" #include "cmake.h" +namespace { +#ifndef CMAKE_BOOTSTRAP +void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf, + cmTryCompileResult const& compileResult) +{ + // Keep in sync with cmFileAPIConfigureLog's DumpEventKindNames. + static const std::vector<unsigned long> LogVersionsWithTryCompileV1{ 1 }; + + if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) { + log.BeginEvent("try_compile-v1"); + log.WriteBacktrace(mf); + cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult); + log.EndEvent(); + } +} +#endif +} + bool cmTryCompileCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { @@ -59,7 +80,15 @@ bool cmTryCompileCommand(std::vector<std::string> const& args, if (!arguments) { return true; } - tc.TryCompileCode(arguments, targetType); + + if (cm::optional<cmTryCompileResult> compileResult = + tc.TryCompileCode(arguments, targetType)) { +#ifndef CMAKE_BOOTSTRAP + if (cmConfigureLog* log = mf.GetCMakeInstance()->GetConfigureLog()) { + WriteTryCompileEvent(*log, mf, *compileResult); + } +#endif + } // if They specified clean then we clean up what we can if (tc.SrcFileSignature) { |
