Commit Graph

372 Commits

Author SHA1 Message Date
Frederik Gladhorn
f55565b77a Fix pro2cmake.py path replacement
I forgot to add .items() in ed35e1ac84.

Change-Id: Ic46134daffa8f1a1b5b59040c8bcca76d32dbb35
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-07 09:16:18 +00:00
Frederik Gladhorn
ed35e1ac84 CMake: clean up target.path and DESTDIR replacements
Change-Id: I0891008cff939aa98b39a28a23710add0781901e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-07 08:58:37 +00:00
Frederik Gladhorn
123ef6c391 CMake: allow $$[QT_INSTALL_PREFIX]
This is used in QtPurchasing.

Change-Id: I29c3a87d844eeaf3fd1b64057e33d64054f14a89
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-07 08:57:58 +00:00
Frederik Gladhorn
7bca6edc16 cmake: add tests in corelib/serialization
The DEFINES -= QT_NO_LINKED_LIST is no longer needed, so just remove it
from .pro and CMakeLists.txt.
Handle $$[QT_INSTALL_TESTS] and $$TARGET in target.path.
When we have DESTDIR set, do not use target.path for OUTPUT_DIRECTORY.

Fixes: QTBUG-78219
Change-Id: I5161a955b25ff2f3b35428dc4b935a7c9d2d425b
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-10-07 08:57:31 +00:00
Leander Beernaert
9e5e98047e Add expansion for QQC2_SOURCE_TREE
Test in QtQuickControls2 rely on this variable, which basically points
to the root of the project. We can't use PROJECT_SOURCE_DIR since it
will vary depending on whether we build tests as stanadlone or part
of the build.

Change-Id: Ic59a79af2b4b62611d6c32391c936e98e469dea0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-07 07:46:11 +00:00
Frederik Gladhorn
a98f64af91 cmake: add more tests in corelib/thread
This fixes the qatomicinteger magic by making $$basename work for one
particular case.

qthreadstorage still needs investigation.

Task-number: QTBUG-78221
Change-Id: I7bb38f6ca24273bcf0443ab25685c8e815814c3c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-04 06:27:19 +00:00
Mårten Nordheim
c718213548 Make SDL2 library-mapping use a wrapper
Since at least one system provides config files without an included
target.

Change-Id: If1f336aab4cec9704412349d7951849ee8c3dabb
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-03 10:45:58 +00:00
Alexandru Croitor
1b0710a393 pro2cmake: Handle SOURCES subtractions
SOURCES -= foo.cpp statements should now be handled correctly by the
script. The script uses the same principle as for subdir handling:
go through all scopes to collect source removals, and then generate
new scopes with total conditions that take into account both
additions and subtractions and their conditions.

Should handle NO_PCH_SOURCES case as well.

Tested on gui.pro, network.pro and qtconnectivity bluetooth.pro.

Change-Id: I0cc913ef64cecf09e8ada4e6a3ce3ccb4365b44e
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-10-01 14:16:14 +00:00
Alexandru Croitor
f23b7e1476 Implement persistent caching for simplify_condition
Store the results of simplify_condition in a json cache file,
next to the pro2cmake.py script.
Dramatically speeds up re-conversion of projects.

The cache is cleared whenever the content of the
condition_simplifier.py file changes, effectively presuming that the
condition computing code has changed.

Sample times.
Initial corelib.pro conversion - 142.13 seconds.
Next re-conversion with hot cache - 1.17 seconds.

Change-Id: I8790b2736358236e4b23bcb5f10f45a36fdfa426
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-01 14:14:16 +00:00
Alexandru Croitor
590213e531 Move sympy condition simplification code into separate file
Change-Id: I3f062bf939b452bb41b7a27508a83cbf93abff8c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-01 14:13:12 +00:00
Johan Klokkhammer Helsing
447c868a5d CMake: Generate wayland protocol code for examples as well
Task-number: QTBUG-78177
Change-Id: Id1c49013244e5ba51b99c1538b314181efe786fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-01 13:49:18 +00:00
Joerg Bornemann
3886828c1f pro2cmake: Add qtremoteobjects
Change-Id: I6cb2ee0c83e0dd3bf830a063f5790e35cbf73285
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-01 08:56:59 +00:00
Jean-Michaël Celerier
309f96ccb6 Add CMake support for directfb plug-in
Change-Id: I126545e1da54018ce081b42a29e62ca30ee04d64
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-30 11:31:54 +00:00
Alexandru Croitor
6f5b1dd9ab pro2cmake: Handle WINDOWS_SDK_VERSION and simplifications
Add custom code to handle WINDOWS_SDK_VERSION comparisons,
similar to how it was done for QT_GCC_MAJOR_VERSION.

