Commit Graph

381 Commits

Author SHA1 Message Date
Christophe Giboudeaux
7f6eb6ead6 Don't hardcode the binary directory name
INSTALL_BINDIR may point to a different location than "bin". In order
to avoid errors when trying to install qtbase, "bin" is replaced with
"INSTALL_BINDIR" where necessary.

Contributes to QTBUG-81289

Change-Id: I1d4f9fb2617547c9b0e44d6690caebb2b6768e2f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-31 10:09:47 +00:00
Christophe Giboudeaux
5fc2882ac5 Add INSTALL_MKSPECSDIR to the install locations
Linux distributions may want to install mkspecs files into a
different subdir in order to make Qt6 co-installable with
older versions.

Contributes to QTBUG-81289

Change-Id: Ie4a64370d742948d5ca4f2eaed6ea550d2676707
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-31 10:09:39 +00:00
Leander Beernaert
67ea445f09 Append to AUTO_MOC_OPTIONS in order not override existing value
Change-Id: Id1bf607e31ee2baa5ffb6d6b4aedd98ea83e5e15
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-29 15:55:49 +00:00
Leander Beernaert
f47efdac1d Only add --automoc-json to AUTOMOC_OPTIONS for metatypes targets
Change-Id: I7c2e859a83ea78c2a6cf2ad59c175c1b29a74621
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-29 15:36:55 +00:00
Leander Beernaert
a6ccef651d Generate metatypes dependency file
Due to generator expression it is impossible to recursively evaluate the
link dependencies of a target. This is required by QtDeclarative's
qmltyperegistrar.

To overcome this we generate a ${target}_metatypes_dep.txt file which
contain lines with the following pattern:
${PATH_TO_METATYPES.json}=${PATH_TO_METATYPES_DEP.txt}

This can be used to recursively evaluate the dependencies at run time.

Change-Id: Ia4cee0632c16ba9631e0289db906fe9d320844a3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2020-01-29 14:20:54 +00:00
Alexandru Croitor
fd590b9482 Don't create convenience plugin target when not needed
If the OUTPUT_NAME of a plugin is the same as the CMake target name,
don't try to create a custom target with the same name. That will
cause configuration errors due to duplicate targets.

Amends f67d8ae2d4

Change-Id: Iaea7c68e22dbc1e345ba10950c312618abba4c21
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-27 14:21:58 +00:00
Alexandru Croitor
f67d8ae2d4 Fix plugin target names to be compatible with Qt 5
In Qt 5, qmake generates CMake Config files which expose the plugins
as imported libraries. The name of these libraries are derived from
the plugin class name. So QCocoaIntegrationPlugin, and not qcocoa.

To keep compatibility between Qt5 and Qt6 CMake target names,
the pro2cmake script should generate plugin target names based on the
plugin class names.
To avoid passing the same name in qt_add_plugin (target and CLASS_NAME),
derive the class name from the target if the class name is
not explicitly specified.

Also add a new OUTPUT_NAME parameter which is used to change the
final file name of the plugin, so that it's compatible with Qt5.
For example to generate a qcocoa.dylib file, instead of
QCocoaIntegrationPlugin.dylib file.

The same OUTPUT_NAME value will be used for generation of plugin .prl
files for qmake consumption.

Change-Id: I4d53e680d7beb62befecd359cdf6bba60a34ff0d
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-27 11:49:11 +00:00
Alexandru Croitor
c9bea1ad62 Add initial support for CMake "Ninja Multi-Config" generator
This allows doing debug_and_release builds with Ninja on all
platforms.
The "Ninja Multi-Config generator" is available starting with CMake
3.17.

Desired configurations can be set via CMAKE_CONFIGURATION_TYPES.
Possible values: "Release, Debug, RelWithDebInfo, MinRelSize".
For example -DCMAKE_CONFIGURATION_TYPES="Release;Debug".

The first configuration is the 'default' configuration which is
built when calling ninja with no arguments.

To build all targets of a certain configuration use "ninja all:Release"
or "ninja all:Debug".

To build all targets in all configurations use "ninja all:all".

Note that the first configuration influences which configuration of
tools will be used when building the libraries for all configurations.
In simple terms, when configured with
-DCMAKE_CONFIGURATION_TYPES="Release;Debug" the release version of moc
is used by AUTOMOC.
When configured with -DCMAKE_CONFIGURATION_TYPES="Debug;Release"
the debug version of moc is used by AUTOMOC.

Framework builds and Ninja Multi-Config don't currently work together
due to multiple bugs in CMake, which ends up generating an invalid ninja
file with duplicate rules. There are also issues with placement of the
debug artifacts.

This will be handled in a follow up patch after CMake is fixed.

Task-number: QTBUG-76899
Change-Id: If224adc0b71b7d1d6606738101536146aa866cd7
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-27 11:47:57 +00:00
Leander Beernaert
cce8ada814 Support for QML Type Registrar
Change-Id: Ifc1f44cf40b22c20ab768333ba9d5ce58a5f7250
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-24 12:29:30 +00:00
Alexandru Croitor
d1be8b9ceb Fix dependencies for SIMD object libraries in macOS framework builds
This manifested in Coin when ninja tried to build qdrawhelper_sse2.cpp
before the Core framework headers were copied, resulting in a
fatal error: 'qatomic.h' file not found.

Make sure every SIMD object library has all PRIVATE dependencies of
its parent library PRIVATE dependencies (except for other SIMD object
libraries), to make sure that the framework headers are copied by the
time the SIMD source file is compiled.

Here's an example for clarification. Gui_simd_sse2's LINK_LIBRARIES
property should have all the values of Gui's LINK_LIBRARIES property
(like Qt::Core) filtering out all SIMD object library targets (
like Gui_simd_sse2, Gui_simd_sse3, etc).
Thus we make sure the SIMD object libraries are built after Gui's
dependencies are built.

Note that using INTERFACE_LINK_LIBRARIES to avoid the filtering of SIMD
targets in the generator expression would only work in shared Qt builds.
In static Qt builds where PRIVATE dependencies become PUBLIC, CMake would
insert $<LINK_ONLY:Gui_simd_foo> entries in INTERFACE_LINK_LIBRARIES
which causes CMake to be confused and fail at generation time.

Change-Id: I246c1394b9c9830c0ebd11e6621e56b992a6a1f2
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-22 12:36:06 +00:00
Leander Beernaert
3854b5892b Add QT_TEST_RUNNING_IN_CTEST environment variable for test
When running tests with CMake's CTest, set the environment
QT_TEST_RUNNING_IN_CTEST to 1. This can be useful to deal with tests
that do not properly work when running from CTest.

For instance, the qmake test in this patch has one test that only works
when not run from CTest.

Change-Id: I01eea9131de69c18118a9ed9f96e9296d5ea20f1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-14 13:24:55 +00:00
Leander Beernaert
1f2cdd8a04 Add support for test timeouts
Change-Id: Iba805cbc16d179e5b080ccc00542329270075aa1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-13 12:28:24 +00:00
Jean-Michaël Celerier
ea81b69cde Implement qtbase fixes for superbuilds
Change-Id: I0d3445cf0740e3925fa9342dac4d07892518afe5
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-08 10:42:21 +00:00
Leander Beernaert
a182efb9c4 Fix is_framework check for interface libraries
Change-Id: I59832e698eceb98a2a03f4a3e2de88b1d18fda6e
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-06 15:05:44 +00:00
Joerg Bornemann
4b2de41b13 CMake: Add support for framework builds
Framework builds are enabled by default on macOS.
They are controlled via the framework feature.

Task-number: QTBUG-75751
Change-Id: I00bc64672f02bbd1672508b2b5010d202984a961
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CMake Build Bot
2020-01-06 11:53:53 +00:00
Leander Beernaert
0095ff4e06 Add custom targets for documentation
Adds custom targets which take care of generating and installing
documentation files.

Every module has a global set of targets suffixed with the module
name in order for them to be unique when we implement super builds.
The targets are the same as the list below, but replace ${target}
with the module's name. Eg.: docs_qtbase.

For every target which has an qt_add_docs() call, we now create the
following set of custom targets:

* docs_${target}
* html_docs_${target}
* qch_docs_${target}
* prepare_docs_${target}
* generate_docs_${target}
* install_docs_${target}
* install_html_docs_${target}
* install_qch_docs_${target}

