From d2b856bc9219d7176ae8fd394843151e27021a8e Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Sat, 1 May 2021 16:10:43 +0200 Subject: [PATCH] ctest_build: Add the PARALLEL_LEVEL argument Fixes: #19712 --- Help/command/ctest_build.rst | 8 ++++++++ .../dev/generate-cmake-build-command-parallel.rst | 2 ++ Source/CTest/cmCTestBuildCommand.cxx | 3 ++- Source/CTest/cmCTestBuildCommand.h | 1 + Tests/RunCMake/ctest_build/ParallelLevel-check.cmake | 11 +++++++++++ Tests/RunCMake/ctest_build/RunCMakeTest.cmake | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/ctest_build/ParallelLevel-check.cmake diff --git a/Help/command/ctest_build.rst b/Help/command/ctest_build.rst index 4d6dc5a43a..e05df1afcd 100644 --- a/Help/command/ctest_build.rst +++ b/Help/command/ctest_build.rst @@ -7,6 +7,7 @@ Perform the :ref:`CTest Build Step` as a :ref:`Dashboard Client`. ctest_build([BUILD ] [APPEND] [CONFIGURATION ] + [PARALLEL_LEVEL ] [FLAGS ] [PROJECT_NAME ] [TARGET ] @@ -42,6 +43,13 @@ The options are: Otherwise the ``-C `` option given to the :manual:`ctest(1)` command will be used, if any. +``PARALLEL_LEVEL `` + .. versionadded:: 3.21 + + Specify the parallel level of the underlying build system. If not + specified, the :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment + variable will be checked. + ``FLAGS `` Pass additional arguments to the underlying build command. If not specified the ``CTEST_BUILD_FLAGS`` variable will be checked. diff --git a/Help/release/dev/generate-cmake-build-command-parallel.rst b/Help/release/dev/generate-cmake-build-command-parallel.rst index 8d3b7d7949..1b8dd40acb 100644 --- a/Help/release/dev/generate-cmake-build-command-parallel.rst +++ b/Help/release/dev/generate-cmake-build-command-parallel.rst @@ -2,3 +2,5 @@ generate-cmake-build-command-parallel ------------------------------------- * The :command:`build_command` command gained a ``PARALLEL_LEVEL`` option. + +* The :command:`ctest_build` command gained a ``PARALLEL_LEVEL`` option. diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 099d1e2de4..483c316a63 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -27,6 +27,7 @@ void cmCTestBuildCommand::BindArguments() this->Bind("CONFIGURATION"_s, this->Configuration); this->Bind("FLAGS"_s, this->Flags); this->Bind("PROJECT_NAME"_s, this->ProjectName); + this->Bind("PARALLEL_LEVEL"_s, this->ParallelLevel); } cmCTestBuildCommand::~cmCTestBuildCommand() = default; @@ -98,7 +99,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator->GenerateCMakeBuildCommand( - cmakeBuildTarget, cmakeBuildConfiguration, "", + cmakeBuildTarget, cmakeBuildConfiguration, this->ParallelLevel, cmakeBuildAdditionalFlags, this->Makefile->IgnoreErrorsCMP0061()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand << "\n", diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 00dbcc451b..1254dad9bb 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -60,4 +60,5 @@ protected: std::string Configuration; std::string Flags; std::string ProjectName; + std::string ParallelLevel; }; diff --git a/Tests/RunCMake/ctest_build/ParallelLevel-check.cmake b/Tests/RunCMake/ctest_build/ParallelLevel-check.cmake new file mode 100644 index 0000000000..f45d2a29f5 --- /dev/null +++ b/Tests/RunCMake/ctest_build/ParallelLevel-check.cmake @@ -0,0 +1,11 @@ +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(STRINGS "${build_xml_file}" build_cmd LIMIT_COUNT 1 REGEX "") + if(NOT build_cmd MATCHES [[ --parallel "1"]]) + set(RunCMake_TEST_FAILED + "Build.xml does not have expected build command with --parallel flag" + ) + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index 072fbac223..511cd71fbb 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -10,6 +10,7 @@ function(run_ctest_build CASE_NAME) endfunction() run_ctest_build(BuildQuiet QUIET) +run_ctest_build(ParallelLevel PARALLEL_LEVEL 1) function(run_BuildFailure) set(CASE_CMAKELISTS_SUFFIX_CODE [[