Commit Graph

305 Commits

Author SHA1 Message Date
Friedemann Kleint
9b31bdacc6 pro2cmake.py: State dependencies
Change-Id: I26234c68b781b983022c73a2d4206550f25b0232
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-17 12:57:19 +00:00
Friedemann Kleint
69caeada8d run_pro2cmake.py: Run on Windows
Prefix by python executable and drop os.nice.

Change-Id: Idd1d0de6695887652db84261da1130a084e5af78
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-17 12:57:10 +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
Sona Kurazyan
ce8337dbeb Add Qt Coap to the library mapping
Task-number: QTBUG-78308
Change-Id: I6ba6f84354d7d008e128c784e24db00ecd67647a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-17 09:57:01 +00:00
Joerg Bornemann
bc4f17e7dc pro2cmake: Remove warning about line continuations
Almost every non-trivial .pro file has line continuations.
Remove the warning as there's nothing the user can do about it.

Change-Id: Ic8a54e5e5cc39a31267800edde4b0ff2b0276a48
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-17 08:59:05 +00:00
Leander Beernaert
4acb0b8582 Add expansion for $$files() in RESOURCES
Expand $$files() when processing resources.

Change-Id: I55a10dad65461db8640450609414fcfb0bb5d103
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-17 08:40:50 +00:00
Alexandru Croitor
59b940ff41 pro2cmake: Recursively expand $$FOO variables
Given HEADERS = $$PUBLIC_HEADERS $$PRIVATE_HEADERS
$$PUBLIC_HEADERS can be expanded into a list of source files
which in turn contain $$PWD/foo.cpp.
The $$PWD needs to be expanded as well.

This is the case for qtwebsockets/src/websockets/websockets.pro
project.

Change-Id: I3aa14203ee8d177fadd12a7e3212c3250970e0a8
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 12:48:13 +00:00
Alexandru Croitor
8489fe4ba4 Use posix paths in pro2cmake and configurejson2cmake even on Windows
Makes the conversions script usable on Windows.

Change-Id: Icb37f3ee8ae1c942556f524984ce3aed0d21cee0
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2019-09-11 08:50:23 +00:00
Alexandru Croitor
9d893641b9 Minor fix path handling when considering whether to convert project
We should use the new relative path to the project, instead of the old
specified on command line.

Change-Id: I54cb1cefd4df079a95c364b7c7c66c36941add01
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2019-09-11 08:50:15 +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
b0dbfc3094 Skip converting certain projects when they are passed to pro2cmake
Specifically skip cmake tests projects (because they are only needed
when Qt is built with qmake).
Also skip test qmake projects in qmake's test suite.
We might find more tests to skip in the future.

Change-Id: I4c3a42db669b31e81fd06206652371b6a70fd8ce
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-09 19:20:57 +00:00
Alexandru Croitor
e87677ad4f Try to detect if project given to pro2cmake is an example
If the project path starts with "examples/" relative to the repo
source directory (which is decided by location of .qmake.conf),
consider the given project file to be an example.

This makes the usage of run_pro2cmake.py easier, specifically by
being able to point it to a repo source directory, and getting most
project conversions correctly.

Change-Id: I93de98f8fc97af509c1f96cdebad3681190a53d1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-09 19:20:49 +00:00
Alexandru Croitor
3215f5457a Handle top level tests, examples and main qmake projects in pro2cmake
The script now detects whether the project file given is a:
- top level qmake project (qtdeclarative.pro)
- top level tests project (qtdeclarative/tests.pro)
- top level examples project (qtdeclarative/examples.pro)

This is done by finding the .qmake.conf file in parent directories of
the given project, and comparing the project's location to the
.qmake.conf location.

For the top level qmake project and the tests project, the script will
now use a predefined block of code that we usually had to copy paste and
change manually. Now only small bits will have to be adjusted manually
(project name and dependencies).

For the examples project, the content is surrounded by the required
build examples commands.

As a result, developers will have to worry less about knowing where to
copy paste from.

Change-Id: I4f751b371e74eeb86e070d58635c3d99b970ab18
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-09 19:20:38 +00:00
Ville Voutilainen
b2a11daaa1 cmake: Enable building of the oci plugin
Change-Id: I003d6da10c7e47402fb373d3956817817328cf0f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-05 08:24:07 +00:00
Ville Voutilainen
95c9c5a308 cmake: Enable building of the db2 plugin
Change-Id: I26810cccba5f3128cb47e0bf53b5ec78de2eec8c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-04 09:50:15 +00:00
Ville Voutilainen
3ff31ed020 Enable building of the mysql plugin
Change-Id: I8cb97afaaed46ee64b5a133e797179d7ddecdeef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-02 15:16:42 +00:00
Simon Hausmann
8da5305102 Fix Harfbuzz detection
We use

    qt_find_package(harfbuzz PROVIDED_TARGETS harfbuzz::harfbuzz)