Fixes: QTBUG-75859
Change-Id: Ie84cb9a2dedbe7333d9a84f4d73383442deca477
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-18 14:27:01 +00:00
Leander Beernaert
ed6e6c3787 Expose Patch Version in QtConfig.cmake
Change-Id: I2166d480c0b717fc9137f8eb42d5aab7a091395d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-11 15:46:08 +00:00
Leander Beernaert
6c20ae774c Add option to specify working directory for qt_add_test
Change-Id: Iba5104cccdc613f7b2cf0d1454209578adaac824
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-12-10 13:24:10 +00:00
Alexandru Croitor
04d895681a CMake: Fix creation of versionless targets for tools
We can't use qt_internal_export_modern_cmake_config_targets_file for
executables like tools, because it's not possible to use
INTERFACE_LINK_LIBRARIES with executables like you can with libraries.
We also can't create aliases to non-global imported targets.

Instead create new imported executable targets, fish out the imported
location, and assign it to the versionless targets.

Task-number: QTBUG-74137
Task-number: QTBUG-80477
Task-number: QTBUG-75984
Change-Id: I6a3c9c67ef4699c72a6c9a627c63158dfd6557f8
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-06 11:11:16 +00:00
Leander Beernaert
05ba991d39 Fix meta types json file install for non-prefix builds
Change-Id: I76fd379dacb7db79d4ed6ca47954ae8e703842d4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-05 15:09:50 +00:00
Alexandru Croitor
f4e80ea688 Clear QT_KNOWN_MODULE_${module}_TOOLS cache vars on reconfiguration
Otherwise if you configured a commit that has tool A, and the switch
to a commit where tool A does not exist anymore, reconfiguration
will fail.

Change-Id: Ibb244b9630a6f4fecd27d51ce28eceff07ba8666
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-05 14:52:42 +00:00
Leander Beernaert
0f220d473a Collect Json Metatypes from CMake's Automoc
This patch adds a new bootstrap tool which will read CMake's
AutoGenInfo.json and ParseCache.txt to determine what the current
list of json files is that needs to be passed to moc --collect-json
option.

Right now this is enabled for qt_add_module() with the option
GENERATE_METATYPES. pro2cmake has also been updated to detect qmake's
CONFIG += metatypes and to generate the above option for modules.

The implementation lives in Qt6CoreMacros so it can eventually be used
in the public facing apis.

The generated meta types file is saved under the target property
QT_MODULE_META_TYPES_FILE.

Change-Id: I03709c662be81dd0912d0068c23ee2507bfe4383
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-04 10:48:06 +00:00
Alexandru Croitor
9eea24ed60 Don't export private include paths if there are no private includes
Needed when building Qt Creator with CMake + Qt6 non-prefix build.
Specifically qttools's QtUiPlugin does not have any private headers,
but the non-existing include path was exported, which caused an error
when configuring Qt Creator.

Change-Id: I662bc502fe3134fba083bde273b7f63fe1470277
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-03 17:14:14 +00:00
Alexandru Croitor
55a15a1c1b Add initial support for cross-building to iOS
Tested locally with the following configurations:
- iOS device builds (arm64)
- iOS simulator builds (x86_64)
- iOS simulator_and_device builds (fat arm64 and x86_64 archives)

All iOS builds currently require a custom vcpkg fork which contains
fixes for building the required 3rd party libraries.

qtsvg, qtdeclarative, qtgraphicaleffects and qtquickcontrols2
have also been tested to build successfully.

simulator_and_device builds are also supported, but require an umerged
patch in upstream CMake as well as further patches to vcpkg.

Task-number: QTBUG-75576
Change-Id: Icd29913fbbd52a60e07ea5253fd9c7af7f8ce44c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-12-03 13:35:59 +00:00
Alexandru Croitor
9061f29872 Provide a way to specify extra tool package dependencies
In the qtwayland repo, both WaylandClient and WaylandCompositor
packages need access to the qtwaylandscanner tool. That means
that the add_qt_tool(qtwaylandscanner) can't use the TOOLS_TARGET
argument to associate a dependency with only one of the above
modules.

Instead add_qt_tool now allows specifying a non-existent module
name for the TOOLS_TARGET argument, which can be manually
depended on by other packages.
Actually, you could specify the non-existent module before as
well, but that didn't do everything that had to be done.

This required a bit of refactoring in how the Dependencies file
for Tools packages is created. Now the file is created in
qt_export_tools.

Two new functions were also added to allow recording additional
dependencies between packages.

Also some bug fixes were done to make it all work. Specifically
the _FOUND variable generated in the Dependencies file was incorrect.
Also there are some quotes missing when appending extra package
dependencies via the QT_EXTRA_PACKAGE_DEPENDENCIES property.

Change-Id: I167efec16dff8d036e191df3572ea72764e22bc5
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-26 10:58:56 +00:00
Cristian Adam
974536c4aa CMake: Do feature testing for linker flags
Instead of hardcoding which platforms and which compilers support
certain linker features, do the proper probing via
check_cxx_source_compiles.

Change-Id: I676010970d8f3a8f2a8340c5d15dfcef76fe9191
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-22 17:08:02 +00:00
Cristian Adam
f4efaf54d5 CMake: Add support for building with Clang-MinGW toolchain
Clang doesn't have a mkspec just a win32-clang, there is
win32-clang-g++ and win32-clang-msvc.

Change-Id: Iff521e955559dfb2308e377b41e86b3f62c42e70
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-22 17:06:18 +00:00
Alexandru Croitor
1fd21c47d0 Fix warnings when a module's plugin type has underscores
In qtwayland, there were a bunch of warnings of the following type
when configuring:

"The plug-in 'f' does not belong to any Qt module".

This happened because the plugin type had underscores, and was not
sanitized when comparing a the plugin type of plugin.

Add a function to do the sanitization, and use it everywhere.

Change-Id: I728b5f1e18fa5f8876c4a57dbd4e33148cb242d5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-15 18:02:12 +00:00
Alexandru Croitor
dfc583005b Fix add_cmake_library to use a correct plugin suffix on macOS
Qt plugins on macOS use .dylib, whereas CMake created used
".so" instead.

Change-Id: I3ea73a52a0675a0cfce4997ca413df79e63cfaa7
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-15 12:25:22 +00:00
Alexandru Croitor
38354d7d61 Rename / prefix all our private API functions with qt_
Rename internal APIs like extend_target to qt_extend_target.
Prefix apis with qt_ where required.

Keep old names for compatibility until all their usages are removed.

Change-Id: I9a13515a01857257a4c5be3a89253749d46a4f41
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-14 09:05:33 +00:00
Alexandru Croitor
9e6456a49d Fix not to add warnings_are_errors property to INTERFACE targets
Amends f000685612

Change-Id: I3b61b64bb9c755de38f4a5ffcb07b39b38bd4fd7
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-13 16:17:23 +00:00
Alexandru Croitor
edcf5d0144 Fix qt_skip_warnings_are_errors_when_repo_unclean for executables
Amends f000685612

Change-Id: I48d7a42e11e609fa3a387b7669ee96bd10c856e4
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-13 09:59:56 +00:00
Alexandru Croitor
f000685612 Add support for skipping warnings are errors
Unfortunately not all repositories are marked as warning_clean
in their .qmake.conf files. For instance qtconnectivity and
qttools are not warning clean. Therefore we need to skip
warnings_are_errors flags on all targets created in that repository.

Add support for skipping the warnings are errors flags, by setting
a QT_SKIP_WARNINGS_ARE_ERRORS property on a target, and use that
within a generator expression with all the accumulated flags.

To mimic behavior of qmake, and set the property on all targets
created by add_qt_module, add_qt_plugin, etc, one simply needs
to set the QT_REPO_NOT_WARNINGS_CLEAN variable in the
repo project CMakeLists.txt.

Change-Id: Ib5a487af6601ae1519a0988a89f8083f94f92267
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-12 17:30:35 +00:00
Leander Beernaert
681e8b4ead Add add_qt_manual_test()
This patch adds add_qt_manual_test() which is a simple wrapper around
add_qt_executable() which does not build under ${CMAKE_BUILD_DIR}/bin
or install the targets.

This could potentially be used later to tag manual tests.

Change-Id: Ic4e0a1d133009f5a858b9394347a0996cf42683f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-12 14:46:44 +00:00
Simon Hausmann
1b41a62893 Fix armv7 embedded Linux build
In gui's CMakeLists.txt we have

    if (NOT ANDROID)
        ...
        add_qt_simd_part(Gui SIMD neon SOURCES ...)
        ...
    endif()

