diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-07-03 18:23:47 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-07-06 17:43:52 +0200 |
commit | dd775972527f1be31ddd9db906619c593bb29002 (patch) | |
tree | 34daa86c039b8444d655b89017b6c5f70f4f9cbe | |
parent | ab559e25af74f6f83a4fcf4f4a19a8db5b5a89a9 (diff) |
CMake: Support build config-related configure options
This add support for the following options: -debug, -release,
-debug-and-release. For the latter, the "Ninja Multi-Config" generator
is auto-detected, if ninja is available.
Task-number: QTBUG-85373
Change-Id: Ide0ca44e5f4c74657147e89d71e8d71c4f6a4c45
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 1142a5c557..63e168af90 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -31,6 +31,7 @@ list(FILTER configure_args EXCLUDE REGEX "^[ \t]*$") list(TRANSFORM configure_args STRIP) unset(generator) set(auto_detect_generator TRUE) +unset(build_configs) while(configure_args) list(POP_FRONT configure_args arg) if(arg STREQUAL "-cmake") @@ -105,6 +106,12 @@ while(configure_args) elseif(arg STREQUAL "-plugindir") list(POP_FRONT configure_args dir) push("-DINSTALL_PLUGINSDIR=${dir}") + elseif(arg STREQUAL "-release") + set(build_configs "Release") + elseif(arg STREQUAL "-debug") + set(build_configs "Debug") + elseif(arg STREQUAL "-debug-and-release") + set(build_configs Debug Release) elseif(arg STREQUAL "--") # Everything after this argument will be passed to CMake verbatim. push(${configure_args}) @@ -114,10 +121,24 @@ while(configure_args) endif() endwhile() +list(LENGTH build_configs nr_of_build_configs) +if(nr_of_build_configs EQUAL 1) + push("-DCMAKE_BUILD_TYPE=${build_configs}") +elseif(nr_of_build_configs GREATER 1) + set(multi_config ON) + string(REPLACE ";" "\\;" escaped_build_configs "${build_configs}") + # We must not use the push macro here to avoid variable expansion. + # That would destroy our escaping. + list(APPEND cmake_args "-DCMAKE_CONFIGURATION_TYPES=${escaped_build_configs}") +endif() + if(NOT generator AND auto_detect_generator) find_program(ninja ninja) if(ninja) set(generator Ninja) + if(multi_config) + string(APPEND generator " Multi-Config") + endif() else() if(CMAKE_HOST_UNIX) set(generator "Unix Makefiles") |