which would set harfbuzz_FOUND. Since variable names are case-sensitive,
this is also the name we must check for in the qt feature condition.

Change-Id: I43420489c3310bc9c3e5cc798a005c8d5b0ab646
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-30 13:21:32 +00:00
Maurice Kalinowski
e5bf0290d9 Add Qt Mqtt to the library mapping
Change-Id: Ifa50161a579647002d3349b49da7012660c59f81
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 15:51:44 +00:00
Alexandru Croitor
0798ed8a83 Fix subdir handling in pro2cmake
Conditions scopes that had "else" were not handled properly.
The "else" condition should be expanded to its proper negative full
form.

Also every condition "piece" should be wrapped with parentheses before
being passed to sympy simplification, to be sure that boolean
operator precedence is applied properly.

Refactored the code a bit to make it easier to read.

Change-Id: I4726845b867f93c3afbc9362cdce1cd063ccff63
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-28 11:15:59 +00:00
Alexandru Croitor
c3ef1a012b Fix handling of more functions in handle_function_value
Essentially pass them through without failing the whole
conversion process.

Change-Id: I7bbd198203f79b45120a7254e2ecdf58e32f9525
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-28 11:15:44 +00:00
Alexandru Croitor
5c75f6a21a Fix some corner cases of condition mapping in pro2cmake
no-png is an old unused scope that should be mapped to the png
feature instead.

Map contains(QT_CONFIG, shared) to correct variable check.

Sympy doesn't like dashes in indentifiers, so replace all of them
with a _dash_ token which will be replaced again at the end
of the condition simplifying.

When doing sympy preprocessing, fix mapping of target names that
don't contain double colons.

Change-Id: Id3d37800665c96505b7cbb1d80fdbed59c3ae9c0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-28 11:15:32 +00:00
Alexandru Croitor
3416a83f05 Augment conversion scripts with requirements for qttools part 2
Designer components target names need to be prefixed with Qt.

Change-Id: I13037820b080d88cd670f2db97232509eb868daf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-28 11:15:24 +00:00
Alexandru Croitor
5a5dc6294b Augment conversion scripts with requirements for qttools
The libclang test is implemented as a custom FindWrapLibClang module.
The module does mostly the same things as the configure test in qmake
land.

Change-Id: I965f284baf7daef074e22f033047c35a917c8808
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-28 11:15:14 +00:00
Leander Beernaert
060784c981 Remove ../ from Targets
Remove repeating '../' pattern from target names, since we generate
the targets in the correct location with CMake.

Change-Id: I89d527a9ad717f742f8d0e5921f378e6ac0a229d
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-26 10:39:40 +00:00
Leander Beernaert
103d1aa910 Use GLOB_RECURSE for testdata
Use GLOB_RECURSE for testdata instead of globbing the top level folder.
Although RCC supports scanning directories, it will result in alias
collosions and test not being able to find the files on platforms
where test data is embedded into the binary.

Change-Id: I35d3d46a5d9fcafa5c8dc833eafdd0044ffe355f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-26 08:20:14 +00:00
Leander Beernaert
bf298499a0 Update public CMake macros' version
Update all public Qt macros to use qt6/QT6 instead of qt5/QT6.

Change-Id: Ib178f4fa21f37dfb8da7d4d8c097aa0e96c9d9f9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-23 10:04:30 +00:00
Alexandru Croitor
60ceb1b0c5 Handle contains(CONFIG, static) in pro2cmake
Change-Id: I36717688dd3b2ff0f6730bf3d65be421e391895f
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:26:42 +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
02074bf345 Fix more uses of functions in handle_function_value
Change-Id: Ie6b6f79b50e9eaf605427f19a8c2ca86050e2f74
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:26:07 +00:00
Leander Beernaert
f96faa95aa Update pro2cmake example generation to use QT5_ADD_RESOURCES
Update pro2cmake to generate CMake projects where resources are handled
via the QT5_ADD_RESOURCES command.

Change-Id: I66dc2174a45fc652fd8c9b7e3c0f46f58ae02c0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-23 07:52:19 +00:00
Leander Beernaert
3a105b9d11 Extend run_pro2cmake.py to pass --is-example to pro2cmake
Add command line argument to make run_pro2cmake invoke pro2cmake with
the --is-example option so we can convert examples in bulk.

Change-Id: I162eddffc509f16a97de5517698e8daca5207b74
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-23 07:06:48 +00:00
Alexandru Croitor
c7ec7cd2a1 Merge branch 'wip/qt6' into wip/cmake
Change-Id: I50ac36b8803c296998149e98cc61e38687cdd14b
2019-08-15 16:53:19 +02: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
Alexandru Croitor
87078650a5 Wrap resource file paths in quotes
This is required for paths that contain spaces, otherwise the .qrc
file generated by the build system is invalid, and the RCC run fails
at build time.

