Commit Graph

387 Commits

Author SHA1 Message Date
Alexandru Croitor
846adfe079 Handle the new cmdline config feature in pro2cmake
cmdline implies console, so use that also to determine if a binary
should get a GUI flag.

Change-Id: I084e0a45785df96a7dc2c101af5305fbb39efbc3
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-20 09:23:14 +00:00
Alexandru Croitor
826821658d Workaround fix in pro2cmake Operation __init__ method
There are still call sites that call Operation.__init__ with a string
instead of a list. Restore the handling of such a case.

Amends 5fe8a38af3

Change-Id: I2a4d5c5cb5b460bf02b6da02d42d8cc8d5eb4192
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-20 09:18:56 +00:00
Alexandru Croitor
c454e622a1 Don't exclude QtCore from dependencies when generating modules
and plugins.

src/network/network.pro for instance depends on core-private, but
because we ignore adding QtCore as a public dependency, the exported
Config file for Network doesn't depend on QtCore anymore, so if a user
only links against Network, they won't automatically link against
Core.

Change-Id: I4a60ffae7e071927360b8ccf6b1b7479ab391060
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-20 09:15:31 +00:00
Alexandru Croitor
e0a6e9f3aa Fix parsing qmake assignments that have comments in between
For some reason the python comment regex that we used does not ignore
the line break at the end of a comment line.

This caused issues when parsing multi line assignments with comments
in between.

Use our own regex for comments to circumvent the issue. It was found
while trying to port the qtimageformats repo.

Added a pytest as well.

Change-Id: Ie4bbdac2d1e1c133bc787a995224d0bbd8238204
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-17 13:31:03 +00:00
Tobias Hunger
14bf7e952e CMake: Fix test_scope_handling
Adapt to updated APIs in pro2cmake.py

Change-Id: I39898b675e27d6295ef6cfa049c82b245d71188a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-17 13:26:29 +00:00
Tobias Hunger
5fe8a38af3 CMake: Fix test_operations
Fix test_operations and do some small mypy cleanups along the way

Change-Id: I6586b5d3491e5dcf44252c098516f0922fa60420
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-17 13:26:26 +00:00
Tobias Hunger
400f94109d CMake: Wrap DBus1 find_package call to fix xproto not being picked up
DBus1 (1.12) configuration file breaks PKG_CONFIG environment
variables and will thus prevent other libraries to be picked up
by pkgconfig. Main sympthom is that xproto is not getting picked
up anymore, which results in hundreds of lines of warnings about
this being printed.

Work around that by wrapping the call to find_package(DBus1) and
restoring the environment.

Change-Id: Ia69f10b014dddc32045b40972500a843e5d29b38
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-10 15:09:49 +00:00
Tobias Hunger
e9085f4162 CMake: pro2cmake.py: Add target_link_libraries to examples
Change-Id: Ic7054f0c88e228496b7f4855bffa5620ed717f9b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 13:14:45 +00:00
Tobias Hunger
35ed41e547 CMake: pro2cmake.py: Generate find_package information into examples
Change-Id: I6dab13ebea4386019f14be5f29a143d194268aac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 13:14:37 +00:00
Alexandru Croitor
bc4687f5bb Keep "special case" modifications when regenerating project files
The pro2cmake.py file is now smarter, and can reapply "special case"
modifications after regenerating a CMakeLists.txt file.

This substantially lowers the maintenance burden when regenerating
many files at once.

See the special_case_helper.py file for details on how it works.

Make sure to commit the generated .prev_CMakeLists.txt file alongside
your CMakeLists.txt changes.

To disable the preservation behavior, you can pass -s or
--skip-special-case-preservation to the script.

To keep around temporary files that are created during this process,
you can pass -k or --keep-temporary-files.

To get more debug output, pass --debug-special-case-preservation.

Fixes: QTBUG-75619
Change-Id: I6d8ba52ac5feb5020f31d47841203104c2a061d8
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-09 11:29:54 +00:00
Tobias Hunger
862ebbf7ea CMake: scripts: Extract code to write find_package lines
Extract code to write find_package lines from configurejson2cmake.py
and move this over into helper.py.

