1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 17:31:57 +08:00

instrumentation: Exclude (pre|post)Build hooks with MSYS Makefiles

The implementation of (pre|post)Build hooks rely on a direct parent-
child relationship between the build system process and `ctest
--start-instrumentation`. MSYS2's `make.exe` uses the msys-runtime POSIX
compatibility layer which disrupts this relationship.
This commit is contained in:
Tyler Yankee
2025-07-21 13:12:43 -04:00
parent 455944508e
commit f7756853c5
3 changed files with 20 additions and 6 deletions

View File

@@ -196,6 +196,9 @@ key is required, but all other fields are optional.
* ``postInstall`` * ``postInstall``
* ``postTest`` * ``postTest``
``preBuild`` and ``postBuild`` are not supported with the
:generator:`MSYS Makefiles` generator.
``options`` ``options``
A list of strings used to enable certain optional behavior, including the A list of strings used to enable certain optional behavior, including the
collection of certain additional data. Elements in this list should be one of collection of certain additional data. Elements in this list should be one of

View File

@@ -691,7 +691,9 @@ void cmLocalUnixMakefileGenerator3::WriteMakeVariables(
#ifndef CMAKE_BOOTSTRAP #ifndef CMAKE_BOOTSTRAP
if (this->GetCMakeInstance() if (this->GetCMakeInstance()
->GetInstrumentation() ->GetInstrumentation()
->HasPreOrPostBuildHook()) { ->HasPreOrPostBuildHook() &&
// FIXME(#27079): This does not work for MSYS Makefiles.
this->GlobalGenerator->GetName() != "MSYS Makefiles") {
std::string ctestShellCommand = std::string ctestShellCommand =
getShellCommand(cmSystemTools::GetCTestCommand()); getShellCommand(cmSystemTools::GetCTestCommand());
makefileStream << "# The CTest executable.\n" makefileStream << "# The CTest executable.\n"
@@ -850,8 +852,11 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom(
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
commands.push_back(std::move(runRule)); commands.push_back(std::move(runRule));
#ifndef CMAKE_BOOTSTRAP #ifndef CMAKE_BOOTSTRAP
addInstrumentationCommand(this->GetCMakeInstance()->GetInstrumentation(), // FIXME(#27079): This does not work for MSYS Makefiles.
commands); if (this->GlobalGenerator->GetName() != "MSYS Makefiles") {
addInstrumentationCommand(this->GetCMakeInstance()->GetInstrumentation(),
commands);
}
#endif #endif
if (!this->IsRootMakefile()) { if (!this->IsRootMakefile()) {
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
@@ -1856,8 +1861,11 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
" 1"); " 1");
commands.push_back(std::move(runRule)); commands.push_back(std::move(runRule));
#ifndef CMAKE_BOOTSTRAP #ifndef CMAKE_BOOTSTRAP
addInstrumentationCommand(this->GetCMakeInstance()->GetInstrumentation(), // FIXME(#27079): This does not work for MSYS Makefiles.
commands); if (this->GlobalGenerator->GetName() != "MSYS Makefiles") {
addInstrumentationCommand(
this->GetCMakeInstance()->GetInstrumentation(), commands);
}
#endif #endif
} }
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),

View File

@@ -129,7 +129,10 @@ instrument(cmake-command-resets-generated NO_WARN
CHECK_SCRIPT check-data-dir.cmake CHECK_SCRIPT check-data-dir.cmake
) )
if(RunCMake_GENERATOR STREQUAL "NMake Makefiles") if(RunCMake_GENERATOR STREQUAL "MSYS Makefiles")
# FIXME(#27079): This does not work for MSYS Makefiles.
set(Skip_BUILD_MAKE_PROGRAM_Case 1)
elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles")
execute_process( execute_process(
COMMAND "${RunCMake_MAKE_PROGRAM}" -? COMMAND "${RunCMake_MAKE_PROGRAM}" -?
OUTPUT_VARIABLE nmake_out OUTPUT_VARIABLE nmake_out