Change-Id: I887100b08052b49dd7ea4dd92b94f357a7d9d16e
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-12 12:41:14 +00:00
Leander Beernaert
e614e837fa Add QT_QML_DEBUG define conversion
Add QT_QML_DEBUG to target when we have qml_debug in qmake's CONFIG
variable.

Change-Id: I266c7313db12667498d4f770c73aec9e79c0b50e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-12 11:42:00 +00:00
Simon Hausmann
1720970102 Fix resource prefix calculation
tools/qml/qml.qrc uses prefix="something", which means that the leading
slash is implied.

Change-Id: Ia856fcef36873442a84b9162f1901cb31ca37b49
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 15:56:57 +00:00
Leander Beernaert
3549f51c98 Fix cases where DESTDIR equals ./ or ../
When DESTDIR has relative paths as a parameter we should prefix those
with ${CMAKE_CURRENT_BINARY_DIR} in order for them to be placed in
the correct location.

Change-Id: Ie9e9d656cbb54457bdf99425e3e1b05e09f20d7c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 14:12:49 +00:00
Simon Hausmann
1fc117e29d Add support for immediate resources
Collect files passed to RESOURCES and write out an add_qt_resources()
call. Similarly, for each "object" passed to RESOURCES (not a file),
write add_qt_resources(), too.

Change-Id: Idbb368ebb4d003a48e7c47ebaf53a78f65ebf9b9
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-09 12:28:24 +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
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
Leander Beernaert
5424c72ab6 Extend handling of special condtions
Extend the hanlding of special condtions outside single line statements.
Conditions such as 'qtHaveModule(gui):qtConfig(opengl(es1|es2)?)' would
not be handled properly.

Change-Id: I992f75311b82d84c574c9cb4ef6d7d648f425d81
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-08 13:11:00 +00:00
Leander Beernaert
5d7bb2e4f0 Add support for converting qtTargetLibrary() value assignments
Add support to pro2cmake to handle variable assignments via functions,
e.g: TARGET = $$qtTargetLibrary($$TARGET). The evalulation of the
functions happens during parsing and is very rudementary in nature.

Currently it only covers the qtTargetLibrary(), required for certain
projects, and quote(), required for passing unit tests.

If we run into any unhanlded function an exception will be thrown.

This patch also changes the TARGET property on Scope to expand the
value.

Change-Id: I678b7058067348a3972944bdba110f556cf22447
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-08 13:03:28 +00:00
Leander Beernaert
6396840182 Fix conversion of SUBDIR pro files not in current directory
This patch fixes the processing of pro files that do not reside in
the current directory. Before this patch statements such as SUBDIRS +=
Foo/Bar/z.pro would cause z.pro to be parsed in the current
CMakeLists.txt. What we want instead is a call to
add_subdirectory(Foo/Bar). Failing to do so leads to issues with
relative paths specified in z.pro being invalid.

Change-Id: I7bfa7837d54877e5340081d1c9aebe855cf6796d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-08 08:07:11 +00:00
Leander Beernaert
d8a7c0f40f Handle DESTDIR override
Set OUTPUT_DIRECTORY on a target when DESTDIR is specified.

Change-Id: I72061ae8156356fcb2aa9ba6cb87049fcef600c7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-07 13:47:51 +00:00
Leander Beernaert
f9db9a22e9 Handle qmake's CONFIG=plugin
In some tests in qtdeclarative we have projects that are built
as a lib with CONFIG=plugin. Without these changes they would be
translated to an add_qt_module call.

Change-Id: I208d31d43b087ed0b87eb4715f6c49b218fcc2c5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-07 12:34:59 +00:00
Alexandru Croitor
b4ef975a0a Handle conditions for SUBDIRS *more* correctly
There are project files that not only do SUBDIRS -= foo depending on
some condition, but also SUBDIRS += foo. To handle these cases
correctly we need to do a whole pass across all scopes and collect
all addition and subtraction conditions.

Once we have that information, we can compute a final condition for a
particular subdirectory. After we have the condition information for
all subdirectories, we can simplify all those conditions using SimPy,
and group all subdirectories that have the same simplified condition.

Finally we print out the subdirectories grouped by the simplified
condition.

The end result is similar to how we have extend_target() calls with
multiple sources grouped into a single conditional call, except in
this case it's subdirectories.

Amends b26b1455d7.

Change-Id: I5b648ac67264ba9a940561baee5b49c43c13b721
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-07 11:55:28 +00:00
Leander Beernaert
9ca1d79539 Fix regular expression for add_qml_module
Values such as Foo.2 would no longer be converted into Foo due to an
error in the regular expression.

Change-Id: I6a11d02662782094f5b264f86a930d9aaf002c77
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-06 13:27:20 +00:00