and later

    if(UNIX AND NOT ANDROID AND NOT APPLE_UIKIT AND NOT INTEGRITY AND NOT (TEST_architecture_arch STREQUAL "arm64"))
        add_qt_simd_part(Gui SIMD neon
    endif()

Since add_qt_simd_part internally uses an OBJECT library to compile the
sources with different flags and then link into Gui (in this case), we
may end up with an error when add_qt_simd_part is called twice for neon,
because the constructed target (Gui_simd_neon) exists already.

We can re-use an existing target though, as the SIMD features is the
same.

Change-Id: I7a21c6e66b47e918a53fa3b1a7db9e053ecc8d87
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-11 13:04:12 +00:00
Alexandru Croitor
c51fe841f4 Fix handling of _nolink targets for the QtNetwork module
When a _nolink target is exported, instead of getting the original
namespace prefix, it gets the Qt6 prefix
(OpenSSL::OpenSSL_nolink -> Qt6::OpenSSL_nolink).

There is some special case code in Network autotests which tries
to access the former target name, which doesn't exist when building
standalone tests.

Make sure to create a Qt6:: library alias for _nolink targets during a
build (so before the library is exported), and change the Network
autotests project to use this Qt6:: namespaced library, which will
ensure it is found both in a standalone tests build and in a regular
Qt build.

Also make sure to actually call find_package to find the OpenSSL
library when building standalone tests, otherwise configuration will
fail.

Change-Id: I3da5b958e72e745a50380f8ab1644459a7c6b005
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-08 15:09:54 +00:00
Alexandru Croitor
3cfaa19c60 Fix interface library issues on Android
Don't call qt_android_dependencies for interface libraries.
Also make sure not to set properties which don't start with
INTERFACE_ prefix.

Change-Id: I0afdffd34c9aebe0d7ac4731b57dd4d505f84570
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-08 15:09:41 +00:00
Alexandru Croitor
8294d85d80 Don't add linker scripts to interface libraries
It only makes sense for non-interface libraries.

Change-Id: I80ac942ed546a6ac866e827aa2026e4e6ac897b2
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-08 15:09:31 +00:00
Leander Beernaert
cd9813d276 Add support for benchmark conversion
Convert benchmark executables to add_qt_benchmark().

Currently add_qt_benchmark just calls add_qt_executable() and
ensures that it they build under CMAKE_CURRENT_BUILD_DIR and do not
install.

Add QT_BUILD_BENCHMARKS option to enable/disable building of benchmarks.

Change-Id: Id0bc676698d21d50048d97d9abef51d92ccb6638
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-04 15:48:30 +00:00
Frederik Gladhorn
92fdc6b2ea cmake: Fix setting QT_DISABLE_DEPRECATED_BEFORE
The last set would override the variable instead of appending to it,
thus QT_DISABLE_DEPRECATED_BEFORE was never set.

Change-Id: I173b91704a855fcda1f2b86172d318e3953466db
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-31 13:48:09 +00:00
Leander Beernaert
69fb4ae343 Distinguish between qt_plugin and regular plugins
If we do not encounter the load(qt_plugin) statement in the .pro file
but we do see the entry CONFIG+=plugin, treat the target as a regular
CMake library instead of treating it as a qt_plugin by default.

Change-Id: I67ad5c865a1a5ab691a6b0d86c2db4b686aa04dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-28 09:20:37 +00:00
Leander Beernaert
080f9ad160 Enable running test on Android
This patch converts all add_executable calls when building for Android
to a module library and replaces the call to add_test() to use
the android testrunner binary.

Change-Id: I10ba5919217cdc93cc2cbbb7d13ad9d10fc5ac1a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-28 09:18:28 +00:00
Alexandru Croitor
d183c21a2c Fix declarative tests
e1fd607493 in qtbase removed the
qml1 imports enum from qlibraryinfo.cpp, qconfig.cpp, etc.

With the recent merge from dev, this was not adjusted in
qt_generate_qconfig_cpp, and thus we generated one too many strings
in qconfig.cpp, which resulted in
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) returning
"imports" instead of "qml" subfolder, thus causing all qml modules
not being found.

Fix this by removing the extra qconfig.cpp entry, and all other
references to the location.

Change-Id: I128f667281138e2e0ef0fe1ced4af0405c532fef
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-25 16:21:06 +00:00
Leander Beernaert
790d380f8b Add custom targets to generate Android APK
This patch adds two custom targets to generate android apks. The
targets are named ${TARGET}_prepare_apk_dir and ${TARGET}_make_apk. The
first one insures the binary is copied to the right location and the
latter invokes androiddeployqt on the apk directory.

Change-Id: I8152cef387b50ec03ee2bfd92b56910a6f22754c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-23 09:08:10 +00:00
Tobias Hunger
edf61092f2 QtBuild: Use STRING type for install locations
Use STRING type for install locations as we use them relative to the
CMAKE_INSTALL_PREFIX.

PATH type will get expanded to absolute paths by newer CMake versions,
so that breaks our logic.

Change-Id: I36be1f0378c4fb07ad8db0051d540f9d243000be
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-21 11:29:04 +00:00
Tobias Hunger
1c2db89027 Write out a module description file
Write out a file with some JSON data to describe a module.

This file contains information on how that module has been built.

Change-Id: I8a604692663cbb7b76b96b97124130e30b822e4b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-21 11:28:55 +00:00
Leander Beernaert
51979657a1 Add ALLOW_UNDEFINED_SYMBOLS to add_qt_plugin
Allow plugins to be built with undefined symbols when
ALLOW_UNDEFINED_SYMBOLS is specified.

Change-Id: I6bc809e3e5257302157bf8484f850d8319674a4a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-21 10:04:22 +00:00
Leander Beernaert
077ea818af Rename builtin test data resource name
Rename the builtin test data resource name to something more unique as
there are name clashes when building tests which also add a resource
named 'testdata'.

Change-Id: Icc1bbff3134e1dbc6ea4f6a87a1715b936c723cc
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-18 13:20:56 +00:00
Simon Hausmann
7e7f41e40c Pick the latest available C/C++ standard when compiling Qt
This maps the behavior of mkspecs/features/qt_common.prf and enables the
use of C++17 for example in Android, where the toolchain supports it
anyway.

Change-Id: I41f4bdb160a3929e2fb78f36efb1ad5f2ad391a5
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-10-17 19:23:25 +00:00
Alexandru Croitor
4a7e7103e7 Fix precompile header usage
Latest CMake will try to compile the given precompiled headers
as C files, due to enabling the C language in the project + also
having c files.

Make sure to wrap the precompiled headers in a CXX language only
generator expression.

For details, see https://gitlab.kitware.com/cmake/cmake/issues/19839

Change-Id: Ib3508ad920092455c300b1a566ba6152bab032db
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-15 13:50:25 +00:00
Leander Beernaert
69bb9f7cad Fix output property for add_cmake_library()
OUTPUT_DIRECTORY by itself is not a valid cmake target property.

Change-Id: Ic3a2a81b8b982ad7ccf0551000a157f9a4d3ef22
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-15 13:12:04 +00:00
Simon Hausmann
a3fd3c193d Remove compatibility code for old call sites of qlalr processing
Change-Id: I48801c336f7546b9366c70d877d20222c16dd4ff
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-15 08:39:55 +00:00
Alexandru Croitor
190e9dcdcf Regenerate files after dev -> wip/cmake merge
Note the following bigger things that had to be done:
Handle GSS library / feature with a new custom find module.
Implement rudimentary support for relocatability (does not currently
handle extprefix).

Change-Id: Ic6cd27dda7ebca9829f51cb42ea76fff6d1767ef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-14 19:01:19 +00:00
Alexandru Croitor
1e27ad1697 Don't include header directories that don't exist
If a module is marked as NO_MODULE_HEADERS, we shouldn't
try to include the non-existing include directory which is
usually generated by syncqt.

Note it seems that NO_SYNC_QT and NO_MODULE_HEADERS seems
to converge, so it might make sense to merge them in the future.

Change-Id: Iab4e2907ed68776632337b37496b015535da8784
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-14 15:06:10 +00:00
Leander Beernaert
6694689a26 Fix Android build from multi-arch qmake changes
Add condition replacements for the android ABIs.

Add a replacement for QT_ARCH to ANDROID_ABI, since QT_ARCH is only used
with the android build for now.

Change-Id: I553d7910546de32236f723ec2e9a05a18da76130
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-14 13:49:40 +00:00
Leander Beernaert
ecccb71d3d Fix handling of OUTPUT_DIRECTORY in add_cmake_library
extend_target() does not handle the OUTPUT_DIRECTORY argument, so we
must handle it ourselves.

Change-Id: I31880a516ae185f3255b2a51f41d61ee6b1d9838
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 12:18:20 +00:00
Simon Hausmann
f2d15b9683 Minor fix to qt_process_qlalr API
It's probably best to make it follow the usual calling convention that
the associated (consuming) target is the first parameter of the
function. So first this change accepts both formats.

Change-Id: I1f20706b23d5e819e0eb689eecedb3afb49df3b7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 12:02:08 +00:00
Leander Beernaert
1dd82a8843 Add SKIP_INSTALL to add_qt_plugin()
Provide a SKIP_INSTALL argument to add_qt_plugin for test cases with
plugins lacking install information.