Change-Id: Iefd313b2a56cb78a99a7f3151c3f6c6284482f79
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 11:29:35 +00:00
Tobias Hunger
80e0c615a9 CMake: pro2cmake.py: Separate library extraction logic from writing out data
Separate the logic to find all used libraries from the code that writes out
the link_library information into the CMakeLists(.gen)?.txt files.

This patch will remove some "PUBLIC_LIBRARIES Qt::Core" from generated files.
This is due to us handling some Qt libraries in special ways in some of our
add_qt_* helpers. These special libraries were added to the LIBRARIES section,
but actually they should be added to the PUBLIC_LIBRARIES section instead. Do
so now, so that the newly generated files do not break things again.

Change-Id: I588781087a8aecc4d879e949735671d8085f0698
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 11:29:25 +00:00
Tobias Hunger
c4dd1a8fe3 CMake: pro2cmake.py: Extract writing lists into cmake files
Extract the actual functionality to write a list of "things" below
headers and/or cmake parameter and followed by a footer.

Reuse this functionality everywhere we write a list of things.

Change-Id: Ia7647be465b4788a2b1e6a5dbede1ca868f24ae2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 07:38:17 +00:00
Tobias Hunger
ee3d9a8b67 CMake: scripts: Fix mypy issues
Change-Id: I706740be79eccd6bf08213fdaf747dde08cd053a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 07:37:58 +00:00
Tobias Hunger
5608bf3cba CMake: pro2cmake.py: Add basic support for examples
Examples need to be built stand-alone and as part of Qt, so they
need a special CMakeLists.txt file that supports both use-cases.

Add an --is-example switch to pro2cmake to make it generate these special
CMakeLists.txt files.

This is basic support only and is currently still missing the necessary
find_package calls.

Change-Id: Ie770287350fb8a41e872cb0ea607923caa33073d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-09 07:37:42 +00:00
Tobias Hunger
0c498ef4ff CMake: pro2cmake.py: Do not fail when run from .pro-file directory
Change-Id: I285b05986e3a58efc060ca0b5732f6e3f5121476
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-08 11:25:58 +00:00
Alexandru Croitor
9d96c8da78 Fix freetype target not being found when using vcpkg
vcpkg and upstream CMake find module define different target names for
the same package. To circumvent this, create our own Wrap find module,
and link against it. Inside the find module, try both target names.

Change-Id: Iba488bce0fb410ddb83f6414244f86ad367de72b
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-08 10:54:15 +00:00
Alexandru Croitor
aed2c1f5ae Force pro2cmake.py to always change the dir to the converted pro file
Otherwise if you call the script from a different directory, path
handling becomes broken and certain files are not found.

Change-Id: Ia2f60abbd312a771330b3d5e928e1ccd0b4a845b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-07 17:08:28 +00:00
Tobias Hunger
5ec3baa67a CMake: scripts: Make xcb_qpa_lib known as a Qt module
Change-Id: I65f48d86c4ec946b38004b945078f29625e32d93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-07 14:45:22 +00:00
Tobias Hunger
d5018720db CMake: scripts: Treat libraries mapped to None as known
This detects doubleconversion as a 3rd party library.

This fixes defaulting QT_FEATURE_system_doubleconversion to 'ON'.

Change-Id: I9d18dbbb6f7a99f6a5c674bed3013b96f19bf6e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-07 14:41:31 +00:00
Tobias Hunger
9ffcc76188 CMake: Scripts: Fix double entries in 3rd party library mapping
Change-Id: I35f29876874d6083d19382800d194e417d57bca1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-06 14:29:20 +00:00
Tobias Hunger
059f4ade7f CMake: pro2cmake.py: Fix library mapping
Fix library substitution again which broke when I merged all the
library related pieces of information.

Keep Qt and 3rdparty libraries separate so that dbus does not get
mapped into Qt::DBus (or the other way around).

Make names in helper.py more consistent while at it.

