diff options
author | Brad King <brad.king@kitware.com> | 2021-06-29 20:58:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-06-30 14:55:40 (GMT) |
commit | ef56eefc9bb9ae0ad23c80c01a3e15086dcf207e (patch) | |
tree | 274a1fe332a115cc18061c7c026e367a75c63226 /Tests | |
parent | e216b9bbd331e77e59634690a2be98f087acaf2c (diff) | |
download | CMake-ef56eefc9bb9ae0ad23c80c01a3e15086dcf207e.zip CMake-ef56eefc9bb9ae0ad23c80c01a3e15086dcf207e.tar.gz CMake-ef56eefc9bb9ae0ad23c80c01a3e15086dcf207e.tar.bz2 |
cmake: Allow CMAKE_CONFIGURATION_TYPES to be set by environment variable
When no `CMAKE_CONFIGURATION_TYPES` is explicitly specified while
creating a new build tree, check for an environment variable of the same
name.
Issue: #20983
Diffstat (limited to 'Tests')
5 files changed, 16 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypes-stdout.txt b/Tests/RunCMake/CommandLine/EnvConfigTypes-stdout.txt new file mode 100644 index 0000000..bfec18f --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypes-stdout.txt @@ -0,0 +1,2 @@ +-- ENV{CMAKE_CONFIGURATION_TYPES}='ConfigTypesEnv' +-- CMAKE_CONFIGURATION_TYPES='ConfigTypesEnv' diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypes.cmake b/Tests/RunCMake/CommandLine/EnvConfigTypes.cmake new file mode 100644 index 0000000..8c9b63a --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypes.cmake @@ -0,0 +1,2 @@ +message(STATUS "ENV{CMAKE_CONFIGURATION_TYPES}='$ENV{CMAKE_CONFIGURATION_TYPES}'") +message(STATUS "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}'") diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore-stdout.txt b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore-stdout.txt new file mode 100644 index 0000000..7800a4f --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore-stdout.txt @@ -0,0 +1,2 @@ +-- ENV{CMAKE_CONFIGURATION_TYPES}='ConfigTypesEnv' +-- CMAKE_CONFIGURATION_TYPES='ConfigTypesOpt' diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore.cmake b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore.cmake new file mode 100644 index 0000000..fcbbaea --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore.cmake @@ -0,0 +1 @@ +include(EnvConfigTypes.cmake) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index e86e663..0b26b89 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -351,8 +351,17 @@ function(run_EnvironmentBuildType) unset(ENV{CMAKE_BUILD_TYPE}) endfunction() +function(run_EnvironmentConfigTypes) + set(ENV{CMAKE_CONFIGURATION_TYPES} "ConfigTypesEnv") + run_cmake(EnvConfigTypes) + run_cmake_with_options(EnvConfigTypesIgnore -DCMAKE_CONFIGURATION_TYPES=ConfigTypesOpt) + unset(ENV{CMAKE_CONFIGURATION_TYPES}) +endfunction() + if(RunCMake_GENERATOR MATCHES "Make|^Ninja$") run_EnvironmentBuildType() +elseif(RunCMake_GENERATOR MATCHES "Ninja Multi-Config|Visual Studio|Xcode") + run_EnvironmentConfigTypes() endif() function(run_EnvironmentToolchain) |