summaryrefslogtreecommitdiffstats
path: root/cmake
Commit message (Collapse)AuthorAgeFilesLines
* CMake: Bump almost all cmake_minimum_required calls to 3.16Alexandru Croitor2021-09-223-3/+3
| | | | | | | | | | | | Needed for subsequent change that will check and error out if the version is lower than 3.16. We do that to ensure all policies introduced by CMake up to version 3.16 have their behavior set to NEW. Pick-to: 6.2 Task-number: QTBUG-95018 Change-Id: Ieaf82c10987dd797d86a3fd4a986a67e72de486a Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Rework how installation is prevented in non-prefix buildsJoerg Bornemann2021-09-223-41/+17
| | | | | | | | | | | | | | | | | In non-prefix builds, we want to prevent users from accidentally running "cmake --install". We did that by replacing cmake_install.cmake with an empty file. The responsible target remove_cmake_install is visible in IDEs, appears in the build output, and the approach is hacky. It's cleaner and easier to add bail out code at the top of cmake_install.cmake. This is now done when calling qt_build_repo_begin. As a bonus, print an informative message on installation. Change-Id: I022b36289358ba09cac8b79781f44cd7b93113f7 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>
* Add missing framework paths to header check targetsAlexey Edelev2021-09-201-0/+15
| | | | | | | | | | | | | | | | | CMake doesn't add framework include paths for the includes if add_custom_command is used. When all Qt modules are installed to a single directory, frameworks could be found under QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX, but for Conan builds each module is installed to the separate directory. These directories need to be listed in the QT_ADDITIONAL_PACKAGES_PREFIX_PATH variables family. This takes into account directories that are listed in the QT_ADDITIONAL_PACKAGES_PREFIX_PATH variables and considers they can contain frameworks. Pick-to: 6.2 Fixes: QTBUG-96511 Change-Id: I664381df4859a2e85c399cd94dc2f3996e452c03 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* 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>
* Fix main() not being visible on AndroidCraig Scott2021-09-201-0/+8
| | | | | | | | | | | | | | A recent change refactored the call to qt_internal_add_executable(), but that had the unintended side-effect of changing the symbol visibility from public to hidden. That meant that main() became hidden, so while apps still built successfully, they could not be run. Restore the original symbol visibility to fix this regression. Amends d47278fd09f73ddc34011ab980dafc23aa453e71 Pick-to: 6.2 Change-Id: I27d84ab2b0dd013d5c38dcfe55e88f307c4bc5dd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove unused EXE_FLAGS option from qt_internal_add_executable()Craig Scott2021-09-182-3/+1
| | | | | | | | | | The EXE_FLAGS option wasn't being used anywhere in any Qt repo and it had no documentation as to its intended use. Remove it. Pick-to: 6.2 Change-Id: I2f67ec57c1da7dc6eab81d5351361e770d19d7d5 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove TODOs related to checking CMake 3.21 features post-releaseCraig Scott2021-09-182-4/+0
| | | | | | | | | | | These TODOs were left as a marker to be checked once the official CMake 3.21.0 release was made. The things they refer to were included in the CMake 3.21.0 release, so the TODOs can be removed. Fixes: QTBUG-94528 Pick-to: 6.2 Change-Id: I769605de85df657ad056123e787ec9849b77e42f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Do not generate cpp exports for pure STATIC modulesAlexey Edelev2021-09-171-1/+4
| | | | | | | | | | | Static libraries don't need to export their symbols, and corner cases when sources are also used in shared libraries, should be handled manually. Task-number: QTBUG-90492 Change-Id: I5cb0a3f7e280b042b678bdbe4475f2bbf9f6b9ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add explicit install rules for the autogenerated cpp exportsAlexey Edelev2021-09-171-8/+38
| | | | | | | | | | | | | | | | | | | If qt_internal_generate_cpp_global_exports is called outside the qt_internall_add_module function scope, install rule that is generated by qt_internall_add_module won't include generated cpp export header files. This adds the explicit file-based install rule for the generated cpp exports. Since qt_internal_generate_cpp_global_exports now encapsulates all install rules related to the generated cpp exports, no need to expose the generated filenames outside the function. It's expected that module public headers now could be added outside the qt_internal_add_module function. Tune generating of the module timestamp by replacing the DEPENDS value with generator expression. Task-number: QTBUG-90492 Change-Id: I0f086abc8187c5d51117c3a75c47b58580f6913f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Ensure _qt_is_android_executable is set for internal executables tooCraig Scott2021-09-171-13/+2
| | | | | | | | | | | | | | | | | The _qt_is_android_executable property is normally set by the _qt_internal_create_executable() command. But various other internal commands don't route through that and go through qt_internal_add_executable() instead. The former is used only by the public API, the latter only by the internal API. Refactor both so that the internal one calls the public one. This ensures all targets receive the same base settings, including the _qt_is_android_executable property. Fixes: QTBUG-96085 Pick-to: 6.2 Change-Id: I157356872c9d942d7be5f1abbbcbac97961b1f40 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Make standalone tests TestsConfig file repo-target-set specificAlexandru Croitor2021-09-162-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conan CI builds can built a qt repository in a repo-target-set configuration. An example of that is qtscxml. When building standalone tests, qt_build_tests includes a repo specific TestsConfig.cmake file to call find_package on the modules that were built as part of that repo. That doesn't quite work with a repo-target-set build which is enabled when the repo is built with a QT_BUILD_SINGLE_REPO_TARGET_SET value. The TestsConfig.cmake file would be overridden with different contents on each configuration. Fix that by including the QT_BUILD_SINGLE_REPO_TARGET_SET value as part of the TestsConfig.cmake file to be generated and included. This means that when configuring the standalone tests, the same QT_BUILD_SINGLE_REPO_TARGET_SET value should be passed, so that the correct packages are found. Add some debug statements to allow checking which TestsConfig.cmake file is loaded when the standalone tests are configured with --log-level=DEBUG. Adjusts to 4b09522c23e9efdf83ba8d4af436d8a700ccb66e Amends de3a806def4b9a754825a2233c9d4952a9b2d0eb Amends e7f188b2d2f10941006be7b0e7197b3c1ebdefdb Pick-to: 6.2 Task-number: QTBUG-96253 Change-Id: I7c22aaad88fe8e6fce23046543363316203f6e8d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Add missing private cpp exports template to install setAlexey Edelev2021-09-161-0/+1
| | | | | | | | | | | Add missing modulecppexports_p.h.in template to install set. Amends e1fe816d4662875032946844fadfed3ea691fdd8 Task-number: QTBUG-90492 Change-Id: I25db6f98637bd33a1c56f6b098ac76c4292de581 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Expose cpp export related arguments for qt_internal_add_module usersAlexey Edelev2021-09-161-43/+8
| | | | | | | | | | Functions that use qt_internal_add_module under the hood might need to generate cpp exports, e.g. qt_internal_add_qml_module. Append cpp exports related arguments to the qt_internal_add_module arguments set. Task-number: QTBUG-90492 Change-Id: I4fd539bd1d8be4d3e57ed5b1b88dd2dbc2f5ca24 Reviewed-by: Craig Scott <craig.scott@qt.io>
* qdevice.pri: Use cmake separators for the pathMårten Nordheim2021-09-101-0/+2
| | | | | | | | | Because otherwise we may end up with trailing backslashes Pick-to: 6.2 6.2.0 6.1 Change-Id: I7ad24ec34c35f0a7b32241751bbcd2b26a8a23ea Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Avoid implicit linking of plugin init library if finalizers were calledAlexey Edelev2021-09-081-0/+2
| | | | | | | | | | | Propagating of plugin init libraries should take into account plugin finalizers to avoid duplicating of object files in a linker line. Pick-to: 6.2 Fixes: QTBUG-96062 Change-Id: I48feac94b08a7eb08d84134e9e9ae6e7214f5bdd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Remove unnecessary IF DEFINED HOST_PERL checkAlexandru Croitor2021-09-081-3/+0
| | | | | | | | | The variable might be defined to HOST_PERL-NOTFOUND which will return early instead of issuing an error. Change-Id: Id49dfd0fec8f477dad9e816e6128e36059e68702 Pick-to: 6.2 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Allow opting out of building examples as ExternalProjectsAlexandru Croitor2021-09-063-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We default to configuring examples as separate ExternalProjects when using a developer / non-prefix Qt build. This ensures we test that the examples configure successfully without the pollution of the main Qt build (e.g. already found packages). One down-side of this is that a developer's IDE doesn't see these example targets, unless each project is loaded into the IDE separately. This is cumbersome to do when refactoring or renaming code across multiple example projects. Allow configuring the example projects as part of the main Qt build by setting QT_BUILD_EXAMPLES_AS_EXTERNAL to FALSE when configuring Qt. Save the value of the variable in QtBuildInternalsExtra.cmake.in so it's propagated to leaf repositories as well. Amends dab8f64b6d5d4241b678d0227355858071376496 Amends d97fd7af2bc5c89a0ad9e5fac080041b78d01179 Task-number: QTBUG-90820 Task-number: QTBUG-94608 Task-number: QTBUG-96232 Task-number: QTCREATORBUG-26168 Pick-to: 6.2 Change-Id: Ie1f724f74365b3a788b04c3fffe9eb2d0611dd50 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Fix 'Cannot find source file' error with older CMakesAlexandru Croitor2021-09-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Configuring a static plugin init library with CMake versions earlier than 3.18.0 fails at generation phase with CMake Error at Qt6CoreMacros.cmake:2071 (add_library): Cannot find source file: example/plugins/basictools/pnp_basictools_init.cpp Call Stack (most recent call first): qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1998 (_qt_internal_add_library) qtbase/lib/cmake/Qt6/QtPublicPluginHelpers.cmake:243 (qt6_add_library) qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1967 (__qt_internal_add_static_plugin_init_object_library) qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1989 (qt6_add_plugin) qtbase/plugins/basictools/CMakeLists.txt:1 (qt_add_plugin) Marking the generated file as GENERATED explicitly solves the issue. Similar to e2c6f2ba7ed72195d12e9882c174e59a53317097 Fixes: QTBUG-96197 Pick-to: 6.2 Change-Id: If730a1fcbe6910d6041eb6eba03d6e45a025c424 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't cache QT_SYNCQT across buildsJoerg Bornemann2021-09-032-10/+13
| | | | | | | | | | | | | | | | | | | | | | There is no need for this variable to be stored in CMake's cache. We don't perform expensive operations to set up QT_SYNCQT, and we even unset the cache variable to ensure it gets recomputed on reconfiguration. We still store QT_SYNCQT in a global property, because the function qt_ensure_sync_qt is called in different directory scopes, and we want to avoid re-calculations for every subdir. It's now possible for the user to set QT_SYNCQT (see QTBUG-88088 for motivation). Also, in a non-prefix build, changes to syncqt.pl in the source dir are reflected upon re-configuration in the build tree (because qt_copy_or_install is called on every configure). Pick-to: 6.2 Fixes: QTBUG-88088 Task-number: QTBUG-75290 Change-Id: I6137b060d200d3dafd4a64d5a6c1bd2549723d78 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* wasm: fail when configuring for wasm and EMSDK is not foundLorn Potter2021-09-011-1/+6
| | | | | | Pick-to: 6.2 Change-Id: Ic7fb933d8c2b42c3ba84a3b5a6c89a808d971bd1 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Update Android default SDK from 29 to 30Juha Vuolle2021-08-271-1/+1
| | | | | | | | | | | By the time of Qt 6.2 release all new apps targeting Play store must target API level 30 (Android 11) or above (starting in 08/2021 for new apps and 11/2021 for existing apps' updates). Pick-to: 6.2 5.15 Task-number: QTBUG-94451 Change-Id: Id7fa2fd62899a7259e365c917292c6c3ac0d2b0d Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* CMake: Error out if ccache is requested but not foundJoerg Bornemann2021-08-271-1/+1
| | | | | | | | | | | | | Before, we would just issue a warning which is likely to get overlooked in CMake's output. Also, the configure summary would report "Using ccache ... yes" but CMAKE_<LANG>_COMPILER_LAUNCHER stays unset, which is inconsistent. Make QT_USE_CCACHE=ON and missing ccache a hard error. Task-number: QTBUG-88308 Change-Id: Iddc7f3a91428fd96ad0defbb1ca72bd46a90aa98 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Call MinGW's ld with -Bstatic when requesting static runtime linkageJoerg Bornemann2021-08-271-1/+1
| | | | | | | | | | | The -static argument we used before is supported by ld, but not lld. The latter requires --static or -Bstatic. Use -Bstatic, which is supported by both. Pick-to: 6.2 Fixes: QTBUG-89549 Change-Id: I3c3069661bf4cd20e3298aff4714163b7419d3ef Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Implement generating of private cpp exportsAlexey Edelev2021-08-273-24/+149
| | | | | | | | | | | | | | | | | | | | | | | | | Add the generating of private cpp exports for Qt modules. Add the GENERATE_PRIVATE_CPP_EXPORTS option to qt_internal_add_module that is the manual switch for private exports generator. Existing modules in qtbase doesn't follow any strict convention of using private cpp export. So there is no clue how to detect if generating of the private exports is required or not for the module. Use autogenerated private cpp exports in QtNetwork module. CPP_EXPORT_HEADER_NAME argument of the qt_internal_add_module function is replaced by the CPP_EXPORT_HEADER_BASE_NAME and has a different meaning. The provided name is used as a base name for the private and non-private headers that contains cpp exports. Header files suffixes are constant: .h and _p.h for the non-private and private header files accordingly. Pick-to: 6.2 Task-number: QTBUG-90492 Change-Id: Icf11304e00379fb8521a865965c19b974e01e62f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use correct module include name across the projectAlexey Edelev2021-08-274-53/+161
| | | | | | | | | | | | | | | Module may have specific module include name that should be taken into account when specifying module include directories in different places. The INTERFACE_MODULE_INCLUDE_NAME module property name is aligned to the common naming rules and the property is used to preform include paths instead of the direct use of the module name. Add additional paths generated by qt_internal_module_info to keep them consistent across all cmake files. Pick-to: 6.2 Change-Id: I4c94017abc322c48616f47e65e371bd863bb087d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Warn when PRIVATE_MODULE_INTERFACE is provided with no targetAlexandru Croitor2021-08-261-2/+10
| | | | | | | | | | | | Warn if the PRIVATE_MODULE_INTERFACE option is provided a value, but there is no ${target}Private target to set the interface dependencies on. Pick-to: 6.2 Task-number: QTBUG-95921 Change-Id: I7d4df9cb3aa9b7746d836b82019ecdd9c8f50fdc Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Properly export MODULE_PLUGIN_TYPESAlexandru Croitor2021-08-262-1/+4
| | | | | | | | | | | | | | | | 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>
* Add missing PRIVATE_MODULE_INTERFACEs to INTERNAL_MODULEsAlexey Edelev2021-08-242-0/+10
| | | | | | | | | | | | | | To detect the internal module ouside the qt_internal_add_module function need to mark it with the property. This adds _qt_is_internal_module property to the Qt internal modules. Since PRIVATE_MODULE_INTERFACE only was applicable to pure Private modules, INTERNAL_MODULEs is missing those dependencies if they were specified. Add extra condition to qt_internal_extend_target to link PRIVATE_MODULE_INTERFACE libraries to internal modules as well. Pick-to: 6.2 6.1 Change-Id: I9c32fa5bad3aff365f5d7663349e5365d5f1d72d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Create plugin initializers for static user pluginsAlexandru Croitor2021-08-241-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we only created object library static plugin initializers for Qt plugins only, not user-project plugins. The reason was that if a user tried to install the plugin target via an export set, CMake would error out saying that the _init library is not part of the same export set. Introduce an OUTPUT_TARGETS option that would allow projects to get the name of the generated _init target, so they can install it if needed. This was already done for qt6_add_qml_module, so we just introduce the same option for qt6_add_plugin. Now user static plugins will have an _init target created, which will be propagated to consumers whenever the consumers link against the plugin itself. We also need an internal option to disable this propagation, because it's handled a bit differently for Qt plugins which can be linked either via finalizers or via usage requirements. Amends 91c65dd80cdd2de666448c14202c0c63718152b6 As a result of the implementation change, cleanup example projects to ensure that they build successfully (the important part is specifying the CLASS_NAME). Only plugandpaint works properly with both shared and static Qt builds. echoplugin works with a shared Qt build, but not a static one due to some assumptions in the C++ code about shared plugins. styleplugin doesn't seem to work properly neither with shared Qt builds nor static Qt builds, at least on macOS. But it builds fine. For some reason even if the plugin is found, the style is not applied. Amends 4caac1feea025b0ad496141e8f16ab88c04c2caa Pick-to: 6.2 Task-number: QTBUG-80863 Task-number: QTBUG-92933 Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix excessive size of precompiled header filesJoerg Bornemann2021-08-241-3/+3
| | | | | | | | | | | | | | | Do not add catch-all header files like QtCore, QtGui, etc. to precompiled headers for targets that already define their own set of precompiled header files. This reduces the size of the precompiled headers and brings the pch file sizes down into the region of the qmake build. Pick-to: 6.2 Task-number: QTBUG-89122 Change-Id: I8e4d17aa6829c7d7b1aa01a01a61b6677e22c460 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add missing -help argument to qt-configure-moduleJoerg Bornemann2021-08-201-0/+22
| | | | | | | | | | | Now it's possible to display a configure help screen per module with qt-configure-module <module-source-dir> -help Pick-to: 6.2 Fixes: QTBUG-95943 Change-Id: I7d26006246af4b38b5a2ec6deca3f45c5313afec Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix our usage of CMake script mode in Windows configureJoerg Bornemann2021-08-201-19/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a preparation for adding the -help argument to qt-configure-module.bat. Consider the call qt-configure-module.bat path/to/qt-module -help Internally, we called cmake ... -P .../QtWriteArgsFile.cmake path/to/qt-module -help which was supposed to separate the arguments and write them into config.opt. However, passing arbitrary arguments after "-P script.cmake" only worked by accident and is not supported. As soon as arguments are passed that are valid CMake arguments, like -help or -G, the CMake call would fail. Now, we let configure.bat and qt-configure-module.bat write the arguments as is into config.opt.in and let QtWriteArgsFile.cmake read this file, separate the arguments and write config.opt. Pick-to: 6.2 Task-number: QTBUG-95943 Change-Id: I80f298a2aaf55b0f79fed86320a055eb2d2b6faa Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Don't force lld for Android when clang is usedJoerg Bornemann2021-08-201-9/+0
| | | | | | | | | | | | | This reverts commit 64c111e10fcb2f69855432177d76649b6b789fac. The claim of the commit message, that we cannot use the gold linker, does not seem to be true (anymore?). This is underlined by the fact that CMake *forces* the gold linker for Android, whenever LTCG is enabled (see Modules/Compiler/Clang.cmake as of CMake 3.21.1). Change-Id: I90edac8555be4abdd44cd367228aeffb0d66b895 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix Android -ltcg buildJoerg Bornemann2021-08-201-2/+8
| | | | | | | | | | | | | | We're passing -Oz for release builds, but that's not a flag the linker understands when -ltcg is enabled. The build fails with: ld.gold: fatal error: Optimization level must be between 0 and 3 Fix this by using -O2, which -Oz is based on, and -O3 for the "full optimization" that is used for core and gui. Pick-to: 6.2 Fixes: QTBUG-89472 Change-Id: Ie1a86888baefce5ca97026e7d635f10d2819f9f4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Pass Qt6_FIND_VERSION in Qt6Config when looking for componentsAlexandru Croitor2021-08-193-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Pass Qt6_FIND_VERSION to components when the find_package(Qt6 ${ver} COMPONENTS Foo) signature is used. Create a ConfigVersion file for BuildInternals, so that BuildInternals passes the version check. Fix qt_configure_file to look in the _qt_6_config_cmake_dir folder for the template file rather than Qt6_DIR, because Qt6_DIR might be accidentally unset after a failed find_package(Qt6) call and the error is not helpful then. We already pass versions everywhere else when looking for dependencies, like in ModuleDependencies.cmake.in, PluginDependencies.cmake.in, ModuleToolsDependencies.cmake.in. Pick-to: 6.2 Fixes: QTBUG-91737 Change-Id: Ief1da0c6f239c935385e7ce662951e85ccfdf130 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-buildsAlexandru Croitor2021-08-195-16/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to allow specifying extra locations to find Qt packages. The reason it was introduced instead of just using CMAKE_PREFIX_PATH is because the Qt6 component find_package call uses NO_DEFAULT_PATH which means CMAKE_PREFIX_PATH is ignored. We use NO_DEFAULT_PATH to ensure we don't accidentally pick up system / distro Qt packages. The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the find_package PATHS option in the Qt6 package, each ModuleDependencies.cmake file and some other places. Unfortunately that's not enough to make it work for cross-builds. Imagine the following scenario. host qtbase, qtdeclarative installed in /host_qt target qtbase installed in /target_qtbase target qtdeclarative installed in /target_qtdeclarative We want to cross-build qtlottie. We configure qtlottie as follows /target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative We expect the target QtQuick package to be found, but it won't be. The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH. Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH, which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to /target_qtbase. There is no QtQuick package there. To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH to CMAKE_FIND_ROOT_PATH. The location where we currently do CMAKE_FIND_ROOT_PATH manipulations is in the qt.toolchain.cmake file, so to be consistent, we prepend the new prefixes there as well. We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH, due the path re-rooting bug in CMake. See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as the existing comment in qt.toolchain.cmake marked with REROOT_PATH_ISSUE_MARKER. We also need to do a few more things to make the setup work Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH adjustments we do in the toolchain file are not enough, so we still need to add the same prefixes to the Qt6Config find_package PATHS option. One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then. It's for find_package(Qt6Foo) calls to work which don't go through the Qt6Config umbrella package. To make the CMake re-rooting behavior happy, we need to ensure the provided paths are absolute. So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH, to make them absolute. We do the same for the environment variable. We need to append lib/cmake to the prefixes which are added to CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit. We need to specify the Qt6 package location (${_qt_cmake_dir}) to the PATHS option in the various Dependencies.cmake.in files, to ensure that dependency resolution can jump around between the Qt6 dir and the additional prefixes. Previously the dependency lookup code assumed that all dependencies would be within the same prefix. The same is needed for qt and qml plugin dependency lookup. Amends 7bb91398f25cb2016c0558fd397b376f413e3e96 Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8 Amends 5bbd700124d13a292ff8bae6045316112500e230 Pick-to: 6.2 Fixes: QTBUG-95854 Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't backup cmake prefix when there are no tool dependenciesAlexandru Croitor2021-08-191-2/+2
| | | | | | | | | This is just a minor optimization. Pick-to: 6.2 Change-Id: Icf0fc615895e1def63c57a72694c89f7ae7ee5cf Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove unnecessary version of module from _MODULE_DEPENDENCIESAlexey Edelev2021-08-191-1/+10
| | | | | | | | | | | | | | _<module>_MODULE_DEPENDENCIES variable in the <module>Dependnecies.cmake should only contain the list of targets that module depends on, but not versions. Version of the first module appears in the list because of the regression introduced in 425ff34aa10a02524f2d52f544dc00b539ef9a26 Amends 425ff34aa10a02524f2d52f544dc00b539ef9a26 Pick-to: 6.2 Change-Id: Iaa42120af6bac742bdf0f8d389bd8e5bdef9c1d1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Don't install metatypes files for user projectsAlexandru Croitor2021-08-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Installing extracted metatypes json files for user projects was an oversight. We shouldn't install anything on behalf of user projects, but rather give them enough information so they can do it the themselves. Make all the install options of qt6_extract_metatypes internal, change the behavior not to install the files by default, unless __QT_INTERNAL_INSTALL is passed, which is used for the Qt build only. __QT_INTERNAL_NO_INSTALL is now a no-op and should be removed from projects. This is behavior change for existing public API, but it's better to fix this now before 6.2.0 release. Introduce a new OUTPUT_FILES option to allow assigning the extracted metatype file paths into a variable that the project provides. The project can then install the files where they need them. [ChangeLog][CMake] qt6_extract_metatypes does not install metatypes files anymore. Instead the OUTPUT_FILES option can be provided to get the list of extracted files for further processing. Pick-to: 6.2 Task-number: QTBUG-95845 Change-Id: If5dd0255a5fea2b598e15118c29ec2ab2ba4324e Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Include quiet packages in feature summaryAlexandru Croitor2021-08-181-1/+2
| | | | | | | | | | | | This will show packages that were found (or not) with find_package(QUIET) in summary just before the configure summary. It's useful for CI logs to determine whether some Qt packages was not found when cross-compiling. Pick-to: 6.2 Change-Id: Ic7d5062cf061f7c60b5c74374f957065dd8029f5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Pick up *Tools components also from host QtKai Köhne2021-08-181-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | Let find_package(Qt6 COMPONENTS LinguistTools) for a cross-compiled Qt fall back to search LinguistTools in the host Qt. Use the same trick as in QtModuleDependencies.cmake: Prepend both CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH with the QT_HOST_PATH (respective ${QT_HOST_PATH}/lib/cmake). Furthermore adding ${QT_HOST_PATH}/lib/cmake to PATHS argument makes sure that find_package will work even with NO_DEFAULT_PATH. Make sure not to match ShaderTools and Tools packages. ShaderTools is the cross-compiled package, the host package name is ShaderToolsTools. Tools is the cross-compiled module from qttools. Allow an opt out via a QT_NO_FIND_HOST_TOOLS_PATH_MANIPULATION variable in case that we accidentally match more packages ending in Tools that are actually cross-compiled packages. Pick-to: 6.1 6.2 Fixes: QTBUG-95602 Change-Id: Ib0a787716fa529e36f22356da069e705d9eed5fa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Remove deprecated CFBundleLongVersionString from Info.plistAlexandru Croitor2021-08-172-4/+0
| | | | | | | | | | | | The CFBundleLongVersionString Info.plist entry has been deprecated and removed from Apple documentation for a long time now. Remove it. Pick-to: 6.2 Task-number: QTBUG-95838 Change-Id: I4e4f74e00d678fd67875976c8884a80cdbb8cec4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* configure: Fix iOS option to be passed for both platform and xplatformAlexandru Croitor2021-08-171-1/+3
| | | | | | | Task-number: QTBUG-95838 Pick-to: 6.2 Change-Id: If0617e1d9c47595d4a350a91ab4f7d47546ebf08 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Save value of QT_UIKIT_SDK in QtBuildInternalsExtra.cmakeAlexandru Croitor2021-08-171-0/+5
| | | | | | | | | | | | | | | The value of QT_UIKIT_SDK is used in configure tests via qt_config_compile_test -> qt_get_platform_try_compile_vars. Up till now QT_UIKIT_SDK was only available in qtbase only. Save the value in BuildInternals to ensure it's used for other repos as well. Change-Id: I46f372267782f1c8e7d48c237fe0264ac72d33bb Pick-to: 6.2 Task-number: QTBUG-95838 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix building iOS projects with a single-arch Qt buildAlexandru Croitor2021-08-171-3/+24
| | | | | | | | | | | | | | | | | | | | Automatically set the CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES values with the ones Qt was configured with, when configuring a user project with the Xcode generator and a single arch / sdk Qt build. This ensures that calling xcodebuild from the command line chooses the correct architecture and SDK when building the project. Allow to opt out of this behavior by passing QT_NO_SET_OSX_ARCHITECTURES and QT_NO_SET_OSX_SYSROOT. Amends 55a15a1c1b93d36d705fc69e44b5c806b807dd55 Amends a6a3b82ffb3d7f1ea13293206401ed360a51e9cd Pick-to: 6.2 Task-number: QTBUG-95838 Change-Id: Ifab16e9eee3100a9b80a2a14b3ea29ba8d9aa6fc Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Suggest "ninja install" for multi-config buildsJoerg Bornemann2021-08-171-0/+7
| | | | | | | | | | | The configure summary now suggests "ninja install" for Ninja Multi-Config builds, because "cmake --install ." does not install all configurations. See CMake upstream issue #21475. Pick-to: 6.2 Change-Id: Ie3129a906945db9d09c6772ce66ec7239797b8fc Reviewed-by: Kai Koehne <kai.koehne@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>
* CMake: Replace usage of WIN32 with CMAKE_HOST_WIN32 in qconfig.cppAlexandru Croitor2021-08-171-1/+1
| | | | | | | | | | | | | The workaround of adding a drive letter to QT_CONFIGURE_PREFIX_PATH_STR should be done when running on any Windows host, not only when targeting Windows. Amends 59c3be711728ab0aa644bfdf50e91a1b020f95bb Pick-to: 6.1 6.2 Task-number: QTBUG-87580 Change-Id: Ic6ca50aa58a4a54fb483e90fe61a907fe86cb002 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>