Change-Id: I5e5bf02bdabf8bafe991c5701deca76bde4df2c3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-06 14:20:50 +00:00
Alexandru Croitor
6b2de61bf9 Make zlib a required package for QtCore
Change-Id: Ifbb969fafe05e355d6874d8bebe2e8f1e80510ff
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-03 14:16:23 +00:00
Tobias Hunger
7874ce7801 CMake: Improve mapping of libraries
Merge all data related to mapping libraries into one data structure
in helper.py.

Use that data for everything related to library mapping.

This change enables way more features now like e.g. adding find_package
calls into generated files.

Change-Id: Ibbd2a1063cbeb65277582d434a6a672d62fc170b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-03 13:42:25 +00:00
Tobias Hunger
9618434de5 CMake: configurejson2cmake: Do not generate useless OPTIONALs
Do not set properties of packages to type OPTIONAL. That is the default
anyway.

Update generator script and generated files.

Change-Id: I7a4d043b69c93ce8c2929a2e27ac6a07e4e6d8cc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-03 13:39:48 +00:00
Albert Astals Cid
64b31cafa1 cmake: Fix xcb_glx build
Use the actual cmake library target name

Change-Id: Icda1d232e3b920bf33ebceb00f39682050f7dedd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 08:13:56 +00:00
Alexandru Croitor
9b0b464e82 Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.

This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.

For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.

The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.

The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.

Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.

In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.

Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.

Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-02 07:30:42 +00:00
Alexandru Croitor
5668522413 Make freetype a required package
With qmake if we don't find a system package, we use the bundled one.
With CMake we don't provide a bundle freetype, hence it's required
to find a system one (or custom provided one).

Change-Id: I00a5e2ac55459957dae0729f89bafa792a102152
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-01 19:05:38 +00:00
Tobias Hunger
6630937e63 Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
2019-04-16 16:32:08 +02:00
Tobias Hunger
37ed6dae00 CMake: Map xkbcommon_support
Qt 5.12 comes with xkbcommon_support now. Map that accordingly.

Change-Id: Id10708349d377f6bdfed654428ebcef0b533bd69
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-04-12 14:06:07 +00:00
Tobias Hunger
ce809cab29 CMake: pro2cmake.py: Fix handling of libraries in QT
Change-Id: I5737a285ca0575a454e60fad231435d96b2f1be7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-12 11:35:18 +00:00
Tobias Hunger
95cdb0d1ae CMake: pro2cmake.py: Inherrit VPATH from parent scopes
Change-Id: I95b62fdf3a4cba674bef5a58f0d414464daa3b0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-12 11:35:09 +00:00
Tobias Hunger
2ec3f492a7 CMake: pro2cmake.py: Handle setting a key with $$key in the value
Change-Id: I86552ed2a30f07f8c6060b2bad04fd5489b1d482
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-12 11:35:01 +00:00
Tobias Hunger
8f0eb65579 CMake: Configurejson2cmake: Always enable system-pcre2 and handle dlopen
Handle dlopen properly. Code is ifdef-ed on it, so we need it:-/

Change-Id: I7f35d24b97530796a4cdcdc1acbe139757170215
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-04-12 11:33:39 +00:00
Tobias Hunger
92b0d7b911 CMake: Support /nolink libraries
Add a helper function to QtBuild that generates Foo_nolink versions
of Foo library targets.

Map 'Foo/nolink' libs found in qmake to Foo_nolink.

Automatically run helper function to create _nolink targets as
part of extend_target.

Change-Id: I4c23ea68b3037d23c9a31d4ac272a6bd0565f7c0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-10 09:36:40 +00:00
Allan Sandfeld Jensen
95f787bfdc Replace Q_DECL_NOTHROW with noexcept the remaining places
The first replacement had missed objective-C++ code some places ourside
the src dir.

In C-files Q_DECL_NOTHROW is replaced with Q_DECL_NOEXCEPT as we still
need to turn it off when compiled in C mode, but can get rid of the old
NOTHROW moniker.

