diff options
| author | Brad King <brad.king@kitware.com> | 2021-06-29 17:34:28 (GMT) |
|---|---|---|
| committer | Brad King <brad.king@kitware.com> | 2021-06-30 14:55:40 (GMT) |
| commit | e216b9bbd331e77e59634690a2be98f087acaf2c (patch) | |
| tree | bbbb4bc6d552751772045ad3993dba2ba70b8536 /Tests/RunCMake/CommandLine/RunCMakeTest.cmake | |
| parent | 6986a382a912f4b982f4b20a6e04ff1d773ef1eb (diff) | |
| download | CMake-e216b9bbd331e77e59634690a2be98f087acaf2c.zip CMake-e216b9bbd331e77e59634690a2be98f087acaf2c.tar.gz CMake-e216b9bbd331e77e59634690a2be98f087acaf2c.tar.bz2 | |
cmake: Allow CMAKE_BUILD_TYPE to be set by environment variable
When no `CMAKE_BUILD_TYPE` is explicitly specified while creating a new
build tree, check for an environment variable of the same name.
Issue: #20983
Diffstat (limited to 'Tests/RunCMake/CommandLine/RunCMakeTest.cmake')
| -rw-r--r-- | Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index c58b1d0..e86e663 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -344,6 +344,17 @@ if(RunCMake_GENERATOR MATCHES "Unix Makefiles" OR RunCMake_GENERATOR MATCHES "Ni run_EnvironmentExportCompileCommands() endif() +function(run_EnvironmentBuildType) + set(ENV{CMAKE_BUILD_TYPE} "BuildTypeEnv") + run_cmake(EnvBuildType) + run_cmake_with_options(EnvBuildTypeIgnore -DCMAKE_BUILD_TYPE=BuildTypeOpt) + unset(ENV{CMAKE_BUILD_TYPE}) +endfunction() + +if(RunCMake_GENERATOR MATCHES "Make|^Ninja$") + run_EnvironmentBuildType() +endif() + function(run_EnvironmentToolchain) set(ENV{CMAKE_TOOLCHAIN_FILE} "${RunCMake_SOURCE_DIR}/EnvToolchain-toolchain.cmake") run_cmake(EnvToolchainAbsolute) |