Also fix simplify_condition to do mapping of conditions to unified
tokens, similar how it was done for target conditions, so that the
simplification process does not fail because of whitespace.

Change-Id: Ia0cec6e1ffeed4c7859bb2a44423d0160222f425
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-27 08:43:16 +00:00
Alexandru Croitor
316353b3e0 pro2cmake: Handle one more hardcoded condition CONFIG(osx)
We can't really handle this in a generic way now, because the values
of CONFIG() can not be directly mapped to features. It might be
possible in the future if we make sure that all configure.json entries
that have output publicConfig or privateConfig also generate a
feature. For now just hardcode the case.

Change-Id: Ie6b82b87973deb84012c3620b41920b343ffb2da
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-27 08:42:59 +00:00
Alexandru Croitor
7bed351c6c Fix run_pro2cmake only_qtbase_main_modules option
There was a missing f prefix for the f-string, and thus no
replacements were done.

Change-Id: If778d4ce25905c302de22a76c27af00a63f3c515
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-27 08:42:42 +00:00
Oliver Wolff
724281d1aa cmake: Add BlueZ to the list of libraries used by Qt (connectivity)
Task-number: QTBUG-78181
Change-Id: I4eda42c4e42ccb28ebb64eb060d02a33c3af6b03
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-25 12:08:54 +00:00
Johan Klokkhammer Helsing
eaf0b27091 CMake: Add missing library-mappings for QtWayland
I haven't checked if the config for wayland-kms actually works, as that
requires building for a target that supports it (RCar M3 or similar).

Task-number: QTBUG-78177
Change-Id: Ib30a63a4e5feb955d17763c37e32ad3f2c13d358
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-25 11:38:22 +00:00
Joerg Bornemann
4b592ba90c pro2cmake: Do not error out if $$files is called with a 2nd parameter
Do not stop the whole conversion if we encounter $$files(..., true).
Ignore the 2nd parameter for now.

Change-Id: If9334ce9719b98c33716dc7f18ba8aede05fe8b1
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-24 17:53:00 +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
Joerg Bornemann
c3131f9f5e pro2cmake: Fix call of write_statecharts for examples
Change-Id: I5417a20deda07b96499ac4f2707e7234b0f4eb7b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-24 11:45:02 +00:00
Alexandru Croitor
0441e3743e pro2cmake: Don't generate GUI applications for config.tests
On macOS the config.tests executable should not be a bundle,
and on Windows it should be a subsystem console application.

Change-Id: I2c8078cc9537df42683f3ff3bcce409402824555
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-24 09:57:19 +00:00
Alexandru Croitor
1d5e8996b0 configurejson2cmake: Generate label for out-of-line tests
Change-Id: Iaaf8d2f19269043dfad34d4ec32ec8163e9616e4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-24 09:57:10 +00:00
Alexandru Croitor
9f6e1abfdb pro2cmake: Skip requires "skip build" message for subdir projects
It makes too much noise when configuring.

Change-Id: I0a65cb99d0dc9a6c0d288cf548035cca1bea57bc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-24 09:56:51 +00:00
Johan Klokkhammer Helsing
0bcd50b40a pro2cmake.py: generate code for WAYLAND*SOURCES
WAYLANDCLIENTSOURCES and WAYLANDSERVERSOURCES is used heavily throughout
QtWayland.

Task-number: QTBUG-78177
Change-Id: I4507447054c435f78e82c2ca3e9404288db6c1f6
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-24 08:58:18 +00:00
Joerg Bornemann
8049ef3d4d cmake: Implement the ~= operator in pro2cmake
Change-Id: I3fadd0038d517d197cce898d10edd6ba452adea9
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-23 13:09:58 +00:00
Joerg Bornemann
6ff123be87 pro2cmake: Ignore generated .qrc files
...instead of complaining about non-existing files.

qtscxml/tests/auto/scion/scion.pro has
    RESOURCES = $$OUT_PWD/scion.qrc

Change-Id: I5737fe5078c87689152fc7fa0d8d25ddc2b1a00f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-23 11:23:29 +00:00
Alexandru Croitor
d8b18385e8 pro2cmake: Improve handling of requires clauses
Change the grammar to parse and extract the whole expression
that is present in the requires clause.

