summaryrefslogtreecommitdiffstats
path: root/cmake
Commit message (Collapse)AuthorAgeFilesLines
* Fix framework path for *_header_check targetsJoerg Bornemann2021-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | When building a Qt module against an installer-provided Qt on macOS, the module pulls in the headersclean feature that creates the *_header_check targets. Those targets try to compile the public headers of the module, and the compilation command contains the -iframework argument. That -iframework argument is supposed to point to the directory where the Qt libs are installed. However, it pointed to the original CMAKE_INSTALL_PREFIX of the machine where Qt was packaged. Use the QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX variable instead that contains the real installation location, even for an installer-provided Qt. Fixes: QTBUG-90402 Change-Id: I27de8b3cc816488c2716042383b334d5c421452d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit bd8d74e0e265297d61fe3b42f71a282bf381c379) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QtEntryPoint: Fix linking Release against RelWithDebInfo with MSVCJoerg Bornemann2021-01-181-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | To be able to link a Release user project against a RelWithDebInfo Qt we set several IMPORTED_*_RELEASE properties in the *AdditionalTargetInfo.cmake file of each Qt module. The EntryPoint module however is a bit special as it is an INTERFACE_LIBRARY linking publicly against a static library (EntryPointimplementation). Its *AdditionalTargetInfo.cmake file was almost empty, because qt_internal_export_additional_targets_file was called before EntryPointImplementation was set up. Also, qt_internal_add_module, which calls qt_internal_export_additional_targets_file, does not know that we want to export the EntryPointImplementation target. We fix this by telling qt_internal_add_module(EntryPoint) to not generate the *AdditionalTargetInfo.cmake file and call qt_internal_export_additional_targets_file later to take the targets EntryPoint and EntryPointImplementation into consideration. qt_internal_add_module learned the option NO_ADDITIONAL_TARGET_INFO to turn off the generation of *AdditionalTargetInfo.cmake files. Fixes: QTBUG-90039 Change-Id: I68ec7125b538a57567035e7adb8dac3b213f95e6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit b0add5bf2f56c2afc8bdf27ccbb153414617250b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Lower the CMake minimum required version for single-config buildsJoerg Bornemann2021-01-141-0/+10
| | | | | | | | | | | | | | | | | | | | | Ubuntu 20.04 is a supported platform and comes with CMake 3.16. The current state of the Qt build works fine with this CMake version, mainly because the default build on Linux is single-config. For multi-config builds we have higher version requirements as documented in cmake/README.md. This lowers the barrier for users using single-config builds who don't want or cannot upgrade to CMake >= 3.18. For Ninja Multi-Config builds, which were introduced by CMake 3.17, we yield a warning that 3.18.3 is the lowest supported version. Change-Id: Ia918b9f2b494508e86301ffc0e138d3ad4dbaf86 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 20a17911576297f22b9da9849b677476c2d6e0ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix warning in generated test wrappersAlexey Edelev2021-01-131-1/+2
| | | | | | | | | | | | | | Since test command variable may contain quotes, there is a warning in generated test wrappers related to 'message(FATAL_ERROR', that should display full command in log in case of error. To avoid any complicated quoting of command to only display it, join command into single string in wrapper script and pass resulting variable to 'message(FATAL_ERROR'. Change-Id: Ie990fc0b0bf2c19b119c7c4e2aeec092e5200103 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 7582f7b03d52103c5299812aed8705d21d4f8b9b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Use -ffat-lto-objects for static libraries with ltcg and GCCChristophe Giboudeaux2021-01-131-0/+8
| | | | | | | | | | | | | | | CMake <= 3.19 adds the '-fno-fat-lto-objects' compiler flag unconditionally when CMAKE_INTERPROCEDURAL_OPTIMIZATION is enabled. This is fine for shared libraries but static ones need the opposite compiler flag. Task-number: QTBUG-89426 Change-Id: Ie5f48178803a270f6d94408f7a8e85d379eb123c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9563be2870b85309e163db950fefcb9200cac6f4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove redundant .qch from installed docsAlexey Edelev2021-01-081-1/+3
| | | | | | | | | | | Use upper-level document build directory for generated .qch files. This avoids copying of .qch with html documents and duplicating them in the installation directory. Change-Id: I63b2de0047005419d352ea259dec6f17a826a477 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 4d34314679598078d11508f540fe75f51a879046) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: improve FindMySQL.cmakeLi Xinwei2021-01-081-10/+9
| | | | | | | | | | | | | | | | On Windows, Qt should libmysql.lib instead of mysqlclient.lib. Add support for mariadb. Re-indent FindMySQL.cmake. Fixes: QTBUG-88661 Fixes: QTBUG-89775 Change-Id: I6bdf195b8976c59230a12af335a838af55df0caf Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 0c7042defaf3a2a97aebc6f652b4d34229093a5a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add newline to the end of the config.summaryAlexey Edelev2021-01-081-0/+1
| | | | | | | | | Amends 94b6bec01f250065b28d5528ea9239bafd5253e5 Change-Id: I0d4be9c7f9aff071468a66d7940d6cd2488136ca Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit 7f5429f2f45bdfb20ea67ebc9a75891bc5ee6549) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix qch install pathAlexey Edelev2021-01-071-1/+1
| | | | | | | | | | Exclude qch_file_name from install DESTINATION Fixes: QTBUG-89769 Change-Id: I8dba13a0a2c2c92d6b2d6aa438c295b42a04156b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 0f38f69d4493d44ef65c4e1ab52f990241139c6a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Add proactive check of generator multi-config capabilitiesAlexey Edelev2021-01-051-0/+10
| | | | | | | | | | | Add explicit error, if multi-config build is requested, but selected generator doesn't support it. Fixes: QTBUG-88287 Change-Id: I6dba589bb59ad69fa07221c657df272ec75c359b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 52e1603e33db9ef29fe1eff8c689d38166d393f1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix missing report entriesAlexey Edelev2021-01-051-2/+2
| | | | | | | | | | | Increment command_count correct way. Fixes: QTBUG-88054 Change-Id: I0769814ed75ee12db1cab3b1f85635b4d7ee0605 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 01708a44de2c9fe83e554099528b9c2f0a30d731) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix glitch in module pri generation for Ninja Multi-ConfigJoerg Bornemann2021-01-041-0/+1
| | | | | | | | | | | | | | | With Ninja Multi-Config, QMAKE_LIBS_FOO_DEBUG and QMAKE_LIBS_FOO_RELEASE are generated, if their values differ. In that case we did not create an empty QMAKE_LIBS_FOO assignment. That, however, is needed to make the library 'foo' known to qmake_use.prf. This amends bd98ba0d17b7a7c14fefc1741e68e8ca945a6655. Fixes: QTBUG-89387 Change-Id: I80e23746e6ba6ff7f5f4186116232395814cee15 Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit e40b31fe6803dea39649c7c61eaca5b8d597dacf) Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Fix dirty summary file when reconfigure qtAlexey Edelev2020-12-301-1/+2
| | | | | | | | | | | | Overwrite summary file during each configuration cycle. Amends 6baf36d77432dc56a47e50f59ccde93b73cfe204 Fixes: QTBUG-87830 Change-Id: Ie77f9aded4a7395592ff3cefad02265d836bebcc Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit 94b6bec01f250065b28d5528ea9239bafd5253e5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Revert "CMake: Fix missing report entries"Alexey Edelev2020-12-301-2/+1
| | | | | | | | | | | This reverts commit 642ee46f98c6b3cd98a323f7dc5cac3a738b066c. Reason for revert: Issue when command_count is actually 0 Change-Id: I1b2603f25b56e3bd50cfc22a08925930ad231498 Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit 34c3b12fd58fc1833abd20eb7b222cb6561e1b03) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix missing report entriesAlexey Edelev2020-12-291-1/+2
| | | | | | | | | | | Use LESS_EQUAL condition since qt_configure_command_count stores last added command index but not actual count Fixes: QTBUG-88054 Change-Id: I8112820f9885bdad5a786a4f6b4890d8f2fbe14b Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit 642ee46f98c6b3cd98a323f7dc5cac3a738b066c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Store config summary to fileAlexey Edelev2020-12-291-0/+5
| | | | | | | | | | Add generation of qmake-like config.summary in build folder Fixes: QTBUG-87830 Change-Id: I08dd9b3116c6200f7e9f5de96605118c1ea474ad Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit 6baf36d77432dc56a47e50f59ccde93b73cfe204) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Add --enable-new-dtags flag supportAlexey Edelev2020-12-221-0/+4
| | | | | | | | | | | | | | Remove enable-new-dtags from feature mapping, handle it as regular feature. Regenerate configure.cmake with 'enable-new-dtags' enabled. Check for enable_new_dtags feature, add -Wl,--enable-new-dtags if enabled. Fixes: QTBUG-89013 Change-Id: Ice57c02dc85f7f9ecf14e3bc65f31a57b589ce24 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Craig Scott <craig.scott@qt.io> (cherry picked from commit bbebfa0be2e51b638459d6d812e4db25a65a0d6d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Use Release build type by defaultAlexey Edelev2020-12-211-7/+7
| | | | | | | | | | | | Use developer-build feature to set Debug build by default instead of .git folder detection Task-number: QTBUG-89410 Fixes: QTBUG-89476 Change-Id: I2a4f529299d4875e7b0eef5b41dd7a6b9402178b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit b4b33846b4dc703e637b7d365676345eda0da460) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Use host variables instead of hardcoded directoriesAlexey Edelev2020-12-217-12/+23
| | | | | | | | | | | | | | | | | | | | 'QT_HOST_PATH' indicates that we use crosscompilation toolchain to build project. In this case 'Qt6Config.cmake' loads 'Qt6HostInfoConfig.cmake' from host QT_HOST_PATH, that defines correct paths to host tools. Replace hardcoded paths for host tools by paths recorded in Qt6HostInfoConfig.cmake. Correct conditions for QT_HOST_PATH, evaluate it explicitly as string, but not as boolean expression. Fixes: QTBUG-86557 Change-Id: Ib52bbd32478051d019a932dcb1f735e2d4aacfbf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 56bdef94379479f27858dccc73a95614648735bb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Add detection of FEATURE_foo change by userAlexey Edelev2020-12-183-32/+67
| | | | | | | | | | | | | | | | | | | | | | Unset all QT_FEATURE_foo values for every build. If any of FEATURE_foo is different of QT_FEATURE_foo, mark whole Qt build as dirty. Reset FEATURE_foo for dirty builds to the calculated value if it doesn't meet its condition. Set Qt module as NOT FOUND if its target was not created during configuration. Main issue with this approach are generated files, that became trash once the related features are disabled. This especially affects features that enable/disable Qt modules. FooConfig.cmake files are created and generate lots of warnings if feature was disabled. We may introduce a module cleanup procedure at some point. Fixes: QTBUG-85962 Change-Id: Id71c1edb4027b24c6793063e40cc9d612c24ebce Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 61943aefd68b7d88c5eb395c4e44d08a94a70ad0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix module separate build error when -DFEATURE_static_runtime=ONLi Xinwei2020-12-171-9/+9
| | | | | | | | | | | | | | | | | | | Build qtbase with -DFEATURE_static_runtime=ON, and then separately build another module, following build error occurs: error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'. That's because all the sources in this module are compiled with 'MD'. When separately building a module except qtbase, FEATURE_static_runtime is not exist in cmake cache. So we should use QT_FEATURE_static_runtime instead of FEATURE_static_runtime in qt_set_common_target_properties. Additionally, adjust the indentation. Change-Id: I2cf4737db9d3e8533570039a66c7d277d62a8d14 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 970e54c63d487ff5a334b8037ce0890fceb24e0f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix compile warnings when MSVC and -DFEATURE_static_runtime=ONLi Xinwei2020-12-171-0/+2
| | | | | | | | | | | | | | When using MSVC compiler and -DFEATURE_static_runtime=ON, qrc_foo.cpp and qtentrypoint_win.cpp are still compiled with '-MD' or '-MDd' flag, which will cause following warnings and other possible problems: warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library Change-Id: I6794930a64e9cff4dc1c9632fc3fc64227848af0 Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 21e4e85a5798884837b35859f73f1eca4cb976d2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix autotest config in cross-compiled prefix buildEirik Aavitsland2020-12-171-1/+5
| | | | | | | | | | | qt-cmake-standalone-test would be looking for the config files under the target machine install prefix instead of under the staging prefix on the build host. Change-Id: I29850af6d8fe502f4944f689ec10539d17ccdcb9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit e26d2865a718cecd08233e84673c67c5ca3bc765) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: install android test scripts to libexec to test on all modulesAssam Boudjelthia2020-12-111-0/+9
| | | | | | | | | | | | The scripts that are used by Android test VMs are now located in qtbase and are not easily usable by other modules. To fix that and allow other modules to use those scripts, we install them with cmake into libexec. Task-number: QTQAINFRA-4052 Change-Id: Ibdd3658fd9fe7e007104a85d9999028a2de99a33 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit f3cfdb905b926948659f37924837b3c14868ff6a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Wrap benchmarks with cmake scriptAlexey Edelev2020-12-111-42/+57
| | | | | | | | | | | | | | | | | Wrap benchmark executable target with cmake script to run it on windows without necessity of environment variables set. Move common logic related to test and benchmark environment to 'qt_internal_collect_command_environment' function. Make error message of wrapper script a bit more verbose. Amends 61d5b019727dd1c06366205cb307a2a928a2a29c Task-number: QTBUG-89076 Change-Id: I6ad3a027dc071176070cf3af4cf306f20d652039 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit cb43c7176b882b33f352fbbab0ea4ba0b5cf66dc)
* CMake: Use test wrapper to run android testsAlexey Edelev2020-12-112-78/+168
| | | | | | | | | | | | | | | | | | | | Refactor test adding procedure. It's expected that for each new platform we prepare test executable and arguments first and then pass them to common test adding section. Rename '_qt_internal_wrap_test' to 'qt_internal_create_command_script' Rework paramerters handling of 'qt_internal_create_command_script', make them named. Add 'qt_internal_create_test_script' to add tests and wrap them using 'qt_internal_create_command_script'. Amends f19266bd02a01d4b7b277ea769c4c17727b1e661 Fixes: QTBUG-88053 Change-Id: I812f4a295005bf3a85cdcb5b8c41180f8249dc96 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit d5bafc80cd38202464576f3e0b38de645bb2dc64)
* CMake: Improve tests wrapper arguments handlingAlexey Edelev2020-12-111-2/+15
| | | | | | | | | | | | | Use 'separate_arguments' to explicitly split arguments from environment that form 'COMMAND' for execute_process. Enclose using bracket syntax arguments, that propagated to wrapper script as pure strings. Amends f19266bd02a01d4b7b277ea769c4c17727b1e661 Change-Id: I858ddff7efa281f9cecfda656a02e1fd12361758 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c0ebfb81de8fbd352b5a63973f5dde978599c08c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Document some missing configure cmake mappingsLi Xinwei2020-12-091-5/+5
| | | | | | | Change-Id: I4b15dde581e28aece52d7f98cb3d94827e8bcc33 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c9ac82f3b8e37a6db02c63e10b1de6909630c5f1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Do not write Effective[Source]Paths to target_qt.confJoerg Bornemann2020-12-081-17/+0
| | | | | | | | | | | This was needed, when the mkspecs directory was not present in the non-prefix build directory. That's not the case anymore. Fixes: QTBUG-89182 Change-Id: I2b04c2d857b0af324e1d7c41ed1934a62275d6f1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 192d37099da0db1b7bf7452c44daacc19b85094b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Disable static plugin imports for non-executable targetsAlexandru Croitor2020-12-083-1/+31
| | | | | | | | | | | | | | | There is no point in generating cpp files containing Q_IMPORT_PLUGIN() macro calls for non-executable targets like modules, plugins and object libraries in a static Qt build. It causes unnecessary compiling of 10+ files for each of those targets. In a static Qt build, plugin imports should only be done for executables, tools and applications. Change-Id: Ied90ef2f6d77a61a093d393cfdf94c400284c4f0 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit b3576164f0aedf8d528c3724332a36b0fb6d05e0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Offer to build manual tests through QT_BUILD_MANUAL_TESTSAleix Pol2020-12-082-2/+4
| | | | | | | | | | Disabled by default as they are currently not being built and many are not working properly, this will allow us to start using them again. Change-Id: I823368d04e9fde2beccabedc3ca15efd1f355bfb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 9d831491334e75f8ccc691edaeb173af81ab80ac) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Force crosscompiling_emulator to empty string if not foundAlexey Edelev2020-12-071-3/+6
| | | | | | | | | | | | | | In some case CROSSCOMPILING_EMULATOR property is not INHERITED and is set to 'NOTFOUND' by get_test_property. Force it to empty string in this case. Add missed 'name' argument to '_qt_internal_wrap_test'. 'name' previously was used from parent scope. Fixes: QTBUG-88053 Change-Id: I5286bcb9b11659f638e178ce52172dfee994fc34 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 4a9ed410750c8b111d33c52544388904244ec6e5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Add -qt-host-path to configure's help screenJoerg Bornemann2020-12-071-1/+1
| | | | | | | Change-Id: Ia32377e08d72f82e71ce6f2c08e61bd8991b3077 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit a201ce7f11291cbb6810f295126fb3533edbdc53) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Add extra targets to run single benchmark using CMake generatorAlexey Edelev2020-12-074-30/+49
| | | | | | | | | | | | | | | | | | | Add custom targets with '_benchmark' suffixes to make run of benchmarks using generators possible, e.g.: $ ninja tst_bench_qudpsocket_benchmark Extend '-[no]make' option to pass benchmark. Rework '-[no]make' processing to unify these options processing. Also looks like it doesn't make sense to enable benchmarks without having test enabled. So '-DQT_BUILD_BENCHMARKS' enables test as own dependency automatically. Task-number: QTBUG-89076 Change-Id: Ieee9eadaf6d75a1efec120242d6eb786ace1b071 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 61d5b019727dd1c06366205cb307a2a928a2a29c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Enable NEW policies by CMake version with a global defaultCraig Scott2020-12-0713-16/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a CMake release introduces a new policy that affects most Qt modules, it may be appropriate to make each module aware of that newer CMake version and use the NEW policy without raising the minimum CMake version requirement. To reduce the churn associated with making that change across all Qt modules individually, this change allows it to be updated in a central place (qtbase), but in a way that allows a Qt module to override it in its own .cmake.conf file if required (e.g. to address the issues identified by policy warnings at a later time). The policies are modified at the start of the call to qt_build_repo_begin(). For commands defined by the qtbase module, qtbase needs to be in control of the policy settings at the point where those commands are defined. The above mechanism should not affect the policy settings for these commands, so the various *Config.cmake.in files must not specify policy ranges in a way that a Qt module's .cmake.conf file could influence. Starting with CMake 3.12, policies can be specified as a version range with the cmake_minimum_required() and cmake_policy() commands. All policies introduced in CMake versions up to the upper limit of that range will be set to NEW. The actual version of CMake being used only has to be at least the lower limit of the specified version range. This change uses cmake_minimum_required() rather than cmake_policy() due to the latter not halting further processing upon failure. See the following: https://gitlab.kitware.com/cmake/cmake/-/issues/21557 Task-number: QTBUG-88700 Change-Id: I0a1f2611dd629f847a18186394f500d7f52753bc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 3859f15ec9fd333089e6eb1152a76592cd5f83c0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Add handling of TESTRUNNER and TESTARGS by Qt testsAlexey Edelev2020-12-041-36/+137
| | | | | | | | | | | | | Wrap Qt tests to handle TESTRUNNER and TESTARGS environment variables. Variables are handled according to qmake build procedure. All test now are wrapped by generated CMake script. Fixes: QTBUG-88053 Change-Id: I339977ce6ce11ddd38a4bf0bd26eb8f2ae463ba3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit f19266bd02a01d4b7b277ea769c4c17727b1e661) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Build examples with qmake against a CMake built QtAlexandru Croitor2020-12-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | We want to remove the Qt .pro files for projects, except examples, because examples are still meant to build with qmake. To not lose coverage on examples built with qmake, add instructions that will build the qtrepo/examples folder with qmake when the CMake configuration has -DQT_BUILD_EXAMPLES=ON. This means that such configurations will build examples both with CMake and qmake. Aside from making sure that our examples will still build with qmake, it will gives us some some coverage that a CMake-built qmake works correctly. Implementation-wise, add new instructions files that can call qmake and make depending on configuration and target type. Fixes: QTBUG-85986 Change-Id: Ie8f4cbcda03c94da2aef455e32f48dad41a4bdb0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 24f12d0cefe00adfe1b11cf41efbb146d529a6cd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Avoid MSVC C4996 warningsLi Xinwei2020-12-041-0/+4
| | | | | | | | | | | | | | | | | | The qmake build system defines _CRT_SECURE_NO_WARNINGS in mkspecs/features/qt_module.prf, the cmake build system should do the same thing in qt_internal_add_module(). Adding this definition can avoid warnings like: warning C4996: 'strncpy': This function or variable may be unsafe. As a special case, Bootstrap uses add_library() instead of qt_internal_add_module(), so _CRT_SECURE_NO_WARNINGS should also be defined in src/tools/bootstrap/CMakeLists.txt. Change-Id: Ic82193d177f82785fd84948efa78c49ca8d8db46 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 013abe320680b3dcd3f6d7e4fb4880e590ba10e6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix arch parsing for oss-fuzzAlexandru Croitor2020-12-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'll preface by saying, it's not clear to me why the behavior is different. Our qt_run_config_test_architecture function builds a target executable, and then uses file(STRINGS) to try and parse out some magic strings that we expect the executable to have (architecture, abi, etc). In qmake this was done by matching with a regular expression ending on a \\0 null byte character. In CMake, we do a string(FIND) and string(SUBSTRING until the end of the line) on a *line* returned from file(STRINGS). Notably, I did not find any regexp syntax provided by CMake to try and match a null byte character. Note the docs for file(STRINGS) implies to me that *lines* are detected by looking for newline characters '\n'. The docs also mention that binary data in the file is ignored. What's binary data though? If you open the executable with a hex editor, at least on macOS, the strings we are interested in are indeed separated by null byte chars, not newline chars. On most platforms file(STRINGS) did end a line on the null byte character. Except, for some reason not when building Qt for the oss-fuzz project with clang under Docker. Calling message() on one of the lines prints a very long string with null characters seemingly replaced with semicolons, and of course the matched architecture string is wrong and fails configuration. For *some reason*, if I add a "REGEX ==Qt=magic=Qt==" option to the file(STRINGS) command, the captured output lines don't contain semicolons even when building for oss-fuzz. The extracted strings are then correct, and configuration succeeds. Use the REGEX option workaround, with the aim to quickly fix Qt building for oss-fuzz for 6.0.1 release. Fixes: QTBUG-89047 Change-Id: Iad11c1090c1187aadd39082f196050bf3290df95 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit f071ba31b2e441268518217cbe2ec4fe1c978b31) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix QMAKE_LIB_<NAME> variable names in module .pri filesJoerg Bornemann2020-12-031-0/+1
| | | | | | | | | | | | | | | | | | | | | QMake libraries that contain dashes are referenced by QMAKE_USE as is, but the corresponding QMAKE_LIB_<NAME> variable must be normalized to contain underscores. Example from the qmake build: ./mkspecs/modules/qt_lib_waylandclient.pri 11:QT.waylandclient.uses = wayland-client xkbcommon wayland-cursor ./mkspecs/modules/qt_lib_waylandclient_private.pri 12:QMAKE_DEPENDS_WAYLAND_CURSOR_CC = WAYLAND_CLIENT 13:QMAKE_DEPENDS_WAYLAND_CURSOR_LD = WAYLAND_CLIENT 15:QMAKE_LIBS_WAYLAND_CURSOR = -lwayland-cursor Change-Id: If31bd45764d52f97d80d6388503008dc1ffb16ab Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit e32e4898dde1dc2a5ae19a1c3dc4609064258a43) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: mention the QT_BUILD_X_BY_DEFAULT=OFFGiuseppe D'Angelo2020-12-021-2/+7
| | | | | | | | | | | Which is probably the direct port of -nomake XXX, as qmake always offered the way to build tests/examples/etc. after configuring without, while cmake doesn't. Change-Id: I85b039e56cde3ddfaf661385100d3c3a8cc2ac16 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit b70ddde4b651d0825e7e12fdbc50271bd298eea8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fill QT.<module-name>.uses entries in module .pri filesJoerg Bornemann2020-12-012-5/+38
| | | | | | | | | | | | | | | | | Those entries were always empty. The INTERFACE_QT_MODULE_USES property was never set. Map each public dependency to its qmake lib name and place this value into the module's QT.<module-name>.uses variable. Take into account the "_nolink" target modifier and translate it to qmake's "/nolink". Fixes: QTBUG-88951 Change-Id: Ib6ef65b842a1fe1da3ade55867583343b4ee76ee Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 92d60ae589442cfbe1e7ac1bb4c42334a09af310) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Rename internal variableJoerg Bornemann2020-12-012-2/+2
| | | | | | | | | | | | Rename QT_QMAKE_LIB_TARGETS_foo to QT_TARGETS_OF_QMAKE_LIB_foo, because we want to introduce the counterpart QT_QMAKE_LIB_OF_TARGET_bar in a subsequent commit. Task-number: QTBUG-88951 Change-Id: I33f00f4fe65c5977da6e74c632ebeab3b891c89a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit bf483ca9794c8eaafd9007e7e76117bab5bfa35f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Do not discard empty QMAKE_LIBS_FOO entriesJoerg Bornemann2020-12-011-8/+8
| | | | | | | | | | | | | Consider a qmake lib 'foo' that doesn't have entries in QMAKE_LIBS_FOO. Then we must not discard this entry in the generated module pri file, because otherwise any attempt to QMAKE_USE 'foo' will fail with the error message "Library 'foo' is not defined.". Task-number: QTBUG-88951 Change-Id: Ibed283857f5f66b1b79459fe7b7cf06c7ce0691d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit bd98ba0d17b7a7c14fefc1741e68e8ca945a6655) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Add debug information for 'qt_evaluate_config_expression'Alexey Edelev2020-12-011-3/+64
| | | | | | | | | | | | | Add '_qt_internal_dump_expression_values' function that dumps all values evaluated by 'qt_evaluate_config_expression'. '_qt_internal_dump_expression_values' doesn't evaluate undefined features, only collect actual values. Fixes: QTBUG-88476 Change-Id: I9d09ffbd9f9fa91bc4f36536c58e7f118b06f9b9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c140b26959038ada22452079ebc6e33195e9957d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix resource object file paths in prl files for prefix buildsAlexandru Croitor2020-11-302-8/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, the prl files always assumed that resource object files are installed into $qt_prefix/lib when doing a prefix build. That was true for qt_internal_add_resource calls, but not for qt6_add_qml_module and qt6_target_qml_files. Change qt_internal_record_rcc_object_files to take a new required INSTALL_LOCATION argument. The argument takes a path relative to CMAKE_INSTALL_PREFIX. Modify __qt_propagate_generated_resource to save the relative path of the generated resource source file, which will be used in the computation of the final resource object file location. This is needed because the Qml resource functions place the source files in a different directory layout, e.g. .rcc vs .qmlcache Modify qt_generate_prl_file to prepend $$[QT_INSTALL_PREFIX]/ instead of $$[QT_INSTALL_LIBS]/ for the resource install paths. A follow up patch is done in qtdeclarative to pass the new INSTALL_LOCATION argument from the Qml CMake functions. Amends f9dcade5e795a631b9a2d93c855aa8198d58e24e Task-number: QTBUG-87702 Task-number: QTBUG-88425 Change-Id: Id17bb517b4cb5d00911bfd10a728ba4e0d44871b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 54d0ca93bca78f8fd31b6761f078e7a96283f183) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Handle empty INCLUDE_DIRECTORIES in genex for qdocCraig Scott2020-11-301-1/+1
| | | | | | | | | | | | | | | | Follow the pattern recommended in the CMake docs for the $<JOIN:...> generator expression. Wrap it in a $<BOOL:...> genex so that if a target's INCLUDE_DIRECTORIES property is empty, we don't add a stray -I with no directory following it. This fixes the following error when running qdoc: qdoc: Missing value after '-I'. Task-number: QTBUG-88838 Change-Id: Ie3ef2625fbb29cc501f7fc22ff7a9cc8ac548322 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit bac73a36e25076a5929c7feac0675860772e7270) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: strip the executable bit from qt-cmake-private-install.cmakeChristophe Giboudeaux2020-11-301-1/+1
| | | | | | | | | | Despite being installed in the the binary directory, this CMake snippet cannot be executed. Change-Id: Ibfd31e51184f0688d19ac063804cc200c95555a7 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 687bd03d09b42faad4c8790c9508518c3d14b456) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix headersclean interaction with header only modulesAlexandru Croitor2020-11-261-12/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before CMake 3.19, we are not allowed to query non INTERFACE_ prefixed property names from INTERFACE libraries. And it was the wrong thing to do as well. Prefix the properties with INTERFACE_ as appropriate. Don't try to add INTERFACE_COMPILE_DEFINITIONS from header only modules to the headerclean compile commands. This causes configuration issues with UiPlugin in qttools. Fortunately it seems that qmake doesn't do that for 'header_module's either. Finally don't query for the FRAMEWORK property on the passed target (INTERFACE libs can't be frameworks). Instead just query if the whole Qt build itself is a framework build. An issue was discovered regarding QT_NO_ENTRYPOINT genexes breaking headersclean add_custom_commands for UiPlugin in qttools. To avoid this the property was renamed to all lower case in 6ca66de9120537134b63d42de6c53c6e5834e8f3. This avoided the immediate issue, but it's possible it might resurface in the future with a different property name that wasn't renamed. In particular I thought it might happen with QT_NO_UTF8_SOURCE but it didn't. In case something like that happens again, the two possible solutions are to bump minimum CMake version requirement to 3.19 (where upper case property names are allowed to be queried from INTERFACE libs) or to implement recursive include directory fetching similar to our qt_internal_walk_libs implementation. Task-number: QTBUG-86053 Task-number: QTBUG-82615 Change-Id: I7815d555ec9ea049a8fd40f2a2f072dcb9f5e9c3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 9b84ea6b47979b5d789b72f9f74326ecbe3a579a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Use cmake_language(DEFER) when available for scope finalizersAlexandru Croitor2020-11-262-14/+31
| | | | | | | | | | | | | | | If CMake version is 3.19 or greater, use cmake_language(DEFER CALL) for Qt internal scope finalizers, instead of the homegrown implementation. Apart from not depending on the hacky homegrown solution, it significantly improves the readability of --trace-redirect logs. Task-number: QTBUG-77377 Change-Id: I5ce374bb313865662c536826e86052bc762438b9 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 69d9b2b6fdd5cd28aa7dca2636eb2f411277ad30) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>