summaryrefslogtreecommitdiffstats
path: root/cmake
Commit message (Collapse)AuthorAgeFilesLines
* qdevice.pri: Use cmake separators for the pathMårten Nordheim2021-09-101-0/+2
| | | | | | | | | | Because otherwise we may end up with trailing backslashes Change-Id: I7ad24ec34c35f0a7b32241751bbcd2b26a8a23ea Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit a2653331330340c4f44457c49005f4c7226b8316) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Fixes: QTBUG-95602 Change-Id: Ib0a787716fa529e36f22356da069e705d9eed5fa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit d2359b2d4e5db6c42158d536d6e2a2af5ea1e59c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Task-number: QTBUG-87580 Change-Id: Ic6ca50aa58a4a54fb483e90fe61a907fe86cb002 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 6ef3d070a8bad0cfba98fa241a8676401f21371f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Warn when using CMake 3.21.0 due to issue in AUTOMOC/AUTOUICAlexandru Croitor2021-08-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There can be cases where trying to incrementally rebuild an already built Qt will cause a ninja dependency cycle error due to incorrect dependency information created by AUTOMOC and AUTOUIC. Example error when building qtscxml tests ninja: error: dependency cycle: auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen/timestamp -> auto/scxmlcoutput/default/ids1.h -> auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen -> auto/scxmlcoutput/default/CMakeFiles/tst_scxmlcoutput_default_autogen -> auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen/timestamp Example error when building Qt Creator ninja: error: dependency cycle: src/shared/help/shared_help_autogen/include/ui_filternamedialog.h -> src/shared/help/shared_help_autogen/timestamp -> src/shared/help/shared_help_autogen/include/ui_filternamedialog.h Warn and advise to use a different CMake version instead. Change-Id: I6f529ba6a526663bc6ed699b1bfe8a9094129887 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 06c2400f5d439ce1f1945833d9b1895eff843855) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix build with CMake master / 3.22Alexandru Croitor2021-08-101-1/+1
| | | | | | | | | | | | | | | | | CMake master / 3.22 introduced a behavior change in how conditions are evaluated in the while command. It is now consistent with how if() evaluates conditions. This caused an issue in Qt code where a "(" opening parenthesis was evaluated as part of the condition rather than as a string. Fix this by wrapping the evaluation of the variable in quotes. Change-Id: I70c26dc91394f4a14f7a26419df264a069dc7dc5 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Craig Scott <craig.scott@qt.io> (cherry picked from commit eb2282605734152440e840777d1f8a0576e3c7a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Keep public include header locations for internal module priJaeyoon Jung2021-07-261-1/+1
| | | | | | | | | | Amends f254d62cb1807d5bd9ee2e23ef64d4ca2d1b6809. Task-number: QTBUG-95303 Change-Id: Ica8d2850fe427b780d62cd9a9528f387a7ea1b79 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c89a9ccbccdd7d6ceec669e7effec5786eb3f642) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Use namespaced variables in Qt6*Dependencies.cmakeLi Xinwei2021-07-264-96/+95
| | | | | | | Change-Id: I166988020cfd9750a4d58e519742215d0c03ad3e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit bd594f945773f713ca493fd7b040fde8a12bdf87)
* Fix generated pri and prl filesLi Xinwei2021-07-175-6/+17
| | | | | | | | | | | | | | | | Quote the paths after "-L". Get MSVC’s implicit link directories from $ENV{LIB}. Fix some issues cause by Inconsistent case. Amends 2c49f85380d7ad79d9473e0f42e7afaa36d31af9 Fixes: QTBUG-95198 Change-Id: Ie82f10b088e2764396377726340509f24a4ae8e7 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 2915921ad2a79a4ce1651dc7297f6571788d1413) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix bitcode linker flags not to be added on iOSAlexandru Croitor2021-07-161-1/+0
| | | | | | | | | | | | | | | | | | | | We shouldn't force add the bitcode linker flags to user projects. And we don't link anything when building Qt for iOS itself, we only archive object files into static libraries. The final decision whether bitcode should be used is up to the Xcode project. That is controlled by Xcode's ENABLE_BITCODE option. Bitcode compile flags are still added when building Qt itself. Amends a0468331761b497992e9d554c210583781308272 Task-number: QTBUG-95199 Change-Id: I04c77f659b82269bb8010ea262b2e51f36e9def3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 616c32be04b8cee16354283d22dfe5cef890d435) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix platform definition directory in top-level buildAlexey Edelev2021-07-091-1/+1
| | | | | | | | | | | | | | QT_BUILD_DIR should be used instead of CMAKE_BINARY_DIR as a base directory for platform definition when building a non-prefixed build since artifacts are copied to qtbase directory for top-level build. Amends 478f5fcde66a49b710c427447916a0ee0e4d9e0a Task-number: QTBUG-94973 Change-Id: I5cce16fdc7f760b954222ae67a4b85d4beea7f13 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 9bbca531ebe498afa10d9a1c02518fcfc54490a2)
* Fix the detection of platform definitions directoryAlexey Edelev2021-07-092-16/+24
| | | | | | | | | | | | | | | | | | Platform definition directory is defined when building qtbase. Depending on the build type (prefixed/non-prefixed) it should point: - To the source directory when building prefixed qtbase. - To the installation directory of the prefixed qtbase when building consumer projects. - To the build directory of non-prefixed qtbase when building non-prefixed qtbase or consumer projects. TODO: It is desirable to move the logic asssociated with Qt platform definition to the qt_internal_setup_public_platform_target function. Fixes: QTBUG-94973 Change-Id: I8530613f9b2029834c66206bbdf02475528a4640 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 478f5fcde66a49b710c427447916a0ee0e4d9e0a)
* Hide QT_USE_BUNDLED_ CACHE variables from GUIAlexey Edelev2021-07-091-2/+2
| | | | | | | | | | Make QT_USE_BUNDLED_ INTERNAL to hide them from GUI like QtCreator's CMake configurator. Change-Id: Id9dcee31c69b579bbe38611cabb98e46550b0e89 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit f33d11796ff91bfd0323e6bccd03b4cf16b1f371) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix 'Cannot find source file' error with older CMakesAlexandru Croitor2021-06-251-2/+10
| | | | | | | | | | | | | | | | | Configuring a static qtdeclarative with CMake versions older than 3.18.0 fails at generation phase with CMake Error at cmake/QtExecutableHelpers.cmake:28 (add_executable): Cannot find source file: some_path/some_target_plugin_imports_Gui.cpp Marking the generated file as GENERATED explicitly solves the issue. Change-Id: Ife0eba61a1aab4f988d9fe7e2217d30eb96774a7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit e2c6f2ba7ed72195d12e9882c174e59a53317097)
* Disable -Werror=stringop-overflow on GCC >= 10Giuseppe D'Angelo2021-06-221-0/+8
| | | | | | | | | | | | There's a number of upstream bugs that cause false positives; do not make them errors. Change-Id: I4151794d8d37177a47a34aef8d83accf4377d44a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 648e9696d38f9338019d30f297029ba34efb673c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add GCC 11 and C++20 workaroundsGiuseppe D'Angelo2021-06-181-0/+11
| | | | | | | | | | | | | | | | | | | | | | GCC 11.1 has a bug [1] in the preprocessor that leads to -Wsuggest-override warnings being raised in random places, even under pragmas that are supposed to suppress it. For some reason, NOT using the integrated preprocessor fixes it, so add that flag as a workaround. Also, GCC 11 introduces a family of warnings for C++20's deprecations of mixed enum arithmetic, which we use all over the place. Avoid a hard error for those warnings. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100796 Change-Id: I3b2aefa385f191f207e7eb876bc1ed0b18fb342b Task-number: QTBUG-93360 Task-number: QTBUG-94059 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit f29ff5dffb7f9321d2bfb6071813d2d8d88186b3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Handle OPTIONAL_COMPONENTS in qt_find_packageAlexandru Croitor2021-06-185-3/+37
| | | | | | | | | | | | | | | | | | | The optional components arguments were not handled before which caused the recorded package information for static builds to be incorrect, it only recorded the package name without the component. Remove REQUIRED_COMPONENTS TODO, there is no such find_package option, it's already handled by the regular COMPONENTS code path. Amends 07b6d3367debd8f15974abf0f5cdf48f0fe3a536 Fixes: QTBUG-94501 Change-Id: Ib48a7befcb70e20c3f21315897d51d3064b48134 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Dominik Holland <dominik.holland@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit b6c5e0667696c1d4abaf37f2224b2121b72cdebd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace flags with spaces when removing themAlexey Edelev2021-06-121-2/+2
| | | | | | | | | | | | Removing flags based on REGEX may include spaces, so flags might be glued. Replace flags with spaces to keep at least one space for the described case. Fixes: QTBUG-94400 Change-Id: Ice268da36174ef5cf4398d2aee8fcd4731336316 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 523ee5577a3fb1801dc765511c2c76753c10a72e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix generated prl and pri files for MSVCLi Xinwei2021-06-025-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In MSVC static build, if we build Qt with 3rdparty library (e.g. zstd), cmake will add"zstd" (without "-l" prefix) to Qt6Core.prl. Then we use this Qt to build a qmake project, compilation will fail due to missing zstd.obj. Without "-l" prefix, qmake will treat "zstd" as an object file instead of a library. Library names in qt_module.pri and qt_lib_*_private.pri are also missing "-l" prefix. This is because on most compilers, CMAKE_LINK_LIBRARY_FLAG equals "-l". But on MSVC, it is an empty string. So we should pass "-DLINK_LIBRARY_FLAG=-l" for MSVC. Also add "-L/path/to/library" if the library path is not in default linker search directories. This will write un-relocatable paths to prl files only when using 3rdparty libraries to build Qt statically. Usually it's not a problem. In addition, CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is also empty on MSVC. So The third argument of "$<FILTER>" is empty, it is an invalid generator expression. This means no include dir will be written to qt_module.pri and qt_lib_*_private.pri on MSVC. So only use "$<FILTER>" when CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is not empty. Change-Id: Ib66f95dc09cf920363a4b9338fb97747dd2f8ab7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 2c49f85380d7ad79d9473e0f42e7afaa36d31af9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Pass OpenGL_GL_PREFERENCE variable to other Qt reposJoerg Bornemann2021-06-011-0/+8
| | | | | | | | | | | | | | | When building Linux packages, we pass OpenGL_GL_PREFERENCE=LEGACY when building qtbase. This is done to link against legacy OpenGL libs. When building non-qtbase repos, we also need to set this variable to the same value we have in qtbase. Task-number: QTBUG-89754 Fixes: QTBUG-94040 Change-Id: I567b629d245025d2b1544b91cfc265a9c921725f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 20feedac95c519c71d4db93ab28ad1a110dfbcca) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add QT_CONFIGURE_RUNNING variable for configure.cmake filesJoerg Bornemann2021-06-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | configure.cmake files are read twice when using the configure script / qt-configure-module: First, when configure is running and a second time, when CMake creates the local build system files. In the first run, not every function and esp. no targets are available. Code in configure.cmake that accesses targets or calls functions unknown to configure will fail at the configure stage. This patch introduces the QT_CONFIGURE_RUNNING variable that can be used in configure.cmake files to guard such code: if(QT_CONFIGURE_RUNNING) set(_qt_coord_type double) else() get_property(_qt_coord_type TARGET Qt6::Core PROPERTY INTERFACE_QT_COORD_TYPE) endif() Change-Id: Iff39924d6a5133379d28c8204d7b7afdf47de5c8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 37452051d6b68f20a52c65cffd3cde5cb323156e) Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: fix CMake function qt_commandline_addStringHaoyu Liu2021-05-251-1/+1
| | | | | | | | | | 1. a missing '}' breaks CMake 2. the variable "opt" should really be "arg", otherwise it'll be meaningless Change-Id: If29557998bf7aa786dc5c821e2c55f1195e7922b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit c3804ba061ef7ea073dab2855502d35a4d3a67df) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Enable UNICODE for all Qt targets and Qt consumers by defaultAlexey Edelev2021-05-213-8/+16
| | | | | | | | | | | | | | | | | | | After discussion we decided to opt-out the UNICODE definintion behavior. To disable UNICODE in user projects the qt6_disable_unicode_defines function could be used. Amends 5b64e5950cf984abb7d47e0802bcb4b5a21e06fa [ChangeLog][CMake] Enables the UNICODE and _UNICODE definitions on WIN32 platforms by default for all cmake projects to reflect the qmake behavior. Use qt6_disable_unicode_defines function to disable the default unicode definitions. Fixes: QTBUG-93895 Change-Id: Id70ff7dcf8c74f660ec851f8b950e1e3b94d9fb4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 715041b663ababa8b36f90978d20bdcdd80e3117) Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Do not expose Qt internals by the HEADER_MODULEsAlexey Edelev2021-05-201-1/+2
| | | | | | | | | | | | | | | | | | | HEADER_MODULEs use the INTERFACE visibility to link libraries. This causes a transitional propagating of the Qt-internal compile definitions and options to the user targets. This commit avoids an implicit adding of the Qt::PlatformModuleInternal library to the HEADER_MODULEs and stops propagation of the Qt-internal compile definitions and options. If module wants the transitional propagation of some properties, this needs to be done explicitly. Amends 8b7894cb637d21d8fa9bd129849cd23462632d28 Fixes: QTBUG-89951 Change-Id: Ia9cecc38bac98eb5bc6e47d288308b49813ab5ac Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 5b64e5950cf984abb7d47e0802bcb4b5a21e06fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Don't do plugin initialization for static librariesAlexandru Croitor2021-05-201-0/+7
| | | | | | | | | | | | | | | | | | | | Q_IMPORT_PLUGIN generates a global static symbol that initializes a plugin. If this symbol is added to a static library and the library is then linked to an executable, the linker decides that the symbol is unused (because nothing references it) and discards it. This means there's no point to compile the Q_IMPORT_PLUGIN containing files into static libraries. Change the generator expression we use for plugin propagation via associated modules to not compile and link the plugin initialization object file into a static library. Task-number: QTBUG-80863 Change-Id: Ide32c0124c1e313c352a72280ce32ce9fbe8fff1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 5268edf5811251a432fb5096aef6de4ef372f619)
* CMake: add an option to enable or disable versioned hard linkLi Xinwei2021-05-122-0/+8
| | | | | | | | | | | | The option is called QT_CREATE_VERSIONED_HARD_LINK. By default, it is set to ON. Users can set this option to OFF to disable versioned hard link. Fixes: QTBUG-93636 Change-Id: I0ffa1ee1c6bae1950df332fcce3152a861b33db0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 320c282488f4ae4cae735b0be027170803d06cd7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix typo in FindWrapAtomic.cmakeJohn Zimmermann2021-05-121-3/+3
| | | | | | | | | There was a D missing, we want to set CMAKE_REQUIRED_LIBRARIES Change-Id: I7a76d60480ef7bff439f298fe85614d3b7e3ae88 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 224fccdaecbabf72caef3cc7996afe7ad3a857f5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* cmake: FreeBSD has DF_ORIGIN supportThiago Macieira2021-05-121-1/+1
| | | | | | | Change-Id: I755911ae7d0341f49039fffd167afce7fe6b2b38 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit d08d456844ba58c977bf83fc8e48085cbc75abfc) (also cherry-picks fadd87ed15b5f7bf6e7aaed1263e2f2d661a623d)
* CMake: use additional search paths also for tool packageSamuli Piippo2021-05-101-1/+5
| | | | | | | | | | | Use paths configured with QT_ADDITIONAL_PACKAGES_PREFIX_PATH to search also for the tool packages. Task-number: QTBUG-93565 Change-Id: I611b275dd7c4e7ecceb073d16643cd225bbb21d8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 60c87c68016c6f02b0eddd4002f75a49ab51d4a8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Don't use list(PREPEND) in qt.toolchain.cmakeAlexandru Croitor2021-05-101-2/+3
| | | | | | | | | | | | | | | | | | list(PREPEND) command was added in CMake 3.15+, but so far we claim support for CMake 3.14 in user projects. Use set command instead. This is not the only place where we use list PREPEND in public API, but it's the first immediate issue that comes up when using CMake 3.14. Amends 963017f58884dfd929249c5546aadbb0f74501e8 Change-Id: I7ba4507fc7da2dc550317848751502b8b46c298c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit c457e65bf40a8cccff283609924078b5ff985709) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix installation of Find*.cmake files in shadow per-repo buildsJoerg Bornemann2021-05-071-1/+1
| | | | | | | | | | | | | In shadow per-repo builds we never hit the code that is supposed to install cmake/Find*.cmake files. This caused problems when statically building a Qt repo like qtshadertools against qtimageformats which provides such Find*.cmake files. Fixes: QTBUG-91538 Change-Id: I1147daee817ac71303d93e8bf368b2769afb0bb4 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 232c70ecc85243205d4cdd62b6d31dcc32dafeba)
* CMake: fix build with static BrotliLi Xinwei2021-05-071-0/+7
| | | | | | | | | | | BrotliCommon is a dependency of BrotliDec and BrotliEnc. amends 5d2da76c1ee70ffd1f027365c0f3af74b76fd382 Change-Id: I7741d417e95737f8caacd01962985a27dbb7514c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit d104d510ea6c4f3a24f5d6105930d57c6aee0cb6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix Windows build with CMake < 3.19Joerg Bornemann2021-05-051-2/+2
| | | | | | | | | | | | | | | file(REAL_PATH) was introduced in CMake 3.19. Use get_file_name_component(... REALPATH) instead that is available in older CMake versions. This amends commit b226e99c71c. Change-Id: Ibb28ef757228e1a1176ff70c3ec57b7ca751a636 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 33ac3cf7664aa08e3455e516c0d44d923b29955d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Allow usage of QtStandaloneTestTemplateProject as package componentCristian Adam2021-05-034-30/+46
| | | | | | | | | | | | | | | | | | | | | | | | Currently in order to compile a Qt6 test standalone one needs to use the qt-cmake-standalone-test script which will load the Qt6BuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt project with the current test source directory to create a complete CMake project. This commit will allow a test to have these lines at top: cmake_minimum_required(VERSION 3.16) if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) project(a_qt_test LANGUAGES C CXX ASM) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() and be standalone and work with any IDE capable of loading CMake projects. Fixes: QTCREATORBUG-25389 Change-Id: If3f878b7e560a8bfbb604a8f1aa30b7962742e66 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 0a1256a52d8c6c1b85a10f7dc94dfc34e3540040) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix reconfiguration when using a static top-level buildAlexandru Croitor2021-04-291-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | ... and configuring another repo using qt-configure-module. It's possible to configure a top-level Qt with a subset of repos and then afterwards configure additional repos with qt-configure-module. We didn't define QT_REPO_DEPENDENCIES in that case, which caused all plugin config files to be loaded on reconfiguration, thus causing duplicate target errors. Move the QT_SUPERBUILD check to be done every time in QtBuildInternals.cmake rather than when configuring qtbase/qt5. Amends 98e8180e56322ce065e39cc1ef1d65b54caa8c25 Fixes: QTBUG-86670 Fixes: QTBUG-91887 Fixes: QTBUG-92578 Change-Id: I975835ffa02f702799a3c9f68a5e059d2763a951 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit e1c1558218168529ea3fd1ab2e8b775c152ef7ee) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add versioned alias for the Platform targetAlexey Edelev2021-04-271-0/+1
| | | | | | | | | | It's necessary to have versioned alias of the Platform target to use versioned target in the installable cmake files. Change-Id: I79286e1c0642068bdfa5d24c1087ee0c39e48f1a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 8f238788de8fddd08c63a3437029ddfe19a9ee52) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix plugin SKIP_INSTALL optionAlexey Edelev2021-04-271-5/+14
| | | | | | | | | | | If SKIP_INSTALL option is specified for the qt_internal_add_plugin function the install_directory variable become empty and finalizer unable to call qt_finalize_plugin, because of lack of the second argument. It makes sense to use the INSTALL_PATH single argument instead. Change-Id: I2d4b40c8cf812a834c0e045569b45a649d339508 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 361daa2990ddb70805d356ce5df7d8cfae8e1954)
* Skip adding externally added plugins to the plugin meta-setsAlexey Edelev2021-04-271-3/+7
| | | | | | | | | Plugin meta-sets are not visible outside of the module build tree, so there is no point in adding dependencies for externally added plugins. Change-Id: Ica5b29b57c032f4fc9b128172aaa806392e9e581 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit bbe26a766748c00da5e2241a9c7ec5e714dd76ad)
* Fix linking order of the resource objectsAlexey Edelev2021-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The generated object resource library depends on the Qt::Core library because uses the functions defined in qresource.cpp. Dummy linking of the Qt::Core to an object library has an effect only when the object library is linked directly to the executable as a target. If we link the object library as INTERFACE library we miss out all the objects that need to be linked to the executable. This behavior is explained here: https://bit.ly/3sFWKvI Thus, the only option to link the object library objects to the endpoint executable is to use TARGET_OBJECTS property in genex, as it's already done. But that means we are losing all profits that target actually has, especially linking the object library dependencies. The combination of both of the above methods does the job. The only thing that looks fragile so far is order. Currently, the order we use in the target_link_library call applies to the linker command line. This means the object library objects must always appear before the object library target. Change-Id: If1f0e35e0445d5e96a1f2249ab44114cd36630e9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 4ed9402d7a752c739a371706fd5cd82e4626539e)
* Inhibit CMake generator detection for qt-configure-moduleJoerg Bornemann2021-04-261-1/+2
| | | | | | | | | | | | | | | When configuring a Qt module with qt-configure-module, we want to use the same CMake generator that was used for building qtbase. That generator is encoded in qt-cmake-private. But qt-configure-module overrides the generator after trying to detect what generator should be used. That auto-detection is only useful for qtbase-builds and top-level builds. Turn it off for repo builds other than qtbase. Fixes: QTBUG-91405 Change-Id: I07efb4afb51ba69d2f5467d272118fa51637ab54 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 52077d4f0193a236eacac98f75994b44a4c30a91) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Install prl files from all repo build dirs in a top-level buildAlexandru Croitor2021-04-261-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, in a top-level build we always generated the final prl file somewhere under QT_BUILD_DIR (which is qtbase_build_dir). After each repo was processed by QtPostProcess.cmake, we installed the prl files found in PROJECT_BINARY_DIR. For qtquickcontrols2 this meant that qml plugin prl files were placed under qtbase/qml, but we tried installing the prl files from qtquickcontrols2/qml, which didn't have any prl files. In a static Qt build, qmake's qt.prf calls qmlimportscanner to identify which plugins should be linked to the executable. This worked fine because the plugin .pri files were installed correctly. None of the qml plugin library dependencies were linked in though. This is supposed to happen in qmake's C++ code where it tries to find the associated prl file of a linked library in order to extract all its dependencies. Because no prl file was found, linking failed with multiple undefined symbols. Fix this by installing the prl files from QT_BUILD_DIR rather than PROJECT_BINARY_DIR. Note that this will create multiple install rules for certain files, but it's harmless. An example is imageformats. We process qtbase plugins, see qjpeg, issue an install rule from under the qtbase/plugins/imageformats folder. We then process qtimageformats plugins, see webp, issue another install rule from under qtbase/plugins/imageformats. The first install rule will install both qjpeg and qwebp, the second install rule will merely say all plugins are up-to-date. Change-Id: I8a4bb67bfafc1d016eab62f4fe66b6ba378ceeb2 Fixes: QTBUG-93021 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 31ee3c84a78afa67eeb4e4b6da5a8181ea62c387) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Allow enabling Apple app extension API in other reposAlexandru Croitor2021-04-262-3/+4
| | | | | | | | | | | | | | It's needed in qtconnectivity, but currently the qt_disable_apple_app_extension_api_only function is defined in QtInternalTargets.cmake which is loaded only in qtbase. Move the function to cmake/QtTargetHelpers.cmake. Amends e189126f1ae1d2fa2ad0f95ee2c4aa72c770a97b Change-Id: Ia2470e48a91385239394368780f5bbb223000113 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 393f45de907d8c6bca9bdb33d08a6309034c89f5)
* CMake: Fix auto-linking of static plugins for non-QML in-tree testsAlexandru Croitor2021-04-222-16/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Certain repositories like qtsvg, qtimageformats and qtvirtualkyboard build plugins associated with Qt modules from other repositories (qtsvg's QSvgPlugin associated to qtbase's QtGui). When configuring in-tree tests in the same build folder as the repository, the test executables would not automatically link to these plugins. Fix this by recording the existence of such plugins in a separate property of the associated Qt module and only link them when both the test executable and plugin are from the same project (their PROJECT_NAME coincides). This is in addition to linking the plugins associated with the module where both are built in the same repository. The logic is a bit tricky and ensures that plugins are not accidentally initialized twice, so that in-tree tests work for both top-level and per-repo builds. As a drive-by, added a TODO explaining why in-tree tests that need to link to static QML plugins won't work (somewhat unrelated to this change). Amends 734d2cdbc4ff6db6b3df8fffbb23dbbb565c076b Amends b1fcdad9c9b9ad2bddd00f7301c8dd1159d523c2 Task-number: QTBUG-87580 Change-Id: I3e1ff8166864f92dea931ec2ea34b6f56b4eec60 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 6969496e0078f9f9df9bef817caad71cf5213e3a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix auto-linking of static plugins in standalone testsAlexandru Croitor2021-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change introduced in 98e8180e56322ce065e39cc1ef1d65b54caa8c25 fixes reconfiguration issues for repositories that provide plugins associated with modules from a different repository (QSvgPlugin -> QtGui -> qtbase). It does so by only loading the public Plugin CMake packages of dependent repositories. For executables / tests that are built as part of the current repository, plugins are linked via a different simplified mechanism in qt_add_internal_plugin and qt_internal_add_plugin in order to prevent exporting link cycles between plugins and Qt modules. This works for the majority of in-tree tests, but unfortunately breaks static standalone tests. For example in qtbase neither mechanism will link plugins to the standalone tests: - qtbase has no repo dependencies, so the first mechanism (loading of public plugin packages) is skipped because we assume we are merely reconfiguring the main build of qtbase and we don't want to accidentally create duplicate plugin targets - because a standalone test configuration does not call qt_internal_add_plugin, no association is done between qt plugin and module and thus all tests (qt_internal_add_test -> qt_internal_add_executable) don't get the simplified plugin linking Fix this by allowing loading of the public CMake plugin packages when doing standalone tests. It should be safe to do so because we don't build any plugins in this case, only tests. Amends 98e8180e56322ce065e39cc1ef1d65b54caa8c25 Task-number: QTBUG-87580 Change-Id: I690a0366c73a24e7f49c65ed13cd70362c273d81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit be1ee03a0fafa28efa0c0e45f21f9dc684625957) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* MSVC: define _CRT_SECURE_NO_WARNINGS for all internal CMake targetsLi Xinwei2021-04-202-4/+1
| | | | | | | | | | | | | | | | | | In commit 013abe320680b3dcd3f6d7e4fb4880e590ba10e6, I add _CRT_SECURE_NO_WARNINGS definition for all Qt internal module targets, to suppress MSVC warnings like: warning C4996: 'strncpy': This function or variable may be unsafe. However, when compiling some internal tools, such as qmake and qdoc, such warnings also exist. To suppress this kind of warning entirely, _CRT_SECURE_NO_WARNINGS definition should be added for all Qt internal targets when using MSVC compiler. Change-Id: I9c37b20672f9d0f470e3e9ea847e5221f43bfc04 Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit c7a27678d6916a51848c991fb3ee21acc6a6f8ca) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* make FindWrapBrotli.cmake not depend on vcpkg or PkgConfigLi Xinwei2021-04-201-0/+47
| | | | | | | | | | | | | | | | | Currently, FindWrapBrotli.cmake depends on vcpkg or PkgConfig. But for users who build Brotli by themselves and don't have vcpkg or PkgConfig, the Brotli cannot be found. As a reference, I use following CMake commands to build Brotli: cmake path/to/Brotli/source -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES=Release;Debug -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_CONFIGS=all -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=path/to/install Change-Id: I2fa8d3293dd55ebc18937e13fac40d144ca4c1e2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 5d2da76c1ee70ffd1f027365c0f3af74b76fd382) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Generate better Xcode iOS projectsAlexandru Croitor2021-04-203-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an iOS specific plist file like we do for macOS. If the user hasn't specified a bundle identifier or a development team id, do what qmake does and query the Xcode preferences file to pre-populate those if possible. This allows running cmake -GXcode ./foo on a Qt example project and building it with xcodebuild on the command line without having to go through the IDE to set a development team id or modifying the example project to add a product bundle identifier. Note that the change assumes that the development team id has been previously set / configured via Xcode. If no such id is found, then the value will not be set and the user will still have to specify it either in the project file or via the Xcode UI after the project has been generated. Amends 3a2fa3fec5a43d30f1a93a8e89e2973f23ee4ef3 Change-Id: Iaab4e57de72c9877fb9035d28f9a879b2c91a33c Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit 4d838dae5a821e9e5f013ba1d5a494ece1b5180e) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CMake: Introduce zlib find script to work around hardcoded iOS SDKAlexandru Croitor2021-04-191-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Xcode allows building a project targeting either the device or simulator sysroot in one single build dir, but for the sysroot switching to work there should be no linker or compiler flags referencing absolute paths of a specific sysroot. During CMake configuration of a project targeting iOS, all found system libraries will be within one single sysroot, either the device one or the simulator one, whichever one was passed to CMAKE_OSX_SYSROOT. CMake will then generate the Xcode project and pass those absolute paths, which makes sysroot switching within Xcode not work. To avoid that, the CMake documentation recommends passing linker and framework flags of the form '-lfoo' and '-framework bar' instead of absolute paths. Xcode then takes care of setting the correct framework search path. Zlib is one of the libraries found in the iOS sysroot and thus passed as absolute path. To avoid that, create a new FindWrapZLIB find script. The target it creates will pass the absolute path to the library on non Apple platforms and an -lz linker flag on Apple platforms (macOS and iOS). To avoid issues with target global promotion when system PNG package is found, ensure that a found ZLIB::ZLIB target is promoted to global manually in src/gui/configure.cmake. Change-Id: I8bd8649be4f680a331ad51925f27cb9d13ac5e5f Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit b25eb6e0bd1e3b91c44dc4892d529b95c8677889) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix DESTDIR handling on Windows for Qt modules != qtbaseJoerg Bornemann2021-04-191-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | On the CI system, we build qtbase with CMAKE_INSTALL_PREFIX set to a path without a drive letter to support DESTDIR when installing. Other Qt modules are built without CMAKE_INSTALL_PREFIX set. The Qt6BuildInternals package provides a default value. Since commit e6527e2f73663205a0f36feac5a7feda47fba152 this default prefix is calculated from the current installation location. This default prefix however has a drive letter, breaking DESTDIR support. Broken DESTDIR support in this case means for Android that file(INSTALL) can properly install but stripping will silently fail. We now compare the "real path" of the original prefix from qtbase and the calculated prefix. When they're equal, we use the original CMAKE_INSTALL_PREFIX. Fixes: QTBUG-92890 Change-Id: I96fb0655e02c5c695722b7e01a32e209cbdea4cc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 15b26935fca4ab14298abdcc70b3cb15b6cca195) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix top-level build repository targetsJoerg Bornemann2021-04-191-9/+10
| | | | | | | | | | | | | The directory-level targets missed the first level of sub-targets. E.g. `qtbase_qmake` did not have a dependency to `qmake`. Fix qt_build_internals_get_repo_targets to first grab all targets of the subdirectory and then recurse. Change-Id: I3604000caec22fac9a4cc5f5aaf651d550d16793 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 82f8519b827ba7fd89f8168632461f47b09605a7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Warn when using CMake 3.20.1 due to crashes in AUTOMOCAlexandru Croitor2021-04-171-0/+6
| | | | | | | | | | | | | With CMake 3.20.1 AUTOMOC can crash or hang on Windows when used with a Qt installation that supports moc depfiles due to missing multi-threaded locking. Warn and advise to use a different CMake version instead. Change-Id: I78d2269c48dfc2541bebcd6ab23aaa5595012149 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit aab8a0ac6e5365d97d3c7571b26430776b7b5f49) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>