Merge topic 'configure-log'

48292c8624 try_compile: Record stack of in-progess checks in configure log
d4bf7d80c6 try_compile: Add a NO_LOG option to skip recording in the configure log
9d9e8450a8 try_compile: Add optional LOG_DESCRIPTION to record in configure log
65ed5c2ca8 try_compile: Report underlying error when COPY_FILE fails
0418efb7ad Tests: Add explicit ConfigureLog case to RunCMake.try_compile
189557bd74 cmake: Make entire in-progress check stack available internally
96ce3581ab Help: Clarify backtrace order in cmake-configure-log(7)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8072
This commit is contained in:
Brad King
2023-01-17 14:26:40 +00:00
committed by Kitware Robot
27 changed files with 266 additions and 24 deletions
+19
View File
@@ -18,7 +18,9 @@ Try Compiling Whole Projects
SOURCE_DIR <srcdir>
[BINARY_DIR <bindir>]
[TARGET <targetName>]
[LOG_DESCRIPTION <text>]
[NO_CACHE]
[NO_LOG]
[CMAKE_FLAGS <flags>...]
[OUTPUT_VARIABLE <var>])
@@ -47,7 +49,9 @@ which was present in older versions of CMake:
try_compile(<resultVar> <bindir> <srcdir>
<projectName> [<targetName>]
[LOG_DESCRIPTION <text>]
[NO_CACHE]
[NO_LOG]
[CMAKE_FLAGS <flags>...]
[OUTPUT_VARIABLE <var>])
@@ -63,7 +67,9 @@ Try Compiling Source Files
SOURCE_FROM_CONTENT <name> <content> |
SOURCE_FROM_VAR <name> <var> |
SOURCE_FROM_FILE <name> <path> >...
[LOG_DESCRIPTION <text>]
[NO_CACHE]
[NO_LOG]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
@@ -115,7 +121,9 @@ which was present in older versions of CMake:
.. code-block:: cmake
try_compile(<resultVar> <bindir> <srcfile|SOURCES srcfile...>
[LOG_DESCRIPTION <text>]
[NO_CACHE]
[NO_LOG]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
@@ -171,6 +179,12 @@ The options are:
set the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated
project, depending on the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable.
``LOG_DESCRIPTION <text>``
.. versionadded:: 3.26
Specify a non-empty text description of the purpose of the check.
This is recorded in the :manual:`cmake-configure-log(7)` entry.
``NO_CACHE``
.. versionadded:: 3.25
@@ -191,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 <var>``
Store the output from the build process in the given variable.
+4
View File
@@ -17,7 +17,9 @@ Try Compiling and Running Source Files
SOURCE_FROM_CONTENT <name> <content> |
SOURCE_FROM_VAR <name> <var> |
SOURCE_FROM_FILE <name> <path> >...
[LOG_DESCRIPTION <text>]
[NO_CACHE]
[NO_LOG]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
@@ -55,7 +57,9 @@ which was present in older versions of CMake:
try_run(<runResultVar> <compileResultVar>
<bindir> <srcfile|SOURCES srcfile...>
[LOG_DESCRIPTION <text>]
[NO_CACHE]
[NO_LOG]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
+22 -2
View File
@@ -106,6 +106,8 @@ Every event kind is represented by a YAML mapping of the form:
kind: "<kind>-v<major>"
backtrace:
- "<file>:<line> (<function>)"
checks:
- "Checking for something"
#...event-specific keys...
The keys common to all events are:
@@ -115,8 +117,16 @@ The keys common to all events are:
``backtrace``
A YAML block sequence reporting the call stack of CMake source
locations at which the event occurred. Each node is a string
specifying one location formatted as ``<file>:<line> (<function>)``.
locations at which the event occurred, from most-recent to
least-recent. Each node is a string specifying one location
formatted as ``<file>:<line> (<function>)``.
``checks``
An optional key that is present when the event occurred with
at least one pending :command:`message(CHECK_START)`. Its value
is a YAML block sequence reporting the stack of pending checks,
from most-recent to least-recent. Each node is a string containing
a pending check message.
Additional mapping keys are specific to each (versioned) event kind,
described below.
@@ -140,6 +150,9 @@ A ``try_compile-v1`` event is a YAML mapping:
kind: "try_compile-v1"
backtrace:
- "CMakeLists.txt:123 (try_compile)"
checks:
- "Checking for something"
description: "Explicit LOG_DESCRIPTION"
directories:
source: "/path/to/.../TryCompile-01234"
binary: "/path/to/.../TryCompile-01234"
@@ -152,6 +165,10 @@ A ``try_compile-v1`` event is a YAML mapping:
The keys specific to ``try_compile-v1`` mappings are:
``description``
An optional key that is present when the ``LOG_DESCRIPTION <text>`` option
was used. Its value is a string containing the description ``<text>``.
``directories``
A mapping describing the directories associated with the
compilation attempt. It has the following keys:
@@ -206,6 +223,9 @@ A ``try_run-v1`` event is a YAML mapping:
kind: "try_run-v1"
backtrace:
- "CMakeLists.txt:456 (try_run)"
checks:
- "Checking for something"
description: "Explicit LOG_DESCRIPTION"
directories:
source: "/path/to/.../TryCompile-56789"
binary: "/path/to/.../TryCompile-56789"
+8
View File
@@ -6,3 +6,11 @@ Configure Log
* The :manual:`cmake-file-api(7)` gained a new "configureLog" object kind
that enables stable access to the :manual:`cmake-configure-log(7)`.
* 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.
+16
View File
@@ -17,6 +17,7 @@
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -78,6 +79,21 @@ void cmConfigureLog::WriteBacktrace(cmMakefile const& mf)
this->WriteValue("backtrace"_s, backtrace);
}
void cmConfigureLog::WriteChecks(cmMakefile const& mf)
{
if (!mf.GetCMakeInstance()->HasCheckInProgress()) {
return;
}
this->BeginObject("checks"_s);
for (auto const& value :
cmReverseRange(mf.GetCMakeInstance()->GetCheckInProgressMessages())) {
this->BeginLine() << "- ";
this->Encoder->write(value, &this->Stream);
this->EndLine();
}
this->EndObject();
}
void cmConfigureLog::EnsureInit()
{
if (this->Opened) {
+1
View File
@@ -29,6 +29,7 @@ public:
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
void WriteBacktrace(cmMakefile const& mf);
void WriteChecks(cmMakefile const& mf);
void EnsureInit();
+33 -13
View File
@@ -151,7 +151,9 @@ cmArgumentParser<Arguments> makeTryRunParser(
auto const TryCompileBaseArgParser =
cmArgumentParser<Arguments>{}
.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 */;
@@ -1099,23 +1101,35 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
if ((res == 0) && arguments.CopyFileTo) {
std::string const& copyFile = *arguments.CopyFileTo;
if (this->OutputFile.empty() ||
!cmSystemTools::CopyFileAlways(this->OutputFile, copyFile)) {
std::ostringstream emsg;
/* clang-format off */
emsg << "Cannot copy output executable\n"
<< " '" << this->OutputFile << "'\n"
<< "to destination specified by COPY_FILE:\n"
<< " '" << copyFile << "'\n";
/* clang-format on */
if (!this->FindErrorMessage.empty()) {
emsg << this->FindErrorMessage;
cmsys::SystemTools::CopyStatus status =
cmSystemTools::CopyFileAlways(this->OutputFile, copyFile);
if (!status) {
std::string err = status.GetString();
switch (status.Path) {
case cmsys::SystemTools::CopyStatus::SourcePath:
err = cmStrCat(err, " (input)");
break;
case cmsys::SystemTools::CopyStatus::DestPath:
err = cmStrCat(err, " (output)");
break;
default:
break;
}
/* clang-format off */
err = cmStrCat(
"Cannot copy output executable\n",
" '", this->OutputFile, "'\n",
"to destination specified by COPY_FILE:\n",
" '", copyFile, "'\n",
"because:\n",
" ", err, "\n",
this->FindErrorMessage);
/* clang-format on */
if (!arguments.CopyFileError) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, emsg.str());
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, err);
return cm::nullopt;
}
copyFileErrorMessage = emsg.str();
copyFileErrorMessage = std::move(err);
}
}
@@ -1126,6 +1140,9 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
}
cmTryCompileResult result;
if (arguments.LogDescription) {
result.LogDescription = *arguments.LogDescription;
}
result.SourceDirectory = sourceDirectory;
result.BinaryDirectory = this->BinaryDirectory;
result.Variable = *arguments.CompileResultVariable;
@@ -1278,6 +1295,9 @@ void cmCoreTryCompile::WriteTryCompileEventFields(
cmConfigureLog& log, cmTryCompileResult const& compileResult)
{
#ifndef CMAKE_BOOTSTRAP
if (compileResult.LogDescription) {
log.WriteValue("description"_s, *compileResult.LogDescription);
}
log.BeginObject("directories"_s);
log.WriteValue("source"_s, compileResult.SourceDirectory);
log.WriteValue("binary"_s, compileResult.BinaryDirectory);
+4
View File
@@ -21,6 +21,8 @@ class cmRange;
struct cmTryCompileResult
{
cm::optional<std::string> LogDescription;
std::string SourceDirectory;
std::string BinaryDirectory;
@@ -71,7 +73,9 @@ public:
cm::optional<std::string> OutputVariable;
cm::optional<std::string> CopyFileTo;
cm::optional<std::string> CopyFileError;
cm::optional<ArgumentParser::NonEmpty<std::string>> LogDescription;
bool NoCache = false;
bool NoLog = false;
// Argument for try_run only.
// Keep in sync with warnings in cmCoreTryCompile::ParseArgs.
+5 -3
View File
@@ -27,6 +27,7 @@ void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf,
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
log.BeginEvent("try_compile-v1");
log.WriteBacktrace(mf);
log.WriteChecks(mf);
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
log.EndEvent();
}
@@ -81,14 +82,15 @@ bool cmTryCompileCommand(std::vector<std::string> const& args,
return true;
}
if (cm::optional<cmTryCompileResult> compileResult =
tc.TryCompileCode(arguments, targetType)) {
cm::optional<cmTryCompileResult> 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) {
+2 -1
View File
@@ -46,6 +46,7 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
log.BeginEvent("try_run-v1");
log.WriteBacktrace(mf);
log.WriteChecks(mf);
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
log.BeginObject("runResult"_s);
@@ -246,7 +247,7 @@ bool TryRunCommandImpl::TryRunCode(std::vector<std::string> 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);
+8 -5
View File
@@ -9,7 +9,6 @@
#include <map>
#include <memory>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <utility>
@@ -472,13 +471,17 @@ public:
}
std::string GetTopCheckInProgressMessage()
{
auto message = this->CheckInProgressMessages.top();
this->CheckInProgressMessages.pop();
auto message = this->CheckInProgressMessages.back();
this->CheckInProgressMessages.pop_back();
return message;
}
void PushCheckInProgressMessage(std::string message)
{
this->CheckInProgressMessages.emplace(std::move(message));
this->CheckInProgressMessages.emplace_back(std::move(message));
}
std::vector<std::string> const& GetCheckInProgressMessages() const
{
return this->CheckInProgressMessages;
}
//! Should `message` command display context.
@@ -773,7 +776,7 @@ private:
bool LogLevelWasSetViaCLI = false;
bool LogContext = false;
std::stack<std::string> CheckInProgressMessages;
std::vector<std::string> CheckInProgressMessages;
std::unique_ptr<cmGlobalGenerator> GlobalGenerator;
@@ -0,0 +1 @@
#error "This does not compile!"
@@ -0,0 +1,52 @@
^
---
events:
-
kind: "try_compile-v1"
backtrace:
- "[^"]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
- "ConfigureLog.cmake:[0-9]+ \(enable_language\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
checks:
- "Detecting C compiler ABI info"
directories:
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
buildResult:
variable: "CMAKE_C_ABI_COMPILED"
cached: true
stdout: \|.*
exitCode: 0
-
kind: "try_compile-v1"
backtrace:
- "ConfigureLog.cmake:[0-9]+ \(try_compile\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
description: "Source that should not compile\."
directories:
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
buildResult:
variable: "COMPILE_RESULT"
cached: true
stdout: \|.*
exitCode: [1-9][0-9]*
-
kind: "try_compile-v1"
backtrace:
- "ConfigureLog.cmake:[0-9]+ \(try_compile\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
checks:
- "Check 2"
- "Check 1"
description: "Source that should compile\."
directories:
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
buildResult:
variable: "COMPILE_RESULT"
cached: true
stdout: \|.*
exitCode: 0
\.\.\.$
@@ -0,0 +1,4 @@
-- Check 1
-- Check 2
-- Check 2 - passed
-- Check 1 - passed
@@ -0,0 +1,4 @@
int main(void)
{
return 0;
}
@@ -0,0 +1,25 @@
enable_language(C)
try_compile(COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-bad.c
LOG_DESCRIPTION "Source that should not compile."
)
try_compile(COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
NO_LOG
)
message(CHECK_START "Check 1")
message(CHECK_START "Check 2")
try_compile(COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
LOG_DESCRIPTION "Source that should compile."
)
if (COMPILE_RESULT)
message(CHECK_PASS "passed")
message(CHECK_PASS "passed")
else()
message(CHECK_FAIL "failed")
message(CHECK_FAIL "failed")
endif()
@@ -7,3 +7,11 @@ CMake Error at EmptyValueArgs.cmake:[0-9]+ \(try_compile\):
COPY_FILE_ERROR must be followed by a variable name
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
CMake Error at EmptyValueArgs.cmake:[0-9]+ \(try_compile\):
Error after keyword "LOG_DESCRIPTION":
empty string not allowed
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
@@ -5,3 +5,6 @@ try_compile(RESULT ${try_compile_bindir_or_SOURCES}
try_compile(RESULT ${try_compile_bindir_or_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/src.c
COPY_FILE "x" COPY_FILE_ERROR "")
try_compile(RESULT ${try_compile_bindir_or_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/src.c
LOG_DESCRIPTION "")
@@ -8,6 +8,8 @@ events:
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
- "Inspect.cmake:[0-9]+ \(enable_language\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
checks:
- "Detecting C compiler ABI info"
directories:
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
@@ -23,6 +25,8 @@ events:
- "[^"]*/Modules/CMakeTestCXXCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
- "Inspect.cmake:[0-9]+ \(enable_language\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
checks:
- "Detecting CXX compiler ABI info"
directories:
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
@@ -0,0 +1 @@
1
@@ -0,0 +1,7 @@
CMake Error at NoLogDescription.cmake:[0-9]+ \(try_compile\):
Error after keyword "LOG_DESCRIPTION":
missing required value
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
@@ -0,0 +1,4 @@
include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS})
try_compile(RESULT ${try_compile_bindir_or_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/src.c
LOG_DESCRIPTION)
@@ -15,6 +15,7 @@ run_cmake_with_options(Inspect
)
include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake")
run_cmake(ConfigureLog)
run_cmake(NoArgs)
run_cmake(OneArg)
run_cmake(TwoArgs)
@@ -12,6 +12,7 @@ run_cmake(NoCopyFile)
run_cmake(NoCopyFile2)
run_cmake(NoCopyFileError)
run_cmake(NoCStandard)
run_cmake(NoLogDescription)
run_cmake(NoOutputVariable)
run_cmake(NoOutputVariable2)
run_cmake(BadLinkLibraries)
@@ -7,6 +7,8 @@ events:
- "[^"]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
- "CMakeLists.txt:[0-9]+ \(project\)"
checks:
- "Detecting C compiler ABI info"
directories:
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
@@ -20,6 +22,7 @@ events:
backtrace:
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
description: "Source that should not compile\."
directories:
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
@@ -36,6 +39,9 @@ events:
backtrace:
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
checks:
- "Check 1"
description: "Source that should compile\."
directories:
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
@@ -57,6 +63,9 @@ events:
backtrace:
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
- "CMakeLists.txt:[0-9]+ \(include\)"
checks:
- "Check 2"
- "Check 1"
directories:
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
@@ -0,0 +1,4 @@
-- Check 1
-- Check 2
-- Check 2 - passed
-- Check 1 - passed
+16
View File
@@ -1,15 +1,31 @@
try_run(RUN_RESULT COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-bad.c
LOG_DESCRIPTION "Source that should not compile."
)
try_run(RUN_RESULT COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
NO_LOG
)
message(CHECK_START "Check 1")
try_run(RUN_RESULT COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
LOG_DESCRIPTION "Source that should compile."
)
message(CHECK_START "Check 2")
try_run(RUN_RESULT COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
RUN_OUTPUT_VARIABLE RUN_OUTPUT
)
if (RUN_RESULT)
message(CHECK_PASS "passed")
message(CHECK_PASS "passed")
else()
message(CHECK_FAIL "failed")
message(CHECK_FAIL "failed")
endif()
try_run(RUN_RESULT COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c