Change-Id: Iddb3843fab1790d69d64686530a46057a2ff0477
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 09:23:13 +00:00
Leander Beernaert
6167031ecc Add 'add_cmake_library' to QtBuild.cmake
Add add_cmake_library to allow us to create normal cmake targets using
all the information we have collected via the conversion script.

This function is only meant for tests. For an example,
see tests/auto/corelib/plugin/qpluginloader/lib/lib.pro.

Change-Id: I738cb8ac241b8da1a1da3ef957c24dc7a754d43f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-10 14:15:06 +00:00
Leander Beernaert
b42feb02ce Add install directory for plugins without type
When we run into a plugin that does not have a type and is not a
qml plugin, we try to see if we can find the target installation path
and provide INSTALL_DIRECTORY AND ARCHIVE_INSTALL_DIRECTORY to the
add_qt_plugin call.

We run into this frequently with the unit tests.

This patch also changes add_qt_plugin() to use the value provided in
INSTALL_DIRECTORY for ARCHIVE_INSTALL_DIRECTORY if no value is provided
for the latter.

Change-Id: I61278904a4d2d72308079cd362bd085b4e2f540c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-10 13:06:51 +00:00
Jean-Michaël Celerier
d1542e8a73 Match qt_import_plugin API with qt5's
Some work was needed to make the plug-in types,
and which plug-ins are available for each type
in client code.

Change-Id: Ib71feca31069deca3d3f54c8613054f5f8ae410c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-09 09:05:39 +00:00
Leander Beernaert
5260c1d62a Update add_qml_module() to use INSTALL_QML_FILES
Update add_qml_module() to use the new INSTALL_QML_FILES argument from
qt6_add_qml_module().

This patch also updates pro2cmake.py to remove the QT_QML_SOURCE_INSTALL
property from qml files.

Change-Id: I6623b2de76bb55bd6750e48f7d45c53ca536b391
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-08 13:42:17 +00:00
Leander Beernaert
1a4f0e2583 Update add_qml_module to use DO_NOT_INSTALL_METADATA
Update to match latest changes to QtDeclarative.

Change-Id: Ie455c0418e95c288149b4b1a29b065a8876e8b7e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-08 13:28:20 +00:00
Oliver Wolff
e81441421b cmake: Add IOBluetooth to list of apple system frameworks
The framework is needed for qtconnectivity.

Change-Id: I6a502564fb5543ca94ba5ae458a544286e34564c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-01 13:41:25 +00:00
Alexandru Croitor
48699561d9 Enchance qt_find_package with opt-in debug capability
Sometimes when writing a qt_find_package and configuring a project,
you might get the following error from CMake:

CMake Error at QtBuild.cmake (set_property)
Attempt to promote imported target "WrapFreetype::WrapFreetype" to
global scope (by setting IMPORTED_GLOBAL) which is not built in this
directory.

This means that another find_package call, found WrapFreetype
in another directory scope other than the current one, and thus the
found target cat not be made global. Sometimes that implies that the
qt_find_package might not be needed if WrapFreeType will always be
found via a transitive depdendency.

By setting QT_DEBUG_QT_FIND_PACKAGE=1 on the command line, you can
make qt_find_package skip all of its behavior if the package was
already found and the provided targets were also found.

Unfortunately this behavior can not be made the default, because there
is no way to find out in what scope the package was found, and if it's
legal to make the targets global. At least I haven't found a way to do
that yet.

Thus the opt-in QT_DEBUG_QT_FIND_PACKAGE is a means to help with
debugging such cases.

Change-Id: I04242ed0f2fd0a75bc199386d28a1a0bd92da41a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-01 13:34:38 +00:00
Mårten Nordheim
ef9cef6dff Add a find_library entry for the GameController framework
Needed for QtGamepad

Change-Id: I50227949eb509c021ba8d9b4dbe2b36b6a6de87f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-01 12:50:04 +00:00
Alexandru Croitor
34b1c1c23c Fix qt_find_package to not show incorrect packages at features summary
qt_find_package usually does 2 find_package() calls, one in CONFIG
mode and one in MODULE mode.

If the CONFIG mode doesn't find a Config file, the package_DIR cache
variable is set to NOTFOUND, and this causes the FeatureSummary
at the end to show that the package was not found, even if it is
found by the next MODULE mode find_package call.

Make sure to unset the _DIR variable in case if the Config module
call fails.

This fixes XRender showing up as not found even when it's found via
the FindXRender.cmake file.

Change-Id: I6ce39dad9cbb11836ca71f735a3267070c75b444
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Qt CMake Build Bot
2019-09-27 14:28:04 +00:00
Joerg Bornemann
deeddf2cb1 cmake: Fix QT_TOOL_PATH_SETUP_COMMAND
The set command looked like this:
    set \"PATH=...\"
which was setting the environment variable \"PATH.

Removing the escaped double quotes makes it actually work.

Change-Id: I2c1d5d01b4415220512b005b75b7b67c695e33ae
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-26 12:22:13 +00:00
Leander Beernaert
6e2ca1d6cb Add SKIP_TYPE_REGISTRATION option to add_qml_module
If the qml files are not listed in the qmldir file they do not need
to be written again, since it is expected that they are registered
by the c++ plugin code.

Change-Id: I624aedb182583f942bf1d1a322861c47a64b5065
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-24 12:54:57 +00:00
Tor Arne Vestbø
2cc3720a57 macOS: Prevent warnings about object files without any symbols
Change-Id: I0860b95cd75f536ff20defde97c3df7dc78a1e18
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-24 07:27:58 +00:00
Alexandru Croitor
80d86fed13 Fix qtdeclarative build
There is an issue about versionless tool target not finding
the regular targets, and that fails the configuration phase
of qtdeclarative.

Temporarily don't export the versionless targets, to get the
qt5 build going.

Change-Id: I5c7baff7f677f4a3f1f91b9e8082ba8a80f9cddd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-23 11:22:01 +00:00
Alexandru Croitor
fbddf745e9 Create module tools packages (config files) automatically
Previously you had to make sure to use DISABLE_TOOLS_EXPORT
in an add_qt_module call if the tools are built after the module,
as well as to manually call qt_export_tools after all associated
tools are built.

This was needlessly complex, especially for people that are porting
a repo with tools for the first time.

The tools package creation is now automatically done at QtPostProcess
step, so there is no need to use either DISABLE_TOOLS_EXPORT or
qt_export_tools() manually.

DISABLE_TOOLS_EXPORT is now a no-op, and will be removed once all repos
are updated not to use it.

Change-Id: I965b0d3a8a0cb908afae87b047083ed7bea9f02f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:29:28 +00:00
Mårten Nordheim
25c53ce00e PCH: Only enable automatically for libraries/modules
Some tests are changing headers using defines inside the tests.
Let's more closely mirror what qmake does to fix this. And it will also
save quite a lot of space since most tests don't include all of
e.g. QtCore

Change-Id: I6f7e530f922418944d690bd2a1ee5f459ba755e1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-19 17:33:20 +00:00
Leander Beernaert
d03d12a74f Add Qml plugin example support
Extend the example writing section to handle qml plugins. Detection
is based on whether the plugin config is detected an the target links
against Qml.

add_qt_qml_module() now uses the the public facing API underneath.

Change-Id: I2ccd06548e7b5b18c9dc3338b835bc115fa97809
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-19 08:06:08 +00:00
Cristián Maureira-Fredes
3ba61c0354 Check if Qt source dir is not empty to use syncqt
In an extreme case where /bin/syncqt.pl does exists,
is better to check if the QtBase_SOURCE_DIR is not empty
to avoid a mismatch script version that is being used.

Change-Id: Ia5694eadc5517998b827eccf70bdf6f3c14ebfa3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-18 15:26:26 +00:00
Leander Beernaert
1496a88429 Fix QtDeclcarative static builds
Incorrect variable name was being used to set the target in the parent
scope.

Change-Id: I73ea644ebf94c9b9a62b34b1ad493e488729ff2f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-18 14:28:29 +00:00
Simon Hausmann
cb5fbbde27 Fix up documentation integration placeholder
In the future need will need to continue to tie qdoc runs still to
targets, just like with qmake. This change prepares us for that by
ensuring that add_docs takes two parameters and that any re-generated
CMakeLists.txt from now on gets it right.

Change-Id: Id0256dc1e2f2f59f3b4e4ca98f0d10d025d189fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-18 09:45:12 +00:00
Mårten Nordheim
89e347ba42 Fix for getting windows running tests
By adding the path to the DLLs early on in the path. This fixes the
issue seen in CI (0xc0000135, DLL not found) and resolves local issues
where you might have forgotten to add this to path yourself potentially
grabbing libraries from elsewhere.

