mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
Merge topic 'trace-try_compile'
5ba51621af try_compile: Propagate --trace through try_compile
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7757
This commit is contained in:
5
Help/release/dev/trace-try_compile.rst
Normal file
5
Help/release/dev/trace-try_compile.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
trace-try_compile
|
||||
-----------------
|
||||
|
||||
* The :option:`cmake --trace` option now follows :command:`try_compile` and
|
||||
:command:`try_run` invocations.
|
||||
@@ -3584,6 +3584,9 @@ int cmMakefile::TryCompile(const std::string& srcdir,
|
||||
gg->RecursionDepth = this->RecursionDepth;
|
||||
cm.SetGlobalGenerator(std::move(gg));
|
||||
|
||||
// copy trace state
|
||||
cm.SetTraceRedirect(this->GetCMakeInstance());
|
||||
|
||||
// do a configure
|
||||
cm.SetHomeDirectory(srcdir);
|
||||
cm.SetHomeOutputDirectory(bindir);
|
||||
|
||||
@@ -1537,6 +1537,16 @@ void cmake::PrintTraceFormatVersion()
|
||||
}
|
||||
}
|
||||
|
||||
void cmake::SetTraceRedirect(cmake* other)
|
||||
{
|
||||
this->Trace = other->Trace;
|
||||
this->TraceExpand = other->TraceExpand;
|
||||
this->TraceFormatVar = other->TraceFormatVar;
|
||||
this->TraceOnlyThisSources = other->TraceOnlyThisSources;
|
||||
|
||||
this->TraceRedirect = other;
|
||||
}
|
||||
|
||||
bool cmake::SetDirectoriesFromFile(const std::string& arg)
|
||||
{
|
||||
// Check if the argument refers to a CMakeCache.txt or
|
||||
|
||||
@@ -513,10 +513,19 @@ public:
|
||||
{
|
||||
return this->TraceOnlyThisSources;
|
||||
}
|
||||
cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; }
|
||||
cmGeneratedFileStream& GetTraceFile()
|
||||
{
|
||||
if (this->TraceRedirect) {
|
||||
return this->TraceRedirect->GetTraceFile();
|
||||
}
|
||||
return this->TraceFile;
|
||||
}
|
||||
void SetTraceFile(std::string const& file);
|
||||
void PrintTraceFormatVersion();
|
||||
|
||||
//! 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; }
|
||||
@@ -677,6 +686,7 @@ private:
|
||||
bool TraceExpand = false;
|
||||
TraceFormat TraceFormatVar = TRACE_HUMAN;
|
||||
cmGeneratedFileStream TraceFile;
|
||||
cmake* TraceRedirect = nullptr;
|
||||
bool WarnUninitialized = false;
|
||||
bool WarnUnusedCli = true;
|
||||
bool CheckSystemVars = false;
|
||||
|
||||
@@ -940,6 +940,7 @@ unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --trace)
|
||||
run_cmake(trace)
|
||||
run_cmake(trace-try_compile)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --trace-expand)
|
||||
@@ -952,6 +953,7 @@ unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --trace-redirect=${RunCMake_BINARY_DIR}/redirected.trace)
|
||||
run_cmake(trace-redirect)
|
||||
run_cmake(trace-try_compile-redirect)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
file(READ ${RunCMake_SOURCE_DIR}/trace-try_compile-stderr.txt expected_content)
|
||||
string(REGEX REPLACE "\n+$" "" expected_content "${expected_content}")
|
||||
|
||||
file(READ ${RunCMake_BINARY_DIR}/redirected.trace actual_content)
|
||||
string(REGEX REPLACE "\r\n" "\n" actual_content "${actual_content}")
|
||||
string(REGEX REPLACE "\n+$" "" actual_content "${actual_content}")
|
||||
if(NOT "${actual_content}" MATCHES "${expected_content}")
|
||||
set(RunCMake_TEST_FAILED
|
||||
"Trace file content does not match that expected."
|
||||
"Expected to match:\n${expected_content}\n"
|
||||
"Actual content:\n${actual_content}\n"
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,2 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(test C)
|
||||
4
Tests/RunCMake/CommandLine/trace-try_compile-stderr.txt
Normal file
4
Tests/RunCMake/CommandLine/trace-try_compile-stderr.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
.*Modules/CMakeDetermineCompilerABI.cmake\([0-9]+\): try_compile\([^)]+\)
|
||||
.*Tests/RunCMake/CommandLine/trace-try_compile(-redirect)?-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+/CMakeLists.txt\([0-9]+\): cmake_minimum_required.*
|
||||
.*Tests/RunCMake/CommandLine/trace-try_compile(-redirect)?-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+/CMakeLists.txt\([0-9]+\): project\(CMAKE_TRY_COMPILE.*
|
||||
.*Tests/RunCMake/CommandLine/trace-try_compile(-redirect)?-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+/CMakeLists.txt\([0-9]+\): add_executable\(cmTC_.*
|
||||
2
Tests/RunCMake/CommandLine/trace-try_compile.cmake
Normal file
2
Tests/RunCMake/CommandLine/trace-try_compile.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(test C)
|
||||
Reference in New Issue
Block a user