summaryrefslogtreecommitdiffstats
path: root/cmake/QtFeature.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Add hardening build optionsGiuseppe D'Angelo2024-03-191-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit enables hardened-specific checks and codegen, inspired by GCC 14's -fhardened command line switch and LLVM/libc++'s hardened modes. We enable (depending on compiler capabilities): * -ftrivial-auto-var-init=pattern; * -fstack-protector-strong; * -fstack-clash-protection; * -fcf-protection=full or /CETCOMPAT; * -D_FORTIFY_SOURCE=3 or 2 on Glibc, depending on the Glibc version, provided that some optimization level is enabled (release build or optimized debug build); * on libstdc++, -D_GLIBCXX_ASSERTIONS; * on libc++, -D_LIBCPP_HARDENING_MODE set to _LIBCPP_HARDENING_MODE_EXTENSIVE in debug and to _LIBCPP_HARDENING_MODE_FAST in release (_DEBUG is too slow); * -Wl,-z,relro,-z,now. This aligns us 100% with -fhardened (we already pass -fPIE and -pie anyhow). Some Linux distributions already ship GCC/Clang with some of these options enabled by default. The check for Intel CET has been amended to always test if the compiler supports the corresponding flag; and, if so, enable the feature. Before, it was behind a configure option and the test only checked if the compiler had CET support automatically active (the test didn't pass -fcf-protection to the compiler). The check for -fstack-protector-strong has been made general (rather than QNX-specific). We don't support QNX < 7 anyhow. Finally, the qt_config_linker_supports_flag_test test has been amended to also support MSVC. All of the hardening options are enabled by default. [ChangeLog][Build System] Qt builds by default in "hardened mode", meaning that a series of security-related compiler options are automatically enabled. In the unlikely case in which these options constitute an unacceptable performance hit, it is possible to disable individual hardening options when configuring Qt. Change-Id: I2c026b0438010ad10d5e7b1136fedf4ae3af8822 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* cmake: Rename QT_UIKIT_SDK to QT_APPLE_SDKTor Arne Vestbø2024-03-181-2/+2
| | | | | | | | | | | | | | The SDK is relevant for all Apple systems, including macOS, iOS, tvOS, watchOS, and visionOS. We still pick up -DQT_UIKIT_SDK for iOS for compatibility. [ChangeLog][CMake] The -sdk configure argument now maps to the QT_APPLE_SDK CMake variable. QT_UIKIT_SDK is still supported for iOS builds for compatibility. Change-Id: I983a2f23c2414eb73cd35bb83738088defb45cbd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Teach qt_config_compile_test to set the build outputAlexandru Croitor2024-02-211-3/+24
| | | | | | | | | | | | | | | | | The qt_config_compile_test command now assigns the build output of a config test to the TEST_${name}_OUTPUT variable in the callers scope. We can use this to show error messages, and it can also be seen in trace files for better troubleshooting. It works for all project based calls with CMake 3.16, but for source code based tests, due to the usage of check_cxx_source_compiles instead of try_compile, it will only work for CMake 3.23+. Pick-to: 6.5 6.6 6.7 Task-number: QTBUG-122596 Change-Id: Ib9664c158ba9a391bd17bf30a28f9a34eba991d5 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Simplify feature calculationJoerg Bornemann2024-02-131-15/+3
| | | | | | | | | | Since configure doesn't translate -feature-foo to INPUT_foo=ON anymore, we can remove the code that tries to calculate the feature value from INPUT_foo. Task-number: QTBUG-120529 Change-Id: I4829bb634ca8c3f08b489469532b65541d76fa70 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Remove qt_internal_compute_features_from_possible_inputsJoerg Bornemann2024-02-131-16/+0
| | | | | | | | | | | This function calculated the values of the features 'no-prefix' and 'developer-build' from INPUT_* values. Since configure directly translates -no-prefix and -developer-build to FEATURE_no_prefix and FEATURE_developer_build, we can remove the function. Task-number: QTBUG-120529 Change-Id: Ide1fa61af175d8f6a6aa6363dfdfa94912836345 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Dynamically include and install Helpers and other filesAlexandru Croitor2023-11-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of duplicating file names that need to be include()'ed in two different places if the files are meant to be used in both Qt builds and public user projects and then also mention the name when installing, extract the file names into lists returned by functions. Call these functions where needed to iteratively include() the files as well as install them, without having to remember updating multiple code locations. The new functions return the following list of file names: - upstream cmake modules that need to be included during a Qt build - public (Qt build and user project) cmake helpers that need to be included and installed - private (Qt build only) cmake helpers that need to be included and installed - public files that need to be installed, but not included - private files that need to be installed, but not included We also generate the list of public files to include in Qt6Config.cmake. Task-number: QTBUG-86035 Change-Id: I1e7287f4e1d041c723f144ba9626b34f873c4891 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Split and refactor QtSetup.cmakeAlexandru Croitor2023-11-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Split all code in QtSetup into separate functions and macros, put them in more appropriate files, and call them in qt_internal_setup_build_and_global_variables. A new QtBuildOptionsHelpers.cmake is created which takes care of computing the default values of user-customizable options that are not pure configure features, like the cmake build type, whether to build tests / examples, whether to enable ccache, etc. The new function calls added in qt_internal_setup_build_and_global_variables try to preserve the previous code flow when QtBuild was included in-between the code that was run in QtSetup. Macros that have dependencies on various global variables were marked as such with inline comments for easier navigation and comprehension. After this change, QtSetup.cmake just includes QtBuild.cmake. We leave it to exist for easier git blaming, but new code should not be added to it unless really necessary. The intent is to merge a variant of this change to 6.6 and 6.5 as well. Task-number: QTBUG-86035 Change-Id: I3409c2d3ea8ee19a69104b12ab2692966ba5f9cf Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Fix config condition evaluatorJoerg Bornemann2023-09-211-18/+31
| | | | | | | | | | Use recursive descent to handle parentheses in config condition expressions. This fixes cases like 'NOT (A AND B)'. Fixes: QTBUG-117053 Change-Id: Iab1b6173abe00d763808bb972a9a5443ffa0938d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* CMake: Use while instead of foreach in qt_evaluate_config_expressionJoerg Bornemann2023-09-211-9/+5
| | | | | | | | | | | | | By using a while loop instead of a foreach(RANGE), we can simplify the code and remove the skipNext variable. Also, we need to access the last used iteration index in a future commit. This is not possible with a foreach loop without saving the index in another variable. Change-Id: I39306a0105fb31a6a8f39e9d4c47ee3424599a2b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* CMake: Remove superfluous code from qt_evaluate_config_expressionJoerg Bornemann2023-09-211-4/+0
| | | | | | | | | All of the continue() statements are not needed. There is no code after the if-else chain. Change-Id: I16188d14b4f05cb1e5f29bac4657149c4fce60a4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* CMake: Fix reconfiguration when -no-opengl is specifiedAlexandru Croitor2023-09-131-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a previous change, we ensured that all INPUT_foo cache variables are unset at the end of configuration, so they don't influence feature re-evaluation in case if a command line flag like -no-gui is not specified upon second reconfiguration and a FEATURE_foo is manually toggled in the CMakeCache.txt, effectively getting rid of stale INPUT_foo values. Unfortunately that causes an issue when configuring with -no-opengl and then trying to reconfigure with 'cmake .' Specifically various feature options like ENABLE / DISABLE use INPUT_foo variables in their expressions. qt_configure_add_report_entry CONDITIONs also use them. These expect the INPUT_foo variables to be persisted, and if they are removed, the expressions might be re-evaluated to a different value, and cause re-configuration to fail or unexpectedly toggle features. To support both cases described above, instead of removing all INPUT variables when configuration ends, only unset those INPUT variables whose corresponding FEATURE_foo variable has been manually toggled in CMakeCache.txt or via an IDE. Toggling a FEATURE_foo manually is intentional, which means the INPUT_foo value should be discarded. Whereas pre-existing INPUT_bar variables will persist, thus not breaking cases like the -no-opengl report CONDITION. Amends 2799391703e44a34b6557e234462e425a61785f2 Pick-to: 6.6 Fixes: QTBUG-116973 Task-number: QTBUG-112957 Change-Id: I5851255bfa41a9a1d116630a5d9f7b9a74aa93ed Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Handle INPUT_foo values when detecting dirty buildsAlexandru Croitor2023-09-061-15/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, the dirty feature code only checked for differences between FEATURE_foo and QT_FEATURE_foo, without taking into account modified INPUT_foo values that might passed via the configure script. This led to issues in certain scenarios when reconfiguring with the configure script. For example configuring with -gui / -DINPUT_gui=ON and then with -no-gui / -DINPUT_gui=OFF would fail saying 'Feature "widgets": Forcing to "ON" breaks its condition' This happens because the widgets feature depends on gui being available, but because INPUT_gui modifications don't trigger the dirty feature re-eval code, we don't recompute the value of widgets. Extract the code that takes into account the INPUT_foo variables into a separate function, and use it both when computing feature values and also when detecting dirty features. This means any non-matching INPUT_foo variables will now also trigger dirty feature checking. Use the same function to replace the duplicate code we have to early initialize the developer-build, no-prefix and pkg-config features. Pick-to: 6.6 Task-number: QTBUG-112957 Change-Id: I775cf70b48291a659b0fecf7cb9570ec12735bca Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Rework INPUT_foo vars handling when reconfiguringAlexandru Croitor2023-09-061-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To be able to reconfigure Qt with modified feature values using the configure script, and take into account INPUT_foo values, we need to ignore FEATURE_foo values. But we can't always ignore FEATURE_foo values, because users might want to toggle them by editing CMakeCache.txt or using an IDE. What we can do is tell CMake we are configuring via the configure script, in which case we can mostly be sure that any passed INPUT_foo values should have higher priority than pre-cached FEATURE_foo values. We also need to remove all the cached INPUT_foo variables after they have been used for feature computation, so that subsequent reconfigurations where an INPUT_foo is not passed anymore, doesn't cause a feature to accidentally reuse the previous (stale) value. Pass -DQT_INTERNAL_CALLED_FROM_CONFIGURE=TRUE to CMake when configuring via the configure script, and use that as a marker to make INPUT_foo values have a higher priority. This needs to be done centrally in qt_evaluate_feature and also in a few more locations where we check INPUT_ values, like the developer build and pkgconfig features. Because QT_INTERNAL_CALLED_FROM_CONFIGURE would become a cached variable, we want to remove it at the end of the configuration phase, so that future 'cmake .' reconfigurations are not considered to be done via configure. To do that, we unset it right at the end of qt_build_repo_end in a per-repo build, and in the final qt_print_build_instructions call in a top-level build. The latter needs a cleaner fix in follow up commits in qt5.git and qtbase. Pick-to: 6.6 Task-number: QTBUG-112957 Change-Id: I3fd338092041ef09e3f5a4dfbaf61da5deea0514 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Recompute features when dependent features are marked dirtyAlexandru Croitor2023-09-061-22/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, if a user toggled a FEATURE_foo variable, we only recomputed the value for dependent features who's CONDITION would break with the new value. If the CONDITION was not broken, the dependent feature value would remain unchanged. For example if FEATURE_developer_build was OFF, and the user toggled it to ON, the FEATURE_private_tests value would remain OFF, because OFF is a valid value for private_tests' CONDITION. But we would like FEATURE_private_tests to become ON if we toggled FEATURE_developer_build to ON. To address this case, we need to recompute features who's dependent feature values have changed. The algorithm introduced by this change is: - keep track of initial dirty features, aka track when FEATURE_foo is different from QT_FEATURE_foo. We expect FEATURE_foo to be the variable that a user toggles in the cache file or an IDE. - when evaluating feature values, collect feature dependencies from the various expressions given to options like CONDITION, AUTODETECT - if any feature dependency is marked dirty, reset the feature value to its auto-computed value and mark the reset feature as dirty - repeat for all feature evaluations Because feature evaluation is eagerly recursive, we will successfully reset all features that need resetting. To ensure against unforeseen breakages, allow disabling this behavior by configuring with -DQT_NO_FEATURE_AUTO_RESET=ON Adjust some of the messages to contain more details. Note that the pre-existing behavior of resetting feature values when the condition can't be satisfied, stays. For example if FEATURE_developer_build is OFF and FEATURE_private_tests is manually toggled to ON, it will reset to OFF because its condition can't be satisfied (developer_build is still OFF). Amends 61943aefd68b7d88c5eb395c4e44d08a94a70ad0 [ChangeLog][Build System] The build system will now try to recompute configure features when dependent feature values are toggled by the user. Pick-to: 6.6 Fixes: QTBUG-96936 Task-number: QTBUG-85962 Task-number: QTBUG-112957 Task-number: QTBUG-116209 Change-Id: Ib627f3675df8a3b08f4936cdc9c51f2d6e15f58c Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Move dirty feature / dirty build detection into QtFeature.cmakeAlexandru Croitor2023-09-061-0/+26
| | | | | | | | | | | | | It makes more sense for it to live next to the other feature code. Pick-to: 6.6 Task-number: QTBUG-96936 Task-number: QTBUG-85962 Task-number: QTBUG-112957 Task-number: QTBUG-116209 Change-Id: I8438e6fce9deaa5e709e4b0e2e1ea4eb0600a89a Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Pass CMAKE_EXE_LINKER_FLAGS to project-based try_compileAlexandru Croitor2023-03-141-0/+1
| | | | | | | | | | | | | | CMake does it for non-project-based try_compile calls if the CMP0056 policy is set to NEW. That was introduced in CMake 3.2, thus set it unconditionally. The use case is to pick up custom -rpath-link paths when cross-compiling. Pick-to: 6.4 6.5 Change-Id: I726b90267dd46de116052b5b7f19b9354a568200 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: make qt_config_compile_test verbosely indicate missing depsThiago Macieira2023-01-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This alone isn't enough: Feature "xcb": Forcing to "ON" breaks its condition: QT_FEATURE_thread AND TARGET XCB::XCB AND TEST_xcb_syslibs AND QT_FEATURE_xkbcommon_x11 Condition values dump: QT_FEATURE_thread = "ON" TARGET XCB::XCB found TEST_xcb_syslibs = "FALSE" QT_FEATURE_xkbcommon_x11 not evaluated But when it says: -- Performing Test XCB (extensions) - Failed because XCB::CURSOR not found The user can know what to do. Pick-to: 6.4 Change-Id: I810d70e579eb4e2c8e45fffd1719c0abf608ed30 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Retire the qt_parse_all_argumentsAmir Masoud Abdol2023-01-181-7/+23
| | | | | | | | | | | This replaces the qt_parse_all_arguments macro with the built-in `cmake_parse_arguments(PARSE_ARGV`. In addition, a new function, _qt_internal_validate_all_args_are_parsed, can be used to check whether any _UNPARSED_ARGUMENTS have been passed to the function. Fixes: QTBUG-99238 Change-Id: I8cee83dc92dc6acdaaf747ea6ff9084c11dc649b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove perl related functionality from CMake filesAlexey Edelev2022-11-291-16/+0
| | | | | | | | | Avoid using perl in CMake scripts. Remove the syncqt.pl specific code. Task-number: QTBUG-87480 Change-Id: I7fcd5cc83d173ec463c275b5b50b84f25044a118 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: allow user specified boolean values to have any caseRolf Eike Beer2022-09-051-1/+1
| | | | | | | | | | | | | | | | | | | | When running something like this: cmake -D FEATURE_xkbcommon=On qtbase one would run into issues like: CMake Error at cmake/QtFeature.cmake:254 (message): Sanity check failed: FEATURE_xkbcommon has invalid value "On"! Call Stack (most recent call first): cmake/QtFeature.cmake:396 (qt_feature_check_and_save_user_provided_value) cmake/QtFeature.cmake:606 (qt_evaluate_feature) cmake/QtFeature.cmake:575 (qt_feature_module_end) src/CMakeLists.txt:12 (qt_feature_evaluate_features) Change-Id: I33a921625b97aeb3c423cb7c1fb1bd3b05ce24a7 Pick-to: 6.4 6.3 6.2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Relax constraint on not having feature values changeAlexandru Croitor2022-08-031-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if qtbase was built with feature A set to ON, then building qtsvg, then rebuilding qtbase with feature A set to OFF, trying to build qtsvg would fail with an error message at configure time saying that the feature value has changed. This check was added quite early in the Qt CMake port, presumably to catch accidental reconfigures that might cause long rebuilds. This has dubious benefit though. We constantly had people telling us they get the error without knowing what to do. The usual advice was to remove CMakeCache.txt and reconfigure. Instead of forcing people to suffer this dance, relax the constraint by issuing a warning instead of an error, and make it more clear why a rebuild might happen (a changed feature value might change the generated module C++ header file which in turn might be included by various project sources). Amends 20633d97abed0f6025572f87c9359272b4713384 Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-95834 Change-Id: I992bd61024958869f3b995471b4c7ff75e3a33a0 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Mark chosen C++ standard as required for building QtYuhang Zhao2022-06-191-0/+8
| | | | | | Change-Id: I7d3187e74251059c7536f3e34d8c87f54c673146 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* C++23/c++2b supportAllan Sandfeld Jensen2022-06-081-1/+3
| | | | | Change-Id: I33b2a48312ae94e3d5ebb4097e50c4953e14d533 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: add detection of x86 VAES and AVX512VBMI2 featuresThiago Macieira2022-03-081-2/+2
| | | | | | | | We have VAES code in qhash.cpp that isn't getting compiled right now. Change-Id: Ibf4acec0f166495998f7fffd16d6961261dec361 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* CMake: enable machine_tuple also on GNU/HurdPino Toscano2022-02-111-1/+1
| | | | | | | | On the Hurd there is the standard GCC toolchain, so it is possible to query GCC for -dumpmachine. Change-Id: Idc8e80c0937147a8ea656bc0320a83d647278455 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Add support building Qt with the 'mold' linkerAlexandru Croitor2022-01-201-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | The mold linker is a new linker for Linux that provides faster link times compared to BFD ld, ld.gold and lld. It can be found at https://github.com/rui314/mold To build Qt with mold, ensure that the binary in your PATH and then configure Qt with with either cmake /path/to/qtbase -DINPUT_linker=mold or /path/to/qtbase/configure --linker mold The change was tested with gcc 9, clang 10, clang 12, mold 1.0.0. Only qtbase and qtdeclarative (and dependencies) were tested. Pick-to: 6.2 6.3 Task-number: QTBUG-99270 Change-Id: I2e64a1f4257c37ff5b64a9326e548b9b46e07c80 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Fix detection of linker availabilityAlexandru Croitor2022-01-181-9/+31
| | | | | | | | | | | | | | | | | | | | Previously we passed flags like -ld-fuse=lld only to compile calls, but not to the link call of a compile test project. Make sure to pass it to the link call instead by using check_cxx_source_compiles + CMAKE_REQUIRED_LINK_OPTIONS instead of check_cxx_compiler_flag. Note the flag that is passed is still via passed via the compiler launcher and not directly to the linker. Remove duplicate flag handling code. Pick-to: 6.2 6.3 Change-Id: I1bf90573904a9df83240b6debfee3cc9e425c6bb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Support configure -platform linux-clang-libc++Allan Sandfeld Jensen2021-12-141-0/+14
| | | | | | | | Detect libc++ config and add appropriate compiler and linker flags. Pick-to: 6.3 Change-Id: I9ec91b3ace987599d4e79e43b1b75aa67cd5caeb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix config tests not finding module-provided CMake packagesJoerg Bornemann2021-10-131-1/+6
| | | | | | | | | | | | | | | | This amends commit 165e01d5d51d16377542c1b3ffbc22f03fb75e97. Above commit broke the code that adds "${PROJECT_SOURCE_DIR}/cmake" to CMAKE_MODULE_PATH. The semicolon that separates entries of CMAKE_MODULE_PATH must be escaped. Otherwise, the semicolon separates elements of the flags list. Additionally, fix the QT_AVOID_CUSTOM_PLATFORM_MODULES code path which lacked the addition of "${PROJECT_SOURCE_DIR}/cmake". Pick-to: 6.2 Change-Id: I72f78cf066cabe6b0002dce1aa0294aa0dc9cbf0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Don't use libs in /usr/local for configure tests by default on macOSJoerg Bornemann2021-10-081-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit f3c7d22dd04afe8d889585fb5d6426f3d4591e74 we do not use libraries from /usr/local and other non-system locations on macOS. But our configure tests still did. This led to discrepancies between find_package calls in configure tests and the Qt project itself. Mentioned commit removed /usr/local and friends from CMAKE_SYSTEM_PREFIX_PATH. But we can't pass this variable to the configure tests, because CMake sets it up and overwrites our value. Pass CMAKE_SYSTEM_PREFIX_PATH and CMAKE_SYSTEM_FRAMEWORK_PATH as QT_CONFIGURE_TEST_CMAKE_SYSTEM_{PREFIX|FRAMEWORK}_PATH variables to tests. Tests with separate project files that call find_package() must add code like this after the project() command: if(DEFINED QT_CONFIGURE_TEST_CMAKE_SYSTEM_PREFIX_PATH) set(CMAKE_SYSTEM_PREFIX_PATH "${QT_CONFIGURE_TEST_CMAKE_SYSTEM_PREFIX_PATH}") endif() if(DEFINED QT_CONFIGURE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH) set(CMAKE_SYSTEM_FRAMEWORK_PATH "${QT_CONFIGURE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH}") endif() Adjust pro2cmake accordingly. Task-number: QTBUG-97076 Change-Id: Iac1622768d1200e6ea63be569eef12b7eada6c76 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Ensure that UNIX is set for INTEGRITYJoerg Bornemann2021-10-051-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Certain platform-related variables, in this case UNIX, must be set in a platform module, because they get cleared after the toolchain file is loaded. Such platform modules live in upstream CMake, but there is none yet for INTEGRITY. This manifests in an undefined UNIX variable and "System is unknown to CMake" warnings for the project and every configure test. Add the CMake module "Platform/Integrity" in the cmake/platforms directory. Add this directory to CMAKE_MODULE_PATH to let CMake load Platform/Integrity when the toolchain file set CMAKE_SYSTEM_NAME to "Integrity". CMake's module directory takes precedence, when loading platform modules. This is special for platform modules and different from the documented behavior of CMAKE_MODULE_PATH and include(). In case the user wants to provide their own platform modules via CMAKE_MODULE_PATH, they can instruct Qt to not add its path by setting QT_AVOID_CUSTOM_PLATFORM_MODULES to ON. Make sure that configure tests with project files also load the custom platform module. Pick-to: 6.2 Fixes: QTBUG-96998 Change-Id: I9855d620d24dc66353cec5e847a2675b464ace26 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix separate_debug_info configure test for cross-compilationJoerg Bornemann2021-09-281-0/+1
| | | | | | | | | | | | | | | The separate_debug_info configure test uses the CMake variable CMAKE_OBJCOPY. CMakeFindBinUtils in the test project finds the host's objcopy despite CMAKE_TOOLCHAIN_FILE being correctly set. We now add CMAKE_OBJCOPY to the list of variables that are passed to configure test projects and remove the CMakeFindBinUtils include, which looks rather internal anyways. Pick-to: 6.2 Fixes: QTBUG-96798 Change-Id: I164c6bd1771e8789e9dd19b50573b33b8866bd3b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Use only supported values when setting internal QT_FEATURE_ valuesAlexey Edelev2021-09-211-1/+5
| | | | | | | | | | | When setting QT_FEATURE_ values we need to convert the user-provided FEATURE_ values to the one that is supported by QT_FEATURE_. Pick-to: 6.2 Fixes: QTBUG-96300 Change-Id: Idd19fbf7f23f351a6c1cfdcedccfaaf6b0aa6e44 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Pass CMAKE compiler flags to arch detectionAllan Sandfeld Jensen2021-09-201-0/+10
| | | | | | | | | | This fixes the detection of always available architecture based on user set CMAKE flags. Change-Id: I541ac9569766a0fe05f4395c06f2ee3bcd77b035 Fixes: QTBUG-91090 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Properly export MODULE_PLUGIN_TYPESAlexandru Croitor2021-08-261-1/+1
| | | | | | | | | | | | | | | | Don't export the MODULE_PLUGIN_TYPES property only when a module has an associated configure.cmake file with features. Instead, always export it if a module defines a plugin type. This fixes qttools DesignerTargets.cmake file to contain the plugin types it defines, given that the Designer lib does not declare any features via a configure.cmake file. Pick-to: 6.2 Task-number: QTBUG-95668 Change-Id: Ic036c31768e03b51d3bce9c2afe48e04f69f435b Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix feature evaluation for feature definesJoerg Bornemann2021-08-171-1/+6
| | | | | | | | | | | | | | | | | Passing -DFEATURE_developer_build=TRUE did not add the define QT_BUILD_INTERNAL to src/corelib/global/qconfig.h like -DFEATURE_developer_build=ON would. This happened, because the feature evaluation in qt_evaluate_feature_definition did a string comparison against "ON". Normalize both sides of the string comparison, and thus support all booly values for features. Pick-to: 6.2 Fixes: QTBUG-95732 Change-Id: Ibf03579c05919b35219438361fc93676b7cca7cc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Make precompiled headers work for Android on WindowsJoerg Bornemann2021-08-171-0/+9
| | | | | | | | | | | | | | When building Qt for Android on Windows, the precompile_headers test failed if the source directory was passed as absolute path without drive letter. See CMake upstream issue #22534. Work around the CMake issue by ensuring that the path is properly prefixed with a drive letter. Pick-to: 6.2 Fixes: QTBUG-95652 Change-Id: I3154b6c0bb2f53533306227074b24fbbf5973b05 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Don't repeat conditions of use_*_linker features in QtFeature.cmakeJoerg Bornemann2021-07-131-9/+3
| | | | | | | | | | | | | | qt_config_linker_supports() repeated the conditions of all use_*_linker features, because the features are not evaluated yet when this function is called, and the function needs to know what linker is used to build Qt. Move the required tests and features before any qt_config_linker_supports() call and evaluate the use_*_linker features early. Change-Id: I306f032356682a0e82e4d7c4234e5bbc820ab143 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix reconfiguration error when features have EMIT_IF conditionsAlexandru Croitor2021-07-091-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, if a feature was marked as not to be emitted and there was no user provided value for that feature, the build system would still save the user provided value in FEATURE_foo with a value of ON (if the conditions were met). After a reconfiguration, the build system would hit the code path that checks if the user provided a value for the non-emitted feature, and would then warn about it and reset the feature value to OFF. This would cause errors when reconfiguring a user project, complaining that a feature value has changed. Make sure to not save the user provided value for a non-emitted feature and to always set its internal feature value to OFF. Amends c4f5762b20dc20bab3cc62e9166d0e5b36e21cc6 Pick-to: 6.2 Fixes: QTBUG-94921 Change-Id: I257c7fd795c8a6aeba3348cb72522e4f0b006dc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Rename and document the feature evaluation functionsAlexandru Croitor2021-07-091-25/+60
| | | | | | | | | | | | | | | | | | | | Rename various functions and variables to hopefully make the behavior of feature evaluation clearer. The previous names like 'set_value' or 'set_cache_value' or 'cache' were too generic and unclear. One would have to carefully read the code to understand what was actually set. Add some doc comments about what FEATURE_foo and QT_FEATURE_foo represent. Amends c4f5762b20dc20bab3cc62e9166d0e5b36e21cc6 Pick-to: 6.2 Task-number: QTBUG-94921 Change-Id: Ie6a7b83a4d54a83976b2706d4af82b39832d79f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Add the check for linker capabilities to resolve circular dependenciesAlexey Edelev2021-06-101-2/+6
| | | | | | | | | | | | | | 'ld' only capable to resolve circular dependencies by wrapping the suspected static libraries and objects using --start/end-group arguments. We want to detect if linker is 'ld' at configure time to decide how to link the resource objects if finalizers are not enabled. The qt_config_compile_test function is extended with an extra argument since it's required to pass custom cmake flags to the ld-related test. Pick-to: 6.2 Change-Id: I484fcc99e2886952d8b0232f37e4e6a35d072931 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Allow printing config summary even if module is not builtAlexandru Croitor2021-06-011-1/+17
| | | | | | | | | | | | | | In the future it might be useful to print the config summary entries of a Qt module configure.cmake file even if the associated module is not built and thus qt_feature_module_begin is not called. The repo src/CMakeLists.txt could then use a combination of qt_feature_evaluate_features and a conditional qt_feature_record_summary_entries to ensure the that summary entries are still shown. Change-Id: I124efc82163ddae48d9e72c70a677ec4c6588fac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix building multi-arch universal macOS QtAlexandru Croitor2021-04-011-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the same approach we use for iOS, which is to set multiple CMAKE_OSX_ARCHITECTURES values and let the clang front end deal with lipo-ing the final libraries. For now, Qt can be configured to build universal macOS libraries by passing 2 architectures to CMake, either via: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" or -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" Currently we recommend specifying the intel x86_64 arch as the first one, to get an intel slice configuration that is comparable to a non-universal intel build. Specifying the arm64 slice first could pessimize optimizations and reduce the feature set for the intel slice due to the limitation that we run configure tests only once. The first specified architecture is the one used to do all the configure tests. It 'mostly' defines the common feature set of both architecture slices, with the excepion of some special handling for sse2 and neon instructions. In the future we might want to run at least the Qt architecture config test for all specified architectures, so that we can extract all the supported sub-arches and instruction sets in a reliable way. For now, we use the same sse2 hack as for iOS simulator_and_device builds, otherwise QtGui fails to link due to missing qt_memfill32_sse2 and other symbols. The hack is somewhat augmented to ensure that reconfiguration still succeeds (same issue happened with iOS). Previously the sse2 feature condition was broken due to force setting the feature to be ON. Now the condition also checks for a special QT_FORCE_FEATURE_sse2 variable which we set internally. Note that we shouldn't build for arm64e, because the binaries get killed when running on AS with the following message: kernel: exec_mach_imgact: not running binary built against preview arm64e ABI. Aslo, by default, we disable the arm64 slice for qt sql plugins, mostly because the CI provisioned sql libraries that we depend on only contain x86_64 slices, and trying to build the sql plugins for both slices will fail with linker errors. This behavior can be disabled for all targets marked by qt_internal_force_macos_intel_arch, by setting the QT_FORCE_MACOS_ALL_ARCHES CMake option to ON. To disble it per-target one can set QT_FORCE_MACOS_ALL_ARCHES_${target} to ON. Task-number: QTBUG-85447 Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* configure: Fix error when turning on/off non-emitted featuresJoerg Bornemann2021-03-091-14/+14
| | | | | | | | | | | | | | | | | Features that are not emitted in the current configuration (e.g. plugin-manifests on Linux) should not yield an error. Instead, print a warning message like Qt5's configure did. Set insignificant feature to OFF. Remove the now unneeded emit_if parameter from qt_feature_set_cache_value. Pick-to: 6.1 Fixes: QTBUG-88305 Change-Id: I0f2ce152fca5f08417038c9bd2c07639ff6a3df4 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* More helpful error message when merging qt features in CMakeAndreas Buhr2021-02-101-1/+1
| | | | | | | | | | When a feature is set in qtbase and is later set to another value, an error occurs and an error message is given. This patch changes the error message to contain both the preexisting and the new value Change-Id: Ifa9fc1f06bfde40e8fd5dfdf30165d4393abbd28 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Do not export the QT_PLUGINS target property of Qt modulesJoerg Bornemann2021-01-201-1/+1
| | | | | | | | | | | This property is dynamically determined and set in the Qt6${module-name}PluginsConfig.cmake files now. There is no need anymore to export this property. Change-Id: I2d164864c4099034b88f9ad852eae8b9f9e55f8b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Fix missed feature evaluation errors in reportAlexey Edelev2021-01-151-1/+1
| | | | | | | | | | | | Add an optional argument to store the report command while feature evaluation-only stage. This is necessary, because according to the actual feature evaluation process, evaluation happens only once and it's impossible to record any command during the evaluation-only stage. Fixes: QTBUG-90319 Change-Id: I215fbe0a28a2661cd2d97d253b2e2c787d295cbd Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* CMake: Print feature condition errors in configure reportAlexey Edelev2021-01-051-2/+2
| | | | | | | | | | | Add output of feature condition error at the end of configuration summary. Introduce qt_configure_add_report_error that may be used to add error to end-point configure report without actual configure interruption. Fixes: QTBUG-88282 Change-Id: Idcf478da863ae6507438eb3370927d7d1f01e071 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>