The ${path} seems to be a holdover that is no longer used, so it was
removed while the code was changed anyway.

Also disable WIN32_EXECUTABLE for all tests so that we can actually get
some output from them :)

Change-Id: Iec42c809c37be4f31c7f0a7af3a30c3528022dbe
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-17 17:11:59 +00:00
Jüri Valdmann
933d383a24 pro2cmake: Support QML IMPORTPATH with multiple elements
Change-Id: I8113d7dd4e7967d020d59a5b4104e8366d55283c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-17 10:39:34 +00:00
Alexandru Croitor
6bfe16922a Teach automoc to run moc when it sees Q_ENUM_NS
Needed for qtcoap, otherwise AUTOMOC doesn't run moc
on qcoapnamespace.h.

Change-Id: I4ca43fcbbc5db6163f9f9f788b920eae86f5b174
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-17 08:49:56 +00:00
Simon Hausmann
0f312d3c02 Prospective fix for QtGui private symbol versioning
In qmake, the header files used for private symbol versioning is done
via

    private_api_headers = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.QPA_HEADER_FILES

So we must do the same with CMake.

Change-Id: Iaebeb13592241b6c4d89f70d2e6ac3ebfb374207
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-09-17 08:06:28 +00:00
Leander Beernaert
21dd3624a5 Fix OUTPUT_TARGET propagation in qt6_add_resource()
Value was not being propagated to the parent scope when set.

This patch also changes OUTPUT_TARGET to OUTPUT_TARGETS since it is
possible that two targets can be generated.

Change-Id: If489a609ed363a319224fcd6c5a4fc878d0d8617
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-16 11:41:48 +00:00
Mårten Nordheim
5884f793b9 Don't set the MODULE_HEADER property on header-only modules
They're INTERFACE-type targets and can thus only have whitelisted
properties set. That fixes the cmake configure step for the UiPlugin
target in qttools.

This has the unfortunate side-effect that the headers will not be picked
up for our pre-compiled headers. Although it is not a big issue since we
don't have many header-only modules. An example is QtTools' UiPlugin.

Amends 2cf0ba1fba

Change-Id: If722928f64727ffaf2e9d0746668c0198fa1a647
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-13 11:19:46 +00:00
Mårten Nordheim
2cf0ba1fba Use pre-compiled headers when building Qt with cmake
Some modules define their own manually-maintained lists, and we can rely
on the headers generated by each module to include in the pch as well
e.g. QtCore/QtCore.

There's also e.g. QtWidgetDepends for QtWidgets, but this only
works for modules, not for tools, examples or other applications.
For now we'll use the Qt<Module>/Qt<Module> headers for the
modules we depend on.

Building with PCH can be disabled with -DBUILD_WITH_PCH=NO, and it only
works for versions of CMake newer than 3.15.20190829.

Change-Id: Iae52bd69acfdfd58f4cd20d3cfa3c7f42775f732
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-11 08:25:54 +00:00
Alexandru Croitor
6720f0204f Don't propagate INSTALL_INTERFACE headers for modules with no syncqt
If syncqt was not executed for a module, it will not have generated
headers, so we should not propagate the include/${module} header
location in that case.

Change-Id: I6dc0628a11ababb4d237215a9f4d3fc331383848
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-10 14:19:35 +00:00
Simon Hausmann
bc54f0b164 Fix build of installed header-only modules in non-prefix builds
QtUiTools in qttools is a public module that has only headers, so it's
an interface library in cmake. That means INTERFACE_INCLUDE_DIRECTORIES
cannot contain paths to the source or build directory, unless they are
prefixed with BUILD_INTERFACE, which this patch adds.

