mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
A parallel `cmake --build` with a Makefiles generator interleaved the output of concurrent recipes. When CMake is the one passing the parallel flag and a build-time probe finds GNU Make 4.0 or newer, append `-Otarget` so each recipe's output stays grouped. A native `-- -j` leaves the job count unset and opts out. Honor `USES_TERMINAL` under grouping by prefixing such recipes with a `$(CMAKE_USES_TERMINAL_PREFIX)` variable, empty by default and set to `+` next to `-Otarget`, so interactive commands stay unbuffered. Fixes: #27510
68 lines
1.7 KiB
C
68 lines
1.7 KiB
C
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
|
|
/* Stand-in for "make" used by the RunCMake.Make output-sync tests so they can
|
|
assert what "cmake --build" passes to make without a real make tool.
|
|
|
|
On "--version" (the output-sync probe): touch $FAKE_MAKE_PROBE_MARKER, print
|
|
$FAKE_MAKE_VERSION (default a GNU Make 4.x banner), and exit with
|
|
$FAKE_MAKE_VERSION_RESULT (default 0).
|
|
Otherwise (the build): append the argument list to $FAKE_MAKE_RECORD and
|
|
exit 0. */
|
|
|
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
|
# define _CRT_SECURE_NO_WARNINGS
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
int i;
|
|
int isVersion = 0;
|
|
|
|
for (i = 1; i < argc; ++i) {
|
|
if (strcmp(argv[i], "--version") == 0) {
|
|
isVersion = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (isVersion) {
|
|
char const* marker = getenv("FAKE_MAKE_PROBE_MARKER");
|
|
char const* banner = getenv("FAKE_MAKE_VERSION");
|
|
char const* result = getenv("FAKE_MAKE_VERSION_RESULT");
|
|
if (marker) {
|
|
FILE* f = fopen(marker, "a");
|
|
if (f) {
|
|
fprintf(f, "probe\n");
|
|
fclose(f);
|
|
}
|
|
}
|
|
if (!banner) {
|
|
banner = "GNU Make 4.4.1";
|
|
}
|
|
if (banner[0] != '\0') {
|
|
printf("%s\n", banner);
|
|
}
|
|
return result ? atoi(result) : 0;
|
|
}
|
|
|
|
{
|
|
char const* record = getenv("FAKE_MAKE_RECORD");
|
|
if (record) {
|
|
FILE* f = fopen(record, "a");
|
|
if (f) {
|
|
for (i = 1; i < argc; ++i) {
|
|
fprintf(f, "%s%s", i > 1 ? " " : "", argv[i]);
|
|
}
|
|
fprintf(f, "\n");
|
|
fclose(f);
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|