Make sure to preprocess the parsed content as a condition,
so that the value passed to map_condition and simplify_condition
is valid and the functions can handle more complicated conditions
like qtConfig() and if().

Wrap the final condition with an extra pair of parentheses, so that
the negated condition is computed correctly.

Handle the require clause in subdir projects, top level tests projects,
regular test projects, as well as top level repo projects.

Examples are not yet handled, because the would require some kind of
CMake public api to e.g. query if a feature is enabled.

Change-Id: I9af96cf022e47b66f24db3ca15d3803dda7a5d7c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-23 05:28:31 +00:00
Alexandru Croitor
303095e686 pro2cmake: Fix regexp for parsing env var expansion
The qmake syntax for env var expansion is "$$()".
The parantheses are not optional, so the optional "?"
modifiers should be removed.
This fixes the failing test_recursive_expansion pytest.

Amends c58df80cf7.

Change-Id: I5d7217555287ee7d96d6b38027964b1141af208a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-23 05:28:18 +00:00
Alexandru Croitor
5f856a6d0c pro2cmake: Handle if() conditions with pyparsing
Previously we used a regular expression that matched parentheses,
but the regexp didn't match the parantheses in a balanced way
if there was more than one pair.

Instead use a helper function that uses pyparsing to match
balanced parantheses, and removes the if keyword, leaving
just the nested expression.

Change-Id: Ie621e6a305e57aa411838288599366ccfba063cc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-23 05:28:05 +00:00
Alexandru Croitor
f0a22bd78d pro2cmake: Fix regressions introduced by reformat change
Sympy uses eval() inside its code, and that can raise an
AttributeError exception, so we have to catch that.
This happened when converting qml.pro in qtdeclarative.

Also the formatting change removed the raising of an exception
when an unhandled function was encountered in handle_function_value,
which caused not returning any value in such a case.
Instead just return the whole expression string, without checking
if the function is in some whitelist.
Also encountered in qml.pro.

Amends 91634c3c9b.

Change-Id: I47b73af1de0180becb9ef4fb78a8c35a04928d34
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-23 05:27:50 +00:00
Alexandru Croitor
1144c08be8 pro2cmake: Fix default mutable arguments usage
Change-Id: I91f2632f46539a1e5009b598625d78f61a051588
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:29:20 +00:00
Alexandru Croitor
6920acd894 pro2cmake: Small fixes and adjustments reported by flake8 and IDE
Change-Id: I13fd2f20414647b75c8da237857248808dddaa40
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:29:11 +00:00
Alexandru Croitor
d6bbf6944c Reformat python files using black
Change-Id: I0cc8ed89e2057b65f4fa34294eccffae642f2c73
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:29:01 +00:00
Alexandru Croitor
d71609610a pro2cmake: Handle generation of config.tests
Handle conversion of config.tests that are used as out-of-line tests
in configure.json.

The script should able to handle conversion of simple config tests
including nested scopes.
One thing that will probably be needed in the future is handling of
pkconfig which is used in qtwebengine config.tests.

There is also a hardcoded list of config tests which should not be
automatically converted by pro2cmake, either because they were hand
written, or because it doesn't make sense to convert them for now.

Incidentally, we should fix example conversion to also handle nested
scopes, similarly to how it's done for config.tests.

Change-Id: I862e67c4d19d5ed8cb7fc7c9f9aaf6e3d503aa03
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:27:30 +00:00
Alexandru Croitor
f35cc5090a configurejson2cmake: handle out-of-line config tests
Generate appropriate qt_config_compile_test() calls for config tests
that have CMake projects. These are protected by an if(EXISTS) check
so that configuration doesn't fail for repos where the config tests
have not been ported yet.

Adjust the qt_config_compile_test() function to use try_compile for
projects specified via new PROJECT_PATH argument.

Change-Id: I83c061e384f68688a654b782fd7a9bede282d1e3
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:27:22 +00:00
Alexandru Croitor
900df48122 Skip converting projects under tests/auto/installed_cmake
Change-Id: Id26320fb55f7f0ae4b18726b0794a4a1f169c80f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-21 15:48:52 +00:00
Cristian Maureira-Fredes
cfa3c64625 Adapt string formatting in util/cmake
Second and final batch of changes related to string
formatting styling.