Change-Id: I047700f447237dfbe5a901072eb413a159ae537d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-05 13:36:47 +00:00
Simon Hausmann
4ee762cf25 Fix qmlcachegen invocation on Windows, part 2
Fix up the previous commit and use separate COMMAND parameters for
add_custom_command to ensure the expansion of the PATH. The injection
via -E env "/some/dir;%PATH%" does not work as the dollar expansion is
not applied when the ninja command uses cmd /C. This relies now on
undocumented behavior of cmake ;(

Change-Id: I5b5fc88e4c13f8fb6c6bba3131204c2eb35404d6
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-04 13:55:34 +00:00
Simon Hausmann
18fc9e1bf8 Fix qtdeclarative build on Windows
Our tools are typically installed into the Qt bin directory, after which
they are useable right away on Windows, since the Qt dlls are located
there, too. An exception to the rule are tools that are built within a
module and used right away. At that point they are in the top-level
bin dir of the build directory, along with "local" DLLS they might need,
but with the Qt dlls out of reach. To cover this case, we need to
prepend a PATH adjusting command when using these with
add_custom_command.

Change-Id: I7f58581f5060c8004b5d1fa1f6f17297256783de
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-04 13:18:08 +00:00
Simon Hausmann
85e3bb7aea Remove dead code
Change-Id: Iac7c7c77744b43772faf3402566685a674ab8ff3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-09-04 12:29:25 +00:00
Alexandru Croitor
f9842ae7d4 Don't include module syncqt header locations if syncqt was not run
When building QtQmlDevTools we don't generate syncqt headers, but the
non-existent include paths were still added, which means that anything
that used QtQmlDevTools would fail to configure (the standalone tests).

Make sure to only add the include paths if syncqt was executed.

Change-Id: I6d79ecf53e9a5d396e8df801584ce2c9f119f9be
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-02 12:32:01 +00:00
Leander Beernaert
eeffac526e Update Android build configuration
Update Android build configuration to be compatible with the multi-arch
android build patch to qmake. We can now build and generate the apk
correctly. Executing on the device/simulator will only work once the
latest changes from 5.14 have been merged in.

We now replace target suffix with ${CMAKE_ANDROID_ARCH_ABI}.[so|a] so
we don't have to deal with handling targets which might have any of the
OUTPUT_NAME properties set.

The dependency and deploy settings generation has also been updated to
append the file contents to a string and then do a single file write
at the end.

Change-Id: Id3c5bd0428141ecaf962124a100390e3a4e41feb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-30 12:10:26 +00:00
Alexandru Croitor
6c15ad7978 Fix qtdeclarative static builds
qmlplugindump is not build during a Qt static build, so there's no
point in creating custom targets that would run the tool.

Change-Id: Id7d6d44da63312f298f46eab08a5637cb0c97c8f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 12:10:07 +00:00
Alexandru Croitor
d436023b6a Fix static builds after revamp of add_qt_resource
The first issue is that instead of arg_OUTPUT_TARGET we should use
rcc_OUTPUT_TARGET (there was also a typo in the OUTPUT word).

The second issue came with the fact that the object library targets
that were created for resources had a "Qt6::" namespace prefix in the
exported Targets files, and yet the link generator expression did not
contain the prefix. This failed when building qtsvg in a static build,
because the exported object library could not be found.

The solution is to use the TARGET_NAME generator expression which
takes care of adjusting the name of the target when exported, thus
making the linking work both when building qtbase and when building
qtsvg.

This had the fallout, that all resource object libraries need
to be associated with an export set and installed. This wasn't the case
for plugins, because plugins have an export name of the form
"FooTargets", whereas the export name for the resource object library
is "Qt6FooTargets".

Adjust the export names of plugins to be the same as for modules and
resource library objects (aka contain the "Qt6 prefix").

Change-Id: I1ca28d20c51e4447e5783cc20571a68ec77f6513
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 08:24:37 +00:00
Simon Hausmann
3b04d22241 Fix "mkspec selection" when building with Emscripten
Change-Id: Id9d466221294651c2f8dfde149d82f45b4081238
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 14:10:10 +00:00
Simon Hausmann
db61770566 Fix CMake errors around linker flags when targeting WASM
* The -no-undefined linker option only makes sense for shared
      libraries. The WASM build is a static build though.

    * The -gc-sections linker option is only relevant for host tools
      and certainly applicable to the WASM toolchain.

Change-Id: Ib8daec66a6d80f5025887448882dd891e6176268
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:23:59 +00:00
Leander Beernaert
add4c4816c Add missing qml-root-path for Android
Add missing qml root path variable in the deployment configuration file.
Not having this variable will cause androiddeployqt not use the
qml dependency scanner to package all relevant dependencies.

This patch also fixes QT_ANDROID_BUNDLED_FILES files not being
processed.

Change-Id: I5bca33cdbb57098f283b38516b777571806da9e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 12:29:12 +00:00
Alexandru Croitor
486da5a84d Fix qt_get_module_for_plugin to work with interface libraries
Assume that interface libraries can't have plugins for now, otherwise
we'll need to change the "MODULE_PLUGIN_TYPES" property name to
include INTERFACE_ as a prefix.

Change-Id: I21b64179ded5fd10216d843a21ee149e002793f3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-28 11:15:00 +00:00
Leander Beernaert
4260b1edc5 Add OUPUT_DIRECTORY option to add_qt_test
From all the observed cases, the parameters given to OUTPUT_DIRECTORY
tend to be CMAKE_CURRENT_BINARY_DIR, which was the default value. This
change is mainly to avoid add_qt_test failing if OUTPUT_DIRECTORY is
specified.

Change-Id: I26b931dd33ad1e991b64c14cc11b4b7a713fc858
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-26 09:39:47 +00:00
Leander Beernaert
753e7c1061 Do not use quick compiler with embedded test data
Prevent the quick compiler running on embedded test data for platforms
such as Android. This breaks certain assumptions about the test setup
otherwise.

Change-Id: I1026da3e16552256623de26b843ea32ed2c4260e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-23 13:50:49 +00:00
Leander Beernaert
acdc5dfaee Skip emebedding test data when there is no target
On android test data is embedded into to the binary via resources. This
will not work with sourceless tests such as the qml only test cases.

Change-Id: I3ecf28223b3c7c6dae4ca3f15519adc028082598
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-23 09:31:39 +00:00
Alexandru Croitor
54aeb4ccd7 Add support for Qt header_modules aka a header only INTERFACE library
Also add support for modules that have no private module counterpart.

Both are needed for Designer's QtUiPlugin in qttools.

Change-Id: Ia7e9d8837140e1de5cd59e196b4f63481ab68298
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-23 09:26:16 +00:00
Alexandru Croitor
bb2d1f8119 Abstract and fix usages of QT_KNOWN_MODULES
In some places of the build system we need to iterate over repo specific
Qt known modules (aka the ones that are built in the current project).
In other places we need to iterate over the whole list of known Qt
modules (those found via find_package + the ones built in the
current project).

Introduce two separate functions that provide access to either the
former or latter, and adjust all existing usages of QT_KNOWN_MODULES as
needed.

Change-Id: Ica96d0cfe690b9aaaa3f8c53bc84975bccad69c7
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-08-23 09:25:37 +00:00
Leander Beernaert
24bdc6e156 Fix missing prefix for test data on android
Add missing required resource prefix to add_qt_resource() call when
embedding test data as a resource.

Change-Id: I9130f9ae863daae80221a1475b077b1d2e501f6d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-22 13:49:33 +00:00
Leander Beernaert
7a1853dbe2 Extract add_qt_resource into reusable components
This patch moves all of the underlying code for add_qt_resource
into a common reusable snippet for both the Qt build and user projects.

For users, the new API is available under QT5_ADD_RESOURCES. If
outfiles is a CMAKE target we will use the new API, otherwise
we will fall back to the old behavior.

This patch also adds EXTRA_CMAKE_FILES and EXTRA_CMAKE_INCLUDES to
add_qt_module so that module specific cmake files can be installed
and loaded by the module's config.cmake.

The code will be installed under CMAKE_BINARY_DIR/Qt{}CoreResource.cmake
and is injected into Qt{}Core_Config.cmake via the extra cmake includes
passed into add_qt_module.

To make sure it still works with QtBuild, we do the actual generation
of the file from QtBaseGlobalTargets and include the generated file
there as well.

Change-Id: I85fefaa11dde01a6790d23c62d6a64cd157e2617
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-22 09:47:01 +00:00
Leander Beernaert
87a6283fbb Fix QT_WILL_BUILD_TOOLS evaluation
This condition was not being properly evaluated since the cached variable
was treated as a string. Any checks with if(QT_WILL_BUILD_TOOLS) would
just verify whether the string was empty or not.

Change-Id: Ie8b9ecc8249a1e9f5c0aa1b13d5bef686fcb04de
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-16 11:39:18 +00:00
Alexandru Croitor
1291e8d094 Fix developer warnings that a plugin does not belong to a Qt module
When building qtsvg or qtimageformats there are a bunch of
configuration warnings like:

The plug-in 'qtiff' does not belong to any Qt module.

This happens because qt_get_module_for_plugin() checks for modules
only in the QT_KNOWN_MODULES variable. find_package()'d modules
will not appear there though, but only in
QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE.

Change the function to check for Qt modules in both variables.
This fixes all the warnings regarding plugins not belonging to a
module.

Change-Id: I39e668801a93794b62888cf868b97c55f57dccdd
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-16 07:28:53 +00:00
Alexandru Croitor
4572ded8b3 Fix copying / installing of testdata to proper location
I don't know why, but previously the test data was copied to
"test_build_dir/testdata" subfolder. That's incorrect, there's no
need for a testdata subfolder, the copied / installed contents
should go directly under the test build dir / install dir.

Incidentally this will make the corelib/io/qdir tests to pass.

Amends 1307736c7d .

Change-Id: I9e180d608433fe82f4a29afea7f594507e6020d3
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-15 10:56:16 +00:00
Alexandru Croitor
b8dae2c617 Handle test helpers better
Teach pro2cmake to use add_qt_test_helper instead of
add_qt_executable when the qmake 'qt_test_helper' feature is used.

Don't use macOS bundles when building tests on macOS, because that
breaks path assumptions for certain tests.

Introduce a new OVERRIDE_OUTPUT_DIRECTORY option for add_qt_test_helper
that allows placing the binary into a folder other than the test parent
folder. I considered changing the default behavior not to place into the
parent folder, but that would break all existing tests, so I opted for
override approach instead. Ultimately we might want to revisit this
later.



Change-Id: I68fd1dea608333c2af0d3896050b40a6964dd87f
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-15 10:56:02 +00:00
Leander Beernaert
7fda42ef9a Rename alias property on source files to QT_RESOURCE_ALIAS
Rename the alias property used by add_qt_resource() to QT_RESOURCE_ALIAS
to match property naming conventions.

Change-Id: I97b12b0b794e158f03dabeed5ec23a3b7d56cfbb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-15 09:34:09 +00:00
Leander Beernaert
8630c5ac7e Add support for QtQuikCompiler retained resources
Support translating the QTQUICK_COMPILER_RETAINED_RESOURCES variable.

Fix missing PROPERTIES keyword for set_source_files_properties() commands.

Apply source file properties to standalone source files as they appear
in the project as it was possible for them to inherit values that were
not meant for them.

When creating resource lists, prefix them with the resource name
to avoid collisions.

Change-Id: I69ef85ea9414c0e7c07b1ebfb76d24bd878ce70f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-14 12:45:11 +00:00
Leander Beernaert
723d5c5056 Fix QRC Resource paths for qrc files in subdirectories
When pro2cmake converts qrc files that are located in a subdirectory
there is an error in the resource paths for qrc files generated
with add_qt_resource().

For instance, consider the contents of data/scenegraph.qrc:
<RCC>
    <qresource prefix="/qt-project.org/scenegraph">
        <file>"shaders/24bittextmask.frag"</file>
    </qrsource>
<RCC>

After processing by pro2cmake and add_qt_resource() we generate
<RCC>
    <qresource prefix="/qt-project.org/scenegraph">
	<file alias="data/shaders/24bittextmask.frag">
            ${CMAKE_CURRENT_SOURCE_DIR}/data/shaders/24bittextmask.frag"
        </file>
    </qrsource>
<RCC>

The expected qrc path for the resource should be prefix/shaders/...,
but in CMake it becomes prefix/data/shaders/... due to the
BASE parameter.

To fix it we check whether BASE is set and whether there are no
other aliases present on the source file before setting an alias
with the original file path.

Change-Id: If0a68a5ffa787704b10b740e20f875c9029509b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-14 11:44:58 +00:00
Leander Beernaert
0f268277c5 Add substituition rule to qt_internal_module_info
Added substituion rule to qt_internal_module_info to replace '.' with
'_'. Fixes compile errors for targets with names such as Plugin.2.

Change-Id: I0754c771bdc456a8a8f450fba90792c98d276c92
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-12 10:02:20 +00:00
Leander Beernaert
b25260bac6 Change quick compiler generated code path
We now compile all qml files from the quick compiler in separate
directories qmlcache/${resource_name} to prevent issues where the same
qml file is present in more than one resource file.

Change-Id: I6857ff6aaaa21112896d5d39bbe11d3ffe524ec8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-12 09:01:35 +00:00
Leander Beernaert
6ef1b60b08 Fix QuickCompiler Setup Errors
If the variable resource_files existed in the parent scope, the list
would now be duplicate.

Fix case where TO_CMAKE_PATH didn't properly convert //Foo into /Foo,
so wee need to handle this manually.

Change-Id: I73f1b4db82f6a80ba00da928b39091ac6c968a02
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 14:12:37 +00:00
Simon Hausmann
95c27e325f Fix add_qt_resource behavior with regards to unspecified prefixes
This change makes the PREFIX parameter a required parameter if the
target does not specify a default. This way the behavior is clear when
reading the code: add_qt_resource() without PREFIX means it must come
frmo the target.

Change-Id: I79024e70e7b4d32a5164b93aa08ec9ff409b2d39
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-08-09 11:50:11 +00:00
Simon Hausmann
73ba2ba2de Simplify resource embedding for qml modules
* Add support for a QT_RESOURCE_PREFIX target property, that
      add_qt_resource respects. This makes it convenient to add files
      to the resource system for a project without the need to repeat
      prefixes. In qmake land with multiple resources they're repeated
      in the foo.prefix variables or in the prefix attribute in .qrc
      files.

    * Since /qt-project.org/imports is in the default QML import search path
       and the hierarchy under the import search paths is "regulated",
       we might as well make add_qml_module set QT_RESOURCE_PREFIX on
       the target. We can compute the correct value for that. This
       allows removing the redundant prefix from the add_qt_resource()
       calls for the qml files.

Change-Id: Ic15130dc9e432340fc3edf93e35f2a803b4b40eb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-09 11:47:25 +00:00
Simon Hausmann
f55c6a4cb0 Remove unused parameters for add_qml_module
Change-Id: Ic7774aa401089061b153920e51537e1c2264ce4f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-09 11:47:13 +00:00
Leander Beernaert
7e84157117 Fix dependencies for source file generated through rcc
There was a missing dependency rule which would cause the generated cpp
file to not be updated when changes were made to a qrc file generated
through add_qt_resource().

Change-Id: I9544c2fb6cf49529913f731b8fb6fc524d65e40c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-09 11:29:50 +00:00
Simon Hausmann
8ba882a0b3 Add support for QTQUICK_COMPILER_SKIPPED_RESOURCES
Detect this in the conversion script and map it to a source file
property. When that's the case, avoid repeating the file list but
instead store it in a variable.

Change-Id: If3119d83914bb798766e27351746b4e867bd3ab3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 09:21:12 +00:00
Simon Hausmann
587581963e Minor variable naming cleanup
Change-Id: I47f07a22c356ca545052f63788756068a51c3e39
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 09:20:56 +00:00
Leander Beernaert
9c3af6ecb2 Fix sourceless qml test case
Minor tweaks to make sure QML test cases without source files work as
expected.

Change-Id: I30b72622692b8f36d01f7a17b9d1456b0ab223ea
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 08:23:38 +00:00
Leander Beernaert
2d48490940 Enable quick compiler for qml files in add_qt_resource
File passed into add_qt_resource are check to see if they match valid
qml files extension. Those which match the latter are then processed
by the qt quick compiler should the qmlcachegen target be present. We
also ensure that any remaining resources are properly chainloaded.

If the qmlcachegen target can't be located a warning be will be
issued asking for the inclusion of QmlTools in the find_package
command.

Change-Id: Ieecd38670e15c21d94dc549b31c7d87f2383d9af
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-09 07:33:55 +00:00
Alexandru Croitor
c894c224d1 Fix and streamline header inclusion
While trying to port qtgraphicaleffects, when trying to configure
the project with a non-prefix build, the configuration fails with
the following error:

CMake Error in src/effects/CMakeLists.txt:
  Imported target "Qt::Qml" includes non-existent path

 "../qt_cmake/qtdeclarative_built_developer/include"

This is because we incorrectly export public include directories
that point to an "/include" folder under the repo build dir, whereas
in a non-prefix build the syncqt "/include" folder is actually in the
qtbase build dir.

Fix this, by introducing a new variable called "foo_repo_include_dir"
which will point to the correct include directory regardles of prefix
or non-prefix build. This variable is set by qt_internal_module_info.

Fix all relevant places to use this new variable. Also streamline
and remove any unncessary include directories in all our functions,
thus making everything consistent and hopefully easier to understand.

Change-Id: Icbe884701275c7754daecadcdba18048b4d779d0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-08 15:45:32 +00:00
Leander Beernaert
ebe77c89de Fix typo in QtBuild.cmake
Fix typo for set command.

Change-Id: I1881bf77cab47ef37081065057200a72a2bc7e8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-07 07:48:49 +00:00
Leander Beernaert
709538096c Fix add_qml_module URI
Make sure the URI name for qml modules correctly strips out the version
number for instances such as QtQuick.Controls.2.

Change-Id: I18e706b371323eeefdd6d7564b922265fa5cad3f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-06 13:10:22 +00:00
Simon Hausmann
e343affd63 Propagate library/plugin resources automatically when linking statically
The rcc generated code relies on global constructors to register the resources.
The object file of the generated code is included by default in shared libraries
and executables. However when the object file ends up in a static library, the
linker will discard the object file when nothing references any of the symbols
in that object file, when linking the static library into the executable/shared library.
The solution is to link the object file straight into the final target, by means of a
cmake object library.

Change-Id: I02ad1173e4f7e8f907022c906640dc9086233676
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-06 08:41:51 +00:00
Leander Beernaert
0ceed231b4 Add __default_public_args to add_qt_test and add_qt_executable
Due to the missing argument processing on PUBLIC arguments we could
run into situations where the defines for an executable (mostly tests)
would be incorrectly processed.

If one were to pass a define into a test that also specifies public
libraries, the defines passed in by test would fall under the
PUBLIC_LIBRARIES argument in add_qt_executable.

For instance, in a test with DEFINES Foo PUBLIC_LIBRARIES Core
would cause arg_DEFINES to be "Foo=BAR;PUBLIC_LIBRARIES;Core". This
combined with the defines specified by add_qt_test would result
in the following string "Foo=BAR;PUBLIC_LIBRARIES;Core;TEST_DIR=..."
and would cause TEST_DIR to be treated as a public library in
add add_qt_executable.

For some reason I can't figure out, these two defines end up in the
linker flag section of certain test programs. There is nothing wrong
with the rest of the propagation chain into add_qt_executable. My best
guess is that it has something to do with the generators. In any case
add an explicit -D fixes the issue.

Change-Id: I340790c1c2426fa76785d1bd1b3332a904323d56
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-05 08:06:37 +00:00
Leander Beernaert
97b76704ea Refactor QML_FILES for add_qml_module
It has been decided, that going forward all qml files are to be added
to a module via the resource system. This patch does the ground work
to make sure all qml modules in the qt codebase follow these new
conventions.

New properties on targets have been added so that we can't track all the
qml related information for later use.

To make sure it is still possible to install qml files we added the
qt_install_qml_files() command.

Pro2cmake has been adjusted to handle the special cases of versioned
qml modules (e.g: QtQuick.2). It will now insert a TARGET_PATH
override to avoid the default conversion from the URI parameter.

Finally, this patch temporarliy disables the quick compiler by moving
all relevant code into a dummy function. This will be removed in a
follow up patch where the quick compiler will be enable for all
qml files present in resource files.

Change-Id: I09fe4517fad26ec96122d9c7c777dbfbd214905c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-01 14:07:01 +00:00
Leander Beernaert
a920c16ef2 Add Qt Quick Compiler support
This patch adds support for the qtquick compiler feature, which
will embed the compiled qml files as resources along with the
respective qml_loader.

This patch also changes the add_qml_module call to require either
EMBED_QML_FILES and/or INSTALL_QML_FILES to be specified.

Change-Id: I32d29c9b554b8286ed3b980027a56dd4abe11c92
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-31 12:52:20 +00:00
Simon Hausmann
517a0ea8f0 Fix add_qml_module() with non-static builds
Make sure that the .qml/.js/.mjs files are copied or installed into
their target destination.

Change-Id: Ib1649e5168c9fe3a570800af92d82293e5b295d6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-07-30 15:37:00 +00:00
Alexandru Croitor
5528bcf99c Protect against extending imported host targets
When cross-compiling qtdeclarative, add_qt_tools makes sure to import
the host tool and not build it. But there are also some
extend_target and add_qt_resource calls which try to extend the host
tool.

Make sure to protect those functions not to do anything if they are
called on an imported target.

Change-Id: Ifd8bcab8e56ad389a8c145382b23bd2c1bda5e81
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-30 13:26:25 +00:00
Simon Hausmann
c75dcc6875 Permit the use of qml cache file generation even inside qtdeclarative
After re-arranging subdirs, the cmake target level dependencies can
handle building qmlcachegen before running the custom command for
generating cache files.

Change-Id: I8a35b2b5bfd2fdf4b49462ff9c27e5f3075254fc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-29 13:15:16 +00:00
Alexandru Croitor
1307736c7d Fix testdata handling
Make sure to handle glob expressions in the entire path given, not just
the end of the path. This handles tests like qsslkey and qnetworkreply.

Also copy/install the testdata in the final test directory path under
a "testdata" subdir.
Previously INSTALL_TESTDIR was used, which was never set to anything.

Change-Id: I2408e12f586cadeb524ffa249e851a4179324b23
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-07-29 13:14:44 +00:00
Leander Beernaert
e61a7a2c57 Add support for qmlcachegen
This patch adds support for qmake's qmlcache feature. It's enabled
when option EMBED_QML_FILES is not present in add_qml_module.

Change-Id: I9b35f0bda7dfaf777f55c14eaf3d763f9b550fa4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-29 11:52:43 +00:00
Leander Beernaert
88bf485f91 Add EMBED_QML_FILES option to add_qml_module
Some projects in QtQuickControls force the qml files to embedded into
the binary. This change exposes an option to mimic that bevhavior.

Change-Id: I4cbf0c21c05ca03b8dd1189eb7d81e43279c7157
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-25 09:44:03 +00:00
Leander Beernaert
2cc865b943 Extend add_qt_test to support qmltestcase
Extend add_qt_test for qmltest by setting the option QMLTEST
when we detect the config qmltestcase.

We also forwards the GUI option to the tests when detected.
This is a requirement for some QtQuickControls2 tests.

Finally when doing a prefix build, we add the install directory
to the QT_PLUGIN_PATH environment variable.

Change-Id: I3b2ecb494955976e98abbcf3d03925c314336122
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-24 10:49:20 +00:00
Leander Beernaert
1072a8f579 Add missing QT_INSTALL_DIR paths to qml files and test data
Make sure that paths passed to qt_copy_or_install are prefixed with
QT_INSTALL_DIR so that they behave correctly with prefix and non-prefix
builds.

Make sure that plugin.qmltypes and qmldir are also copied to binary dir
when doing prefix builds to match qmake's behavior.

Change-Id: I6f87ed478e797c9f66dbf85264904ad29a60ad95
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-07-24 09:28:18 +00:00
Alexandru Croitor
35fbe525fe Fix warnings regarding QML plugins
Some author warnings don't make sense when dealing with QML
plugins, like the messages regarding CLASS_NAME or not
belonging to a certain module. Take care not to print those
warnings in those cases.

Change-Id: I017bd63cca650dc262337949242e813b7b6a56cc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-22 16:02:30 +00:00
Leander Beernaert
31341ad63a Simplify add_qml_module code
Reduce the amount of code required to add a qml plugin to cmake
by making add_qml_module wrap the add_qt_plugin code where required.

add_qml_module will also create a dummy target so that qml files
will appear as source files in an IDE when no cpp files are present.

CXX_MODULE qmake parameter has been dropped in favor of an
explicit IMPORT_VERSION parameter, since it was only used to
determine the version when the IMPORT_VERSION was not specified.

Change-Id: I4a4b626566720d04c62d246ca521db8c4a95b10f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-22 14:28:19 +00:00
Leander Beernaert
ec1546afc4 Handle TESTDATA for Qt Tests
These changes enable the support to handle test data and install or
package them as resources when appropriate.

This change does not handle the GENERATED_TESTDATA or
TEST_HELPER_INSTALLS since there are very few occurrences of these and
we can handle those as special cases.

Finally, in add_qt_test, only append CMAKE_CURRENT_SOURCE_DIR if
the path is not absolute.

Change-Id: Ic20b9749d10e2a09916f2797606116471c64850b
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-16 06:48:56 +00:00
Leander Beernaert
30b3746370 Add support for QML plugins
Add the necessary code to both the QtBuild and pro2cmake to be able
to handle qml plugins in qt declarative.

Add condition replacement for QTDIR_build to QT_BUILDING_QT so that
certain qml examples work correctly when being built in the build
directory.

Fix add_qt_resources not being updated during build after changes
were made. Files list used as dependencies were not populated.

Add missing module mappings for qtdeclarative.

Change-Id: I0f71d0a3a0e7e97ba96807950d11cffaee04d9b2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-07-15 12:28:12 +00:00
Alexandru Croitor
078cd61751 Fix CMake moc scanner to look for new macro Q_NAMESPACE_EXPORT
f66c1db16c in qtbase introduced a new
macro that the moc scanner has to look for.

Set an explicit list of macros to look for in the
CMAKE_AUTOMOC_MACRO_NAMES property of every target that has AUTOMOC
enabled, otherwise CMake AUTOMOC won't run moc on files that contain
the new macro.

Change-Id: Id991a70d773cef66716621803a88e96b44a80650
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-11 15:16:09 +00:00
Jean-Michaël Celerier
a5b78a3660 cmake: implement default qpa plugin behavior for static builds
This is done by adding a DEFAULT_IF argument to add_qt_plugin, which accepts
if-evaluated expressions.

e.g.

    add_qt_plugin(myplugin
	DEFAULT_IF ${foo} STREQUAL ${bar}
        ...
    )

so that this mechanism can be reused later if necessary.

Change-Id: I7eba9adaaa28e55a4f0f94cf206e868b990027e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-05 14:58:52 +00:00
Jean-Michaël Celerier
5769e1a2f6 cmake: allow client apps to load static plug-ins
Based in part on Kyle Edwards's implementation :
https://codereview.qt-project.org/c/qt/qtbase/+/243731

Example :
```
cmake_minimum_required(VERSION 3.15)
project(foo)

add_executable(foo main.cpp)

find_package(ICU COMPONENTS i18n uc data REQUIRED)
find_package(Qt6 COMPONENTS Core Gui REQUIRED)
target_link_libraries(foo Qt6::Core Qt6::Gui)

qt_import_plugins(foo
    INCLUDE
        Qt6::qxcb
    EXCLUDE
        Qt6::qgtk3 Qt6::qeglfs-kms-integration Qt6::qjpeg
)
```

Change-Id: If7736c42f669f7d7f43052cae59c28fc7fcb4156
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-05 14:56:56 +00:00
Leander Beernaert
a9d2c5b6d7 Android: Final changes for APK generation
Generate the ${MODULE}-android-dependencies.xml for the androiddeployqt
tool. This will ensure all the right plugins and dependencies are
packaged when generating the apk.

This change also changes the visibility for executable to default/public.
Not having this will cause the application to crash as we can't locate
main() in the executable (shared library).

Additionally pro2cmake conversion script has been updated to perform
the required conversions for the Android settings.

Finally, the 6 projects in QtBase that have Android dependencies have
been updated with the new script and the step that produces the xml
files in run at the end in QtPostProcess.cmake.

Change-Id: I9774ba1b123bc11cae972fa37054ef2c51988498
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-26 08:34:37 +00:00
Simon Hausmann
e5b62e9607 Allow prefix builds with developer-build as feature enabled
Just like with qmake, separate the two "features".

Change-Id: Idf2a796c7c4aaa740c471688b2221d7041fed643
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-25 13:38:44 +00:00
Simon Hausmann
6290efc4eb Fix building against an installed static Qt
For ICU we have multiple components, and ICU becomes a public dependency
to QtCore.

When storing the INTERFACE_QT_PACKAGE_COMPONENTS property, make sure to
store the entire list of components, not just the first component -- by
turning the semi-colon separated list into a space separated list.

When processing the components at find_dependency time, we need to
reverse that and pass COMPONENTS directly to ensure a correct parameter
expansion.

Change-Id: I24a0708520e7d5fba039395a151034aee4d4c0e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-25 13:38:33 +00:00
Simon Hausmann
e25f9e2008 Prepare tests for running in the CI
* Add labels so that ctest --print-labels and ctest -L <label> gives
  insight over the test plan and the ability to run easily individual
  tests.
* Unfortunately we can't do the TESTARGS indirection for arguments as
  coin does with testlib, so instead pass the parameters to generate
  the xml unconditionally.

Change-Id: I289de9c15c516e3ac3fe04771fdbd8d7a083ff1f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-25 13:11:05 +00:00
Simon Hausmann
d2c2ff8337 Fix tools dependencies in associated modules when cross-compiling
When cross-compiling we take a shortcut in add_qt_tool() for moc, etc.
as the tools are already imported from the host build of Qt. However we
must still add the tools as a dependency in for example QtCore so that
when the cross-compiled QtCore is used, the host tools are implicitly
imported.

Change-Id: I83e4fd7f21e18472c0965c90c058dd2b55b6ec65
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-24 14:23:41 +00:00
Alexandru Croitor
a581f917e2 Fix plugins on macOS to have the .dylib extension
add_library(MODULE) creates libraries with .so extension on macOS,
but Qt plugins should have the .dylib extension.

Change-Id: I603e7abfb9d5b78c0c8ea526f9fe995bf36c3a50
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-24 13:30:22 +00:00