Change-Id: I6370f57066679c5120d0265a69e7e378e09d4759
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-09 14:48:42 +00:00
Liang Qi
677a7a3066 CMake: Fix mappings in helper.py - WUIAS
This amends 9afc605eb5.

Change-Id: If246811d267d091c692875a1645c96767f781010
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-09 14:26:05 +00:00
Tobias Hunger
511124bf1d CMake: pro2cmake.py: Fix plugin type only prints first letter
Change-Id: Ib8989d2c13199d804d0c069903ca1c5eb61763e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-09 09:54:23 +00:00
Tobias Hunger
9afc605eb5 CMake: Fix mappings in helper.py
Some of the Qt names were wrong. Fix them and remove the work-arounds
in the library mappings.

Change-Id: I9b9afa3fb35c578e5c8d9cdef77224eb072ec8da
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:29:21 +00:00
Tobias Hunger
3bc9586e61 CMake: pro2cmake.py: Move defines from QMAKE_CXX_FLAGS into DEFINES
Change-Id: If3bfe715032b21dc046e63a79b0318a161d7a371
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:29:08 +00:00
Tobias Hunger
3cf92ab183 CMake: pro2cmake.py: Better separation between public and private libraries
Change-Id: I95a941ae92a77e049437d3cdd7d06eece11588f4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:28:58 +00:00
Tobias Hunger
8c28c85465 CMake: pro2cmake.py: Strip '-D' from compile options
Change-Id: I8239d36dc6af1b5eeded7f293dd6c151c10e289f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:28:44 +00:00
Tobias Hunger
9d83b54015 CMake: pro2cmake.py: Fix handling of file paths
This patch makes sure to store unchanged filenames as taken from qmake
into the scopes it creates.

The scopes are then kept longer: Merging/including scopes is handled by
adding the scope to a private _included_children member of the parent scope.

The methods to access data from scopes are then changed to take the
_included_children into account and a new "get_files" method is added,
that does all the necessary mapping to handle scope-dependent things like
$$PWD, etc.

This makes sure src/network is converted correctly incl. all the .pri-files it
includes as well as src/platformsupport/themes.pro. Both have been troublesome
before.

Change-Id: I28e92b7bcee1b91b248c17201c2729a54a3ce4a1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:28:30 +00:00
Tobias Hunger
52f676bf66 CMake: pro2cmake.py: Better representation of scopes as str
Include the current directory in the scope __repr__ output to make
it easier to understand where things wrt. include or file names go
wrong.

Change-Id: I09a6c17c6d8d547f1f64801bcde3c2e10c925ee1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:28:18 +00:00
Tobias Hunger
77a465ea2d CMake: pro2cmake.py: Better handling of debug features
Improve way that debug features are detected.

Change-Id: Ic0f0e74885e6d1e7f236c9efe4c77482ac212dbc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:28:08 +00:00
Tobias Hunger
9365a01531 CMake: pro2cmake.py: Fix typing information
Change-Id: Iaa6ea69c3c72eb1b626a976fcdb16243f15c609e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:27:59 +00:00
Tobias Hunger
81542ffb91 CMake: Map linuxaccessibility_supportPrivate to Qt::LASP
Change-Id: I6066f69c74c39fb97a286eb92748b5c4172b1efd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-09 07:27:48 +00:00
Alexandru Croitor
4f07e711c9 Add script to print out list of unconverted .pro files
Also prints some statistics.

Change-Id: Ieb55618c0d39604ca76d7a44390e61e02824a01f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-08 14:53:46 +00:00
Alexandru Croitor
547c7f8ca5 Fix architecture conditions
The actual variable that contains the architecture is
TEST_architecture_arch. TEST_architecture only contains the value
if the test was performed or not.

Fix the conversion script and all the generated files.

Change-Id: Icb3480832cab894948f4fef03b8bc8187cab6152
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-03 09:00:08 +00:00
Tobias Hunger
29f5c0ee70 CMake: Map cups to Cups::Cups, vulkan_support_private to Qt::VulkanSupportPrivate
Change-Id: Id03942becb08ca3ece589479ffe515f68034ddd4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-03 08:53:57 +00:00