Change-Id: Ifc0e999ee95fe52fd076ac2f001b4a58f82ab5be
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-21 15:48:40 +00:00
Joerg Bornemann
f771b8f6b1 cmake: Let pro2cmake use private statechart API for non-examples
Change-Id: If6206f2377e90ba7f8502029a1cc74856a2e03a1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-20 14:43:45 +00:00
Simon Hausmann
9fe82283c6 Add support for requires() statements in top-level .pro files
For example qtserialport has

    requires(!winrt)

and with this patch it gets translated to

    project(...)

    if(WINRT)
        return()
    endif()

    find_package(...)
    qt_build_repo(...)

Change-Id: Ic38b803b464037a42adc55930947f57c5efa7b45
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-09-20 14:10:58 +00:00
Simon Hausmann
9ef4ffb1a4 Add platform mapping for emscripten
EMSCRIPTEN is the name in cmake land as per emscripten's toolchain
file.

Change-Id: I11fa444204003f25f14fbf993ecf6766bf37d884
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-09-20 14:07:03 +00:00
Oliver Wolff
be3287d779 configurejson2cmake: Add special case handling for Windows BT config tests
Change-Id: Id73c44f5b7faff7392e7a8245e5e26e7dfe78cd8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-20 12:44:58 +00:00
Joerg Bornemann
bb8f8381c6 pro2cmake: Translate STATECHARTS to qt6_add_statecharts
Change-Id: I461768e67ce8fa7dae70a057df340e9c9a2bc14e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-20 11:35:25 +00:00
Tobias Hunger
d245ba48e7 CMake: pro2cmake: Do not mis-report used values as ignored
Do not mis-report "PLUGIN_TYPE", "PLUGIN_CLASS_NAME", "CLASS_NAME"
and "MODULE_PLUGIN_TYPES" as ignored.

The script evaluates these.

Change-Id: I26546a7eff61a20afe68168a865fe3ac99f66319
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-09-20 09:27:51 +00:00
Tobias Hunger
6cefa950e9 CMake: pro2cmake: Handle OBJECTIVE_HEADERS
Change-Id: I9a7b9c96530e8c922cf4aa5b6580e5579829db87
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-09-20 09:27:41 +00:00
Leander Beernaert
e619a387fb Extend globbing support in resources
Extend globbing support in resource in order to be able to handle
globbing expression present in qmake expression such as
RESOURCE.files = *.qml

Change-Id: I55a38c0bdc231a6a1ddbd65be7f57ca6f7dc2932
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-20 08:21:59 +00:00
Johan Klokkhammer Helsing
d6a491d607 CMake: Use FindWaylandScanner.cmake from extra-cmake-modules
Change-Id: Iaf78f215396671fc6f351ac20e686cfd2c39664f
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-20 07:28:32 +00:00
Cristián Maureira-Fredes
3b7aa8aee8 pro2cmake: skip tuple declaration on condition str
In some cases after cleaning and simplifying the conditions
you can end up with the following line:
    ((()))
Python interprets that as an empty tuple:
    >>> a = ((()))
    >>> a
    ()
and then the simplify_condition (sympy) method fails to continue
with an error:
      File ".../util/cmake/pro2cmake.py", line 1993, in simplify_condition
        condition_expr = simplify_logic(condition)
      File ".../sympy/logic/boolalg.py", line 2292, in simplify_logic
        expr = expr.xreplace(dict(zip(variables, s)))
    AttributeError: 'tuple' object has no attribute 'xreplace'

You can see this behavior with the file:
    qtmultimedia/tests/auto/unit/multimediaqml.pro

Change-Id: Ied4285b67f1e567660be49f6610311199bc48a22
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-20 06:38:56 +00:00
Cristián Maureira-Fredes
9bc3968aae pro2cmake: exclude 3rdparty libs from examples
There are some libraries inside examples that cannot be
properly translated due to the fact that the is_example
variable is True.
This condition excludes it, for example:
    qtmultimedia/examples/multimedia/spectrum/3rdparty/fftreal/

Change-Id: I68a1e7d1684ab4604f54b6d16bf88d04e3214ba9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-19 14:16:25 +00:00
Leander Beernaert
cd88c30ce3 Fix formatting for test data
Add missing f parameter and globbing expression.

Change-Id: I0eedb59e47537f9cf42a0b9d9471ddfc87ee48f2
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-09-19 14:06:38 +00:00