diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-07-03 12:25:44 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-07-06 17:43:35 +0200 |
commit | 3ac054d6a8bdf13dad764f9e2dea359a93e540f5 (patch) | |
tree | c974ce31279891a2f1e76a3d65aa96354cf25ea6 | |
parent | dbd3c7596542ab100a794831f1f28ea00be77a0f (diff) |
CMake: Re-work configure flags for CMake generators
Remove the -cmake-makefiles configure argument as its meaning was in
essence "do not pass a -G argument to CMake".
Instead, we add the following arguments:
-cmake-generator <name> to pass -G <name> to CMake
-cmake-use-default-generator to pass no -G argument to CMake
If none of those arguments is given, we try to autodetect the
generator. If a ninja executable is found, we prefer the Ninja
generator. On Unix we fall back to "Unix Makefiles".
On Windows, we do a poor man's compiler detection and select one of
"NMake Makefiles", "NMake Makefiles JOM" and "MinGW Makefiles".
Change-Id: Ic36669bd50956d15fbc71cee73720732cd4bfab8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 34 | ||||
-rw-r--r-- | config_help.txt | 5 |
2 files changed, 34 insertions, 5 deletions
diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index f7c771ecf7..5d7a076ee0 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -29,13 +29,16 @@ get_filename_component(source_dir ".." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_D file(STRINGS "${OPTFILE}" configure_args) list(FILTER configure_args EXCLUDE REGEX "^[ \t]*$") list(TRANSFORM configure_args STRIP) -set(set_generator TRUE) +unset(generator) +set(auto_detect_generator TRUE) while(configure_args) list(POP_FRONT configure_args arg) if(arg STREQUAL "-cmake") # ignore - elseif(arg STREQUAL "-cmake-makefiles") - set(set_generator FALSE) + elseif(arg STREQUAL "-cmake-generator") + list(POP_FRONT configure_args generator) + elseif(arg STREQUAL "-cmake-use-default-generator") + set(auto_detect_generator FALSE) elseif(arg STREQUAL "-top-level") get_filename_component(source_dir "../.." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") elseif(arg STREQUAL "-skip") @@ -101,8 +104,29 @@ while(configure_args) endif() endwhile() -if(set_generator) - push(-G Ninja) +if(NOT generator AND auto_detect_generator) + find_program(ninja ninja) + if(ninja) + set(generator Ninja) + else() + if(CMAKE_HOST_UNIX) + set(generator "Unix Makefiles") + elseif(CMAKE_HOST_WINDOWS) + find_program(msvc_compiler cl.exe) + if(msvc_compiler) + set(generator "NMake Makefiles") + find_program(jom jom) + if(jom) + string(APPEND generator " JOM") + endif() + else() + set(generator "MinGW Makefiles") + endif() + endif() + endif() +endif() +if(generator) + push(-G "${generator}") endif() push("${source_dir}") diff --git a/config_help.txt b/config_help.txt index 1a651fa3f4..db9587dd20 100644 --- a/config_help.txt +++ b/config_help.txt @@ -85,6 +85,11 @@ Build options: -commercial .......... Build the Commercial Edition of Qt -confirm-license ..... Automatically acknowledge the license + -cmake ............... Use the CMake build system instead of the qmake one. + -cmake-generator <name> ... Explicitly specify the build system generator for + CMake instead of auto-detecting one. + -cmake-use-default-generator ... Turn off auto-detection of the CMake build + system generator. -release ............. Build Qt with debugging turned off [yes] -debug ............... Build Qt with debugging turned on [no] -debug-and-release ... Build two versions of Qt, with and without |