ctest: Populate CTEST_CONFIGURATION_TYPE from the -C command line when set

This commit is contained in:
Julien Jomier
2019-12-03 11:23:02 +01:00
committed by Kyle Edwards
parent c57bcf3b30
commit e6f758be6d
7 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
ctest-configuration-type
------------------------
* The :variable:`CTEST_CONFIGURATION_TYPE` variable is now set from the command
line when :manual:`ctest(1)` is invoked with ``-C <cfg>``.

View File

@@ -3,3 +3,6 @@ CTEST_CONFIGURATION_TYPE
Specify the CTest ``DefaultCTestConfigurationType`` setting
in a :manual:`ctest(1)` dashboard client script.
If the configuration type is set via ``-C <cfg>`` from the command line
then this variable is populated accordingly.

View File

@@ -340,6 +340,13 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->SetRunCurrentScript(true);
this->UpdateElapsedTime();
// set the CTEST_CONFIGURATION_TYPE variable to the current value of the
// the -C argument on the command line.
if (!this->CTest->GetConfigType().empty()) {
this->Makefile->AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType());
}
// add the script arg if defined
if (!script_arg.empty()) {
this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg);

View File

@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.1)
project(CTestCommandLine@CASE_NAME@ NONE)
include(CTest)
add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version)

View File

@@ -1,4 +1,6 @@
include(RunCMake)
include(RunCTest)
set(RunCMake_TEST_TIMEOUT 60)
unset(ENV{CTEST_PARALLEL_LEVEL})
@@ -311,3 +313,6 @@ function(run_ShowOnly)
run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1)
endfunction()
run_ShowOnly()
# Check the configuration type variable is passed
run_ctest(check-configuration-type)

View File

@@ -0,0 +1,2 @@
Command line CTEST_CONFIGURATION_TYPE=Debug
set CTEST_CONFIGURATION_TYPE=Release

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.1)
set(CTEST_SITE "test-site")
set(CTEST_BUILD_NAME "test-build-name")
set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_COMMAND "@CMAKE_CTEST_COMMAND@")
if("@CASE_NAME@" MATCHES "^check-configuration-type")
message("Command line CTEST_CONFIGURATION_TYPE=" ${CTEST_CONFIGURATION_TYPE})
set(CTEST_CONFIGURATION_TYPE "Release")
message("set CTEST_CONFIGURATION_TYPE=" ${CTEST_CONFIGURATION_TYPE})
ctest_start(Experimental)
endif()