summaryrefslogtreecommitdiffstats
path: root/cmake
Commit message (Collapse)AuthorAgeFilesLines
* CMake: Add qt6_add_plugin public APILeander Beernaert2020-04-222-3/+4
| | | | | | | | | | | | | | | This patch adds a publicly callable qt6_add_plugin() API to create plugins. This API is meant to cover cases such as the plugandpaint example. This patch also renames qt_add_plugin to qt_internal_add_plugin in order to avoid clashes with the public API. To avoid breaking the existing projects, a compatibility wrapper function is enabled by default unless QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY is specified. Fixes: QTBUG-82961 Change-Id: If5b564a8406c90434f1bdad0b8df76d3e6626b5f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix handling of negated feature config valuesJoerg Bornemann2020-04-212-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | Consider a negated feature config value like the following: qt_feature_config("foo" QMAKE_PUBLIC_QT_CONFIG NEGATE) If this feature was disabled, it would turn up in both, enabled_features and disabled_features of module .pri files. Also, QT_CONFIG would contain foo. Expected however is that QT_CONFIG contains no-foo, and only disabled_features contains foo. Fix this by prepending a "no_" prefix to the value, similar to the "no-" prefix in the qmake build. The qt_correct_config function was adjusted to recognize "no_foo" and translate it to the qmakeish "no-foo" config value. Config values that start with "no_" but do not correspond to a feature are left untouched. You can still have values like "no_valley_too_deep" or "no_mountain_too_high". Change-Id: I23d8b18c84e04ea6dfa25cc6ccd8f7e86211b144 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Move Resources API into Qt6CoreMacrosLeander Beernaert2020-04-202-197/+0
| | | | | | | | Move QT6_ADD_RESOURCE to Qt6CoreMacros in order to avoid the extra config file step. Change-Id: Ib445ca35c648cf344ee8795de8bdddc0f0758972 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Relocate quick compiler resource pass to QtDeclarativeLeander Beernaert2020-04-201-136/+14
| | | | | | | | | | | | Since there's no way to register callbacks or to store functions to be called later in CMake, the only way to isolate the quick compiler behavior for qt_add_resources() is to wrap it in a conditional check. As soon as someone loads Qt6QmlMacros, the variable will set and the functionality will be available. Change-Id: I5fbdf2966e7dfdc734512a5b2b973e0ace9da5df Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Make use of CMAKE_CURRENT_FUNCTION_LIST_DIRJoerg Bornemann2020-04-171-2/+4
| | | | | | | | Once we can require CMake 3.17 everywhere, we can remove the variable set up from QtSeparateDebugInfo.cmake. Change-Id: I91572583654054f5fa47ac1e41be23050a5a8c0b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix location of module .pri files for non-prefix buildsJoerg Bornemann2020-04-171-1/+1
| | | | | | | | | In a non-prefix build, the module .pri files must end up in the mkspecs/modules subdirectory of qtbase's build directory. Change-Id: I241f4e274d31de7c1e3c2fa8e5e26fb8747f11c5 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Write QT_BUILD_PARTS to qmodule.priJoerg Bornemann2020-04-172-14/+23
| | | | | Change-Id: I4bddba38b51df3c70780d94f64a31b3040cb0bc8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Write PKG_CONFIG_EXECUTABLE to qmodule.priJoerg Bornemann2020-04-171-5/+11
| | | | | Change-Id: Ide61cc93d44c659740b72d085fb8b15684bc64fa Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Generate qmake pri information for building with qmakeAlexandru Croitor2020-04-172-11/+161
| | | | | | | | | Implemented some necessary functionality to generate correct .pri information, so that qmake can build modules. Task-number: QTBUG-75666 Change-Id: I63281adfef3d01385928b1d8c4be0b32ac97c4d7 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Generate qmake .prl filesJoerg Bornemann2020-04-174-1/+299
| | | | | | | | This commit also adds a qt_finalize_module function that is called for every Qt module after all link dependencies have been added. Change-Id: I489d188d05e368208a8a62828bb12fb395df54bc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Make sure not to use the Qt prefix for standalone testsAlexandru Croitor2020-04-172-0/+19
| | | | | | | | | We don't want people accidentally installing tests into the Qt prefix. Change-Id: Ic99492559875f753897a83af162253cac846a8a5 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Handle super build non-prefix install prefix correctlyAlexandru Croitor2020-04-172-2/+4
| | | | | | | | | | | | | | | | | The install prefix in such a case is the qtbase build dir, and not the qt6 top-level build dir. This caused issues with certain incorrect paths being generated, including a broken qt-cmake-standalone-test script, as well as upon reconfiguration determining that a non-prefix build should be installed. The fix for a non-prefix build is to check explicitly for the qtbase build dir. This works both for super and non-super builds. Task-number: QTBUG-83496 Change-Id: Ida2393176c4c81da767023ff48159afdedfb0a19 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Handle automatic rpath embedding correctlyAlexandru Croitor2020-04-174-7/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using CMAKE_INSTALL_RPATH to embed an absolute path to prefix/libdir into all targets, use the more sophisticated aproach that qmake does. For certain targets (modules, plugins, tools) use relative rpaths. Otherwise embed absolute paths (examples, regular binaries). Installed tests currently have no rpaths. On certain platforms rpaths are not used (Windows, Android, iOS / uikit). Frameworks, app bundles and shallow bundles should also be handled correctly. Additional rpaths can be provided via QT_EXTRA_RPATHS variable (similar to the -R option that configure takes). Automatic embedding can be disabled either via QT_FEATURE_rpath=OFF or QT_DISABLE_RPATH=ON. Note that installed examples are not relocatable at the moment (due to always having an absolute path rpath), so this is a missing feature compared to qmake. This is due to missing information on where examples will be installed, so a relative rpath can not be computed. By default a Qt installation is relocatable, so there is no need to pass -DQT_EXTRA_RPATHS=. like Coin used to do with qmake e.g. -R . Relative rpaths will have the appropriate 'relative base' prefixed to them (e.g $ORIGIN on linux and @loader_path on darwin platforms). There is currently no support for other platforms that might have a different 'relative base' than the ones mentioned above. Any extra rpaths are saved to BuildInternalsExtra which are re-used when building other repositories. configurejson2cmake modified to include correct conditions for the rpath feature. It's very likely that we will need a new qt_add_internal_app() function for gui apps that are to be installed to prefix/bin. For example for Assistant from qttools. Currently such apps use qt_add_executable(). The distinction is necessary to make sure that relative rpaths are embedded into apps, but not executables (which tests are part of). Amends e835a6853b9c0fb7af32798ed8965de3adf0e15b Task-number: QTBUG-83497 Change-Id: I3510f63c0a59489741116cc8ec3ef6a0a7704f25 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix $ORIGIN rpaths to work when passed on the command lineAlexandru Croitor2020-04-151-6/+10
| | | | | | | | | | | | | | The CMAKE_INSTALL_RPATH cache var had the PATH type, which made CMake transform the value into an absolute path, getting rid of the $ORIGIN value. Fix that by changing the cache var type to STRING. Also clean up the all-caps commands, add a usage example and print the install RPATH. Change-Id: Ibf40cfde4283369ddfcf52609143799cc8e47d68 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Enable Moc for 3rdparty librariesLeander Beernaert2020-04-141-0/+2
| | | | | | | | This is required to support QtVirtualKeyboard's third party OpenWnn library. Change-Id: I64b6a2b6b6b0259bea5aa249a8c901def31f916c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Handle missing packages in project compile testsAlexandru Croitor2020-04-091-1/+19
| | | | | | | | | | | | | | | | | If a find_package() in a try_compile project doesn't find a package, and we then link against a non-existent target, the configuration failure of the compile test also fails the configuration of the project. To avoid that, separate library targets from non-targets, and make sure to only link against the targets if they exist. pro2cmake now outputs modified compile test project code which iterates over targets and non-target libraries, and links against them when needed. Change-Id: Ib0f4b5f07af13929c42d01a661df2cabdf9b926b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Handle finding of OpenSSL headers correctlyAlexandru Croitor2020-04-082-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Coin when provisioning for Android, we download and configure the OpenSSL package, but don't actually build it. This means that find_package(OpenSSL) can find the headers, but not the library, and thus the package is marked as not found. Previously the openssl_headers feature used the result of finding the OpenSSL package, which led to it being disabled in the above described Android case. Introduce 2 new find scripts FindWrapOpenSSL and FindWrapOpenSSLHeaders. FindWrapOpenSSLHeaders wraps FindOpenSSL, and checks if the headers were found, regardless of the OpenSSL_FOUND value, which can be used for implementing the openssl_headers feature. FindWrapOpenSSL uses FindWrapOpenSSLHeaders, and simply wraps the OpenSSL target if available. The find scripts also have to set CMAKE_FIND_ROOT_PATH for Android. Otherwise when someone passes in an OPENSSL_ROOT_DIR, its value will always be prepended to the Android sysroot, causing the package not to be found. Adjust the mapping in helper.py to use the targets created by these find scripts. This also replaces the openssl/nolink target. Adjust the projects and tests to use the new target names. Adjust the compile tests for dtls and oscp to use the WrapOpenSSLHeaders target, so that the features can be enabled even if the library is dlopen-ed (like on Android). Task-number: QTBUG-83371 Change-Id: I738600e5aafef47a57e1db070be40116ca8ab995 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Implement proper exclusion of tools including installingAlexandru Croitor2020-04-071-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous approach didn't work for prefix builds. While a target might be excluded from building via EXCLUDE_FROM_ALL property, when calling make install it would still try to install the target and thus fail. It's not possible to modify an install() command in a post-processing step, so we switch the semantics around. pro2cmake will now write a qt_exclude_tool_directories_from_default_target() call before adding subdirectories. This will set an internal variable with a list of the given subdirectories, which is checked by qt_add_executable. If the current source dir matches one of the given subdirectories, the EXCLUDE_FROM_ALL property is set both for the target and the qt_install() command. This should fix the failing Android prefix builds of qttools. Amends 622894f96e93d62147a28a6f37b7ee6a90d74042 Change-Id: Ia19323a2ef72a3fb9cb752ad2d4f2742269d11c4 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Simplify semicolon escaping in qt_config_compile_testAlexandru Croitor2020-04-071-12/+7
| | | | | | | | | | list(JOIN) removes a layer of escaping, which force doubling up on the backslashes. Instead use string(REPLACE) thus making the escaping a bit saner. Change-Id: Ie3daf0112dd09fbcbaf8798552949470952611c9 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Autodetect Objective-C support only on macOSAlexandru Croitor2020-04-071-1/+6
| | | | | | | | | | | | On Android, check_language() reports that the languages are supported, but enable_language fails afterwards. On Linux it causes issues with the PCH. The PCH file might contain a Clang pragma, even though the C++ compiler is GCC. Presumably due to finding a Clang Objective-C compiler. Change-Id: I1b4c54459772c089e7f6350872c87af52ad72a37 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Remove special handling of the 'static/shared' featuresJoerg Bornemann2020-04-061-11/+0
| | | | | | | | configurejson2cmake handles the 'static' and 'shared' features now. There's no need to special-case it anymore. Change-Id: I956e9f46ebe022b1da862e986ec05f41e1e804e0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Remove special handling of the 'rpath' featureJoerg Bornemann2020-04-061-7/+0
| | | | | | | | configurejson2cmake handles the 'rpath' feature now. There's no need to special-case it anymore. Change-Id: I9aa9c9acdeb586de09d8a8d269909f8acb02e40a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix build with WARNINGS_ARE_ERRORS=ON and gcc 9.3.0Joerg Bornemann2020-04-061-0/+2
| | | | | | | | | Add -Wno-error=format-overflow. This is similar to what is done in qt_common.prf, however we don't turn the warning off completely. For now at least. Change-Id: I93c20064759dea43309c3a17de4d733ede9ca2cb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Adjust PCH support for multi-arch iOS buildsAlexandru Croitor2020-04-033-6/+27
| | | | | | | | | | | | | | | | | | Starting with CMake 3.18, there is PCH support for darwin multi-arch builds, like iOS simulator_and_device builds. Also enable PCH for Objective-C++ files when the support is there. To enable PCH for Objective-C++, we need to do enable the OBJCXX language as well, but conditionally, because on non-darwin platforms the language is probably not available. Introduce the qt_enable_cmake_languages() macro which is called automatically by qt_build_repo_begin(). Change-Id: I0e7f44be6577ac54ce940470036626409920e272 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Handle standalone config.tests in configure libraries sectionAlexandru Croitor2020-04-031-2/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some library entries in configure.json have a test entry. An example is assimp in qtquick3d. qmake tries to find the library via the sources section, and then tries to compile the test found in config.tests/assimp/assimp.pro while automagically passing it the include and link flags it found for assimp. We didn't handle that in CMake, and now we kind of do. configurejson2cmake will now create a corresponding qt_config_compile_test call where it will pass a list of packages and libraries to find and link against. pro2cmake will in turn generate new code for the standalone config.test project. This code will iterate over packages that need to be found (like WrapAssimp) and then link against a list of passed-in targets. In this way the config.test/assimp/main.cpp file can successfully use assimp code (due to propagated include headers). qt_config_compile_test is augmented to take a new PACKAGES argument, with an example as follows PACKAGES PACKAGE Foo 6 COMPONENTS Bar PACKAGE Baz REQUIRED The arguments will be parsed and passed to the try_compile project, to call find_package() on them. We also need to pass the C/C++ standard values to the try_compile project, as well as other try_compile specific flags, like the toolchain, as given by qt_get_platform_try_compile_vars(). Change-Id: I4a3f76c75309c70c78e580b80114b33870b2cf79 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* qt_record_extra_package_dependency: check that target existsSamuli Piippo2020-04-031-7/+9
| | | | | | | | The target may not be defined which causes error: get_target_property() called with non-existent target "qtwaylandscanner". Change-Id: I58a9122456ccbbbb8fc9f0adce3b7ddcc985e6a4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Remove HEADER_MODULE handling from 3rd party libsAlexandru Croitor2020-04-021-15/+13
| | | | | | | | | | | | Installing headers is not supported for 3rd party libs (we don't run syncqt, we don't install headers for 3rd party libs to prefix/include). Remove the unnecessary condition. Change-Id: I46e9af7a7ca9de0138666b0d0faffc86238672ba Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Don't try to add 3rd party includes to ModuleDepends filesAlexandru Croitor2020-04-021-0/+1
| | | | | | | | | | | | | | | | | | | When creating the include/QtShaderTools/QtShaderToolsDepends file in QtPostProcess.cmake -> qt_internal_write_depends_file(), we decide which include files to append based on link dependencies starting with Qt::, which happens to match 3rd party targets like Qt::BundledSpirv_Cross which doesn't expose headers in the prefix/include dir. Mark all bundled targets with the QT_MODULE_SKIP_DEPENDS_INCLUDE property to exclude them from being added to Depends files. This should fix static builds of qtquick3d which includes <QtShaderTools/QtShaderToolsDepend> which tries to include a non-existent <QtBundledSpirv_Cross/QtBundledSpirv_Cross>. Change-Id: I9dcff1e2ab721a7c21fcff3fda0faf8d023d60ba Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake: Don't use escaped plugin type for on-disk directoriesAlexandru Croitor2020-04-021-5/+5
| | | | | | | | | | | | | | | | | | | The path where we install plugins is usually prefix/plugins/plugin_type/plugin_name The plugin_type should not be escaped, so it should be used verbatim (no escaping of slashes or dashes).. So far it seems the only weird plugin types are wayland plugins which contain dashes, like wayland-shell-integration, and the sub-ios plugin which has a slash (platforms/darwin). For cmake properties we use the escaped names. This should fix tests in wayland where the wayland plugins can't be found. Change-Id: I93406731b8c872a82c0f247f5b7c6bdab4875455 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Allow excluding tools and apps from the default 'all' targetAlexandru Croitor2020-04-022-0/+29
| | | | | | | | | | | | | | | | | | | | | | | Qt uses the qtNomakeTools() function to mark a directory which will not be built as part of the default target. This is especially important when cross-compiling (to iOS for example) because the build process might fail. The condition for not building these "GUI tool sub-directory projects" is the absence of the "tools" value in qmake's QT_BUILD_PARTS variable. Introduce a QT_NO_MAKE_TOOLS CMake variable. If the value is true, it's equivalent to "tools" not being present in QT_BUILD_PARTS. Introduce qt_exclude_tool_directories_from_default_target(). It's the qmake counter part to qtNomakeTools(). Teach pro2cmake to generate it where appropriate. Change-Id: If2e5958d91847ab139af0e452608510286e73fa0 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Report which qt parts will be built by defaultAlexandru Croitor2020-04-021-0/+25
| | | | | | | | | Like libs, tools, examples, tests. Built by default means they are part of the default make / ninja target. Change-Id: I304e5724fc5dbd39626e9d589a6e1e92a4dd7882 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Don't generate docs for targets that don't existAlexandru Croitor2020-04-021-0/+6
| | | | | | | | | | Such a case can happen when cross-compiling. Tools currently are not built when cross-compiling, so if the desktop tool was not built, accessing properties on that target would fail when trying to set up the documentation building. Change-Id: I2ffcbb9623df3e4daacdf4be3f48c4b2dd13851b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix usage of CMAKE_CROSSCOMPILINGAlexandru Croitor2020-04-021-1/+1
| | | | | Change-Id: I9557f44c4d99c8591d41512e9705791d77eb0eb3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Define QT_STATIC for static buildsJoerg Bornemann2020-04-011-4/+12
| | | | | | | | | | QT_STATIC must be defined for static builds to have the right import/export symbol macros defined. Originally, this macro is wrapped in a condition. That's why we extend qt_feature_definition to be able to write a prerequisite to qconfig.h. Change-Id: I610e60acc7f5bdc031eff6d53a76e0b229a5c8c2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix qt_lib_XXX.pri files for modules with CONFIG_MODULE_NAME setJoerg Bornemann2020-03-301-30/+31
| | | | | | | | | | | | The function qt_generate_module_pri_file did not take into account the CONFIG_MODULE_NAME argument of qt_add_module. This resulted in wrong file names and content, e.g. qt_lib_test.pri instead of qt_lib_testlib.pri. Fixes: QTBUG-83176 Change-Id: Id6991396cf9ea5a1d155aa15402c0d84a8a9d082 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
* CMake: Fix pkgconfig calls when cross-compilingLeander Beernaert2020-03-261-0/+10
| | | | | | | | | | | | | | When cross-compiling with CMake, before this patch pkgconfig calls would find libraries which are part of the host system and not the target system. The current approach used is based of the discussion present in https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4478, and should be considered a temporary solution until the issue is properly addressed in upstream CMake. Change-Id: I535d4d48c2a5d34689082b80501b3b6ae30d7845 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix the re-computed value of INSTALL_*DIR variablesJoerg Bornemann2020-03-251-1/+4
| | | | | | | | | | | | | | | For INSTALL_*DIR variables that have the the same value as CMAKE_INSTALL_PREFIX, a second cmake run cleared the value. This is because file(RELATIVE_PATH) returns the empty string if we pass the same absolute paths. Fix this by checking the return value of file(RELATIVE_PATH) for the empty string and setting it to ".". It's a limitation of qmake that empty strings are not handled as ".". Change-Id: I8fc4d1eabcc9d5634be2f3741b0002a347dd17e6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix auto-detection of precompiled header supportAlexandru Croitor2020-03-252-0/+21
| | | | | | | | | | | | PCH files were only used while building qtbase. Make sure the value is exported to the BuildInternalsConfig file, so the value is re-used when building other repositories. Also disable PCH when building simulator_and_device iOS builds, because CMake doesn't currently generate separate PCH files per architecture. Change-Id: I79955ebc557b800bc3c704deac519fe80012c229 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Make sure to install Qt3rdPartyLibraryConfig.cmake.inAlexandru Croitor2020-03-231-0/+1
| | | | | | | | | | Repos like qtshadertools need it when configuring their own bundled libraries. Amends 572c03eb7a583baf1f48e5144d2868e5588d292a Change-Id: I540e99d5bd2938299a10220a1a5e0d97091077b3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Fix creation of forwarding headers to be at configure timeAlexandru Croitor2020-03-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | qt_add_module checks for the existence of the following directory include/QtFoo/6.0.0/Foo when deciding whether a private module target should contain that path in its INTERFACE_INCLUDE_DIRECTORIES. There are 2 cases when it's created, when running syncqt, and inside qt_install_injections. If syncqt doesn't create it because there are no private headers (like in qttools/src/global), qt_install_injections created it at generation time (for injected configure headers like qttools-config_p.h) Unfortunately that caused the existence check mentioned above to fail, not exporting the path in the QtToolsPrivate's include directories, and failing the qttools build. To fix that, create the injection files (and directories) at configure time, using qt_configure_file instead of file(GENERATE). Change-Id: Idd9b6ec36e986c4de95d11557170e1c70927211c Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Introduce qt_configure_fileAlexandru Croitor2020-03-233-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It has the same kind of signature as file(GENERATE) but creates the files at configure time rather than generation time. CMake provides a few ways to generate files file(WRITE) -> always overrides content configure_file() -> only overrides if content changes, creates file at configure time, can only take a file as input file(GENERATE) -> only overrides if content changes, creats file at generation time, can take a string or file as input Because dealing with an input file is a hassle (need to create one, make sure it's installed, make sure it's used correctly in the various build types like super-build, non-prefix-build, etc) people tend to use file(GENERATE) instead, which can take a string argument, and is thus easier to use. Unfortunately that introduces subtle bugs because the file is created at generation time, but there are existence checks which are done at configuration time. Thus qt_configure_file allows creation of files at configure time, without having to provide an input file. Underneath it uses configure_file(). Once CMake 3.18 is released, the implementation can be switched to use file(CONFIGURE). Change-Id: Ic8f8d88541ef0b25d01af143352c8c9ba390ad5f Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake: Provide script to configure and build one or more testsAlexandru Croitor2020-03-233-26/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch there were a few ways to build tests - Configure all tests as part of the repo build - Configure all tests as part of the repo build, but don't build tests by default (-DQT_NO_MAKE_TESTS=ON) - Configure all tests as a standalone project in a separate build dir using -QT_BUILD_STANDALONE_TESTS=ON All of the above incur some time overhead due to the necessity of configuring all tests. Sometimes you just want to build ONE test (or a few). To facilitate that use case, a new shell script called bin/qt-cmake-standalone-test(.bat) can now be used to configure and build one or more tests. The script takes one single argument pointing to the desired test project path and configures a generic template project that sets up all the necessary Qt CMake private API, afterwards calling add_subdirectory on the passed in project. Example $ path/to/qt/bin/qt-cmake-standalone-test ./tests/auto/gui/image/qicon or $ path/to/qt/bin/qt-cmake-standalone-test ./tests/auto/gui/image After that, simply run 'ninja && ctest' to build and run the test(s). This is the CMake equivalent of calling qmake on a test .pro file (or on a tests SUBDIRS .pro file) There are 3 details worth mentioning. Due to the add_subdirectory call, the built artifacts will not be in the top-level build dir, but rather in a nested build_dir. The script currently can't handle more than one argument (the path to the project), so you can't pass additional -DFoo=bar arguments. If a test uses a 3rd party library (like Threads::Threads) which was not a public dependency for any of the Qt modules, configuration will fail saying that the target was not found. Perhaps we should consider recording these packages when generating the StandaloneConfig.cmake files. Change-Id: Icde6ecb839341d34f341d9a19402c91196ed5aa0 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Add global / top-level docs targetsAlexandru Croitor2020-03-182-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously you could use either module-specific or repo-specific 'docs' targets. For example 'ninja html_docs_qtbase' or 'ninja html_docs_Core'. Now there's a global / top-level target called 'docs', so 'ninja docs' works. For super builds it will build the documentation of all configured repositories. For a single repo build, it's equivalent to calling 'ninja docs_repo_name'. Also for consistency, add the "docs_Core" target, which was missing before. So now a 'docs' target exsits for repo names AND targets. New global target names are - docs - prepare_docs - generate_docs - html_docs - qch_docs - install_html_docs_docs - install_qch_docs_docs - install_docs_docs Amends 0095ff4e0659906595d281b37c3b7f89e37250af Change-Id: I686be1e0962e40cbce860e8ac2cabb056b360ac2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* cmake: Remove APPLE prefix from platform namesTor Arne Vestbø2020-03-168-19/+19
| | | | | | | None of the other platforms have it. Change-Id: Ib448c2c03ba03f711b507ef391977c0e6aa7c192 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* cmake: Fix naming when referring to Apple macOSTor Arne Vestbø2020-03-164-4/+4
| | | | | Change-Id: Iafb5e448d0d65d42f788464fc600594a5666f9af Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix Windows VM Test RunsLeander Beernaert2020-03-161-26/+8
| | | | | | | | | | | | | | | | | | | | Simplify the handling of simd specific sources. The previous implementation was causing simd instructions to bleed into the main library. The tests were failing because the avx instruction were leaking into Qt6Gui due to the previous problem. This in turn caused any test which required Qt6Gui code run to crash since it is not possible to run avx instruction in the VMs. This patch also disables PCH for the simd sources as they result in warnings related related to using PCH header not compiled for the architecture in question. The latter can cause the build to fail in conjunction with warnings as errors. Change-Id: I1be98f2f5e967f33793d6a2e6134a24ef1709566 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
* CMake: Don't make a private module depend 1kk times on the public oneAlexandru Croitor2020-03-131-1/+2
| | | | | | | | | The exported INTERFACE_LINK_LIBRARIES property now looks a lot more sane. Change-Id: I093fcb242607023dd0b103298562b299cb803028 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* cmake: Add default Info.plist for macOS with some important keysTor Arne Vestbø2020-03-133-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | The default Info.plist shipped with CMake lacks an NSPrincipalClass entry, which is crucial for making macOS apps run in full resolution on retina screens. We make sure the file is only picked up on macOS, not iOS and friends, since those platforms require another principal class. If needed we can extract the value out as a CMake variable and use the same file for all Apple platforms. Doing so would assume all keys are single-platform only, so if that's not the case we need platform-specific files. We should probably extract the package type out as a variable too, so that the file can be used for both apps, plugins, and frameworks, but doing so requires setting up that variable somewhere based on the target type, which CMake doesn't allow in an easy way. The file itself is based on the file CMake ships, combined with keys inherited from Qt's existing plist templates for qmake, and adjusted to match what Xcode generates by default these days. Change-Id: I3f5109e5fff63cdbd109a99d4008948d4bd2102b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* cmake: Disable GL deprecations on Apple platformsTor Arne Vestbø2020-03-121-0/+6
| | | | | Change-Id: I87b98ae68d996868cefaaf578722ac24be745145 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix incorrect argument in QtBuildInternalsAndroidAlexandru Croitor2020-03-121-2/+2
| | | | | | | | Uncovered while building qtdeclarative. Change-Id: If1a36f2640a3a5d765e7ca74b0ba1d39ef2a18f0 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>