diff options
author | Amir Masoud Abdol <amir.abdol@qt.io> | 2023-02-08 12:08:37 +0100 |
---|---|---|
committer | Amir Masoud Abdol <amir.abdol@qt.io> | 2023-02-09 04:23:06 +0100 |
commit | ed26352a1009ce37fe792c023af9e5d6259ea6d4 (patch) | |
tree | dd20dad69070910ae3c1631b393153fee1d51286 | |
parent | 48a1a5564f89e1e8f0b6f4a28398e4ae0b3f751c (diff) |
Add -unity-build, and -unity-build-batch-size to configure
If -unity-build-batch-size is not given, we default to CMake's default
which is 8. In QtSetup.cmake, we explicitly set the default to avoid
having it set to OFF in case it is missing, just to make sure that we
don't get any unintended behavior.
Task-number: QTBUG-109394
Change-Id: I19849e9baa507b64fb23847c740e20a7adc61b8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/QtBuildInternalsExtra.cmake.in | 4 | ||||
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 7 | ||||
-rw-r--r-- | cmake/QtSetup.cmake | 7 | ||||
-rw-r--r-- | cmake/configure-cmake-mapping.md | 2 | ||||
-rw-r--r-- | config_help.txt | 4 |
5 files changed, 24 insertions, 0 deletions
diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index 49d929b666..2dc906b6c6 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -103,6 +103,10 @@ set(QT_BUILD_EXAMPLES_AS_EXTERNAL "@QT_BUILD_EXAMPLES_AS_EXTERNAL@" CACHE BOOL # Propagate usage of ccache. set(QT_USE_CCACHE @QT_USE_CCACHE@ CACHE BOOL "Enable the use of ccache") +# Propagate usage of unity build. +set(QT_UNITY_BUILD @QT_UNITY_BUILD@ CACHE BOOL "Enable unity (jumbo) build") +set(QT_UNITY_BUILD_BATCH_SIZE "@QT_UNITY_BUILD_BATCH_SIZE@" CACHE STRING "Unity build batch size") + # Propragate the value of WARNINGS_ARE_ERRORS. set(WARNINGS_ARE_ERRORS "@WARNINGS_ARE_ERRORS@" CACHE BOOL "Build Qt with warnings as errors") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index e5b4b36d49..0572fbbd5b 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -135,6 +135,13 @@ while(NOT "${configure_args}" STREQUAL "") list(POP_FRONT configure_args version) is_valid_qt_hex_version("${arg}" "${version}") push("-DQT_DISABLE_DEPRECATED_UP_TO=${version}") + elseif(arg STREQUAL "-unity-build") + push("-DQT_UNITY_BUILD=ON") + # QT_UNITY_BUILD_BATCH_SIZE will be set to 8, CMake's default. + elseif(arg STREQUAL "-unity-build-batch-size") + list(POP_FRONT configure_args unity_build_batch_size) + is_non_empty_valid_arg("${arg}" "${unity_build_batch_size}") + push("-DQT_UNITY_BUILD_BATCH_SIZE=${unity_build_batch_size}") elseif(arg STREQUAL "--") # Everything after this argument will be passed to CMake verbatim. list(APPEND cmake_args "${configure_args}") diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index dd656ef70c..cbd12e6af9 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -331,6 +331,13 @@ if(QT_USE_CCACHE) endif() endif() +option(QT_UNITY_BUILD "Enable unity (jumbo) build") +set(QT_UNITY_BUILD_BATCH_SIZE "8" CACHE STRING "Unity build batch size") +if(QT_UNITY_BUILD) + set(CMAKE_UNITY_BUILD ON) + set(CMAKE_UNITY_BUILD_BATCH_SIZE "${QT_UNITY_BUILD_BATCH_SIZE}") +endif() + # We need to clean up QT_FEATURE_*, but only once per configuration cycle get_property(qt_feature_clean GLOBAL PROPERTY _qt_feature_clean) if(NOT qt_feature_clean) diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index b217b65579..4ef2869d24 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -74,6 +74,8 @@ The following table describes the mapping of configure options to CMake argument | | | custom build steps for moc, uic, and rcc. | | | | This lacks support in CMake. | | -ccache | -DQT_USE_CCACHE=ON | | +| -unity-build | -DQT_UNITY_BUILD=ON | | +| -unity-build-batch-size <int> | -DQT_UNITY_BUILD_BATCH_SIZE=<int> | | | -make-tool <tool> | n/a | | | -mp | n/a | | | -warnings-are-errors | -DWARNINGS_ARE_ERRORS=ON | | diff --git a/config_help.txt b/config_help.txt index 9fc0b38042..c0b0b79b47 100644 --- a/config_help.txt +++ b/config_help.txt @@ -140,6 +140,10 @@ Build options: Force use of the GNU ld, GNU gold, LLVM/LLD or mold linker instead of default one (GCC and clang only) -ccache .............. Use the ccache compiler cache [no] (Unix only) + -unity-build ......... Enable Unity (Jumbo) build + -unity-build-batch-size <int> + Maximum number of source files used by the unity build + to create unity source files [8] -warnings-are-errors . Treat warnings as errors [no; yes if -developer-build] |