Commit Graph

381 Commits

Author SHA1 Message Date
Alexandru Croitor
c7fd10a022 Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.

Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.

Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
  Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
  have a .git subdir and thus defaults to be built in Release
  mode, even though qtbase might have been built in Debug, so to
  avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
  QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
  the tests project doesn't specify a major version, and if we
  override the values, the moc / uic targets don't get the correct
  major version prefix and configuration fails

Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 11:12:54 +00:00
Simon Hausmann
f8e4f94a14 Avoid accidental clash with .qrc files that are checked in
Add a prefix for generated .qrc files so for in-source builds we don't
end up overwriting htem.

Change-Id: I8eef582479eb45d67585f6aab87b288393bbadb5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-21 08:35:40 +00:00
Alexandru Croitor
140b65e36f Propagate QT_CMAKE_EXPORT_NAMESPACE via QtCore package
QT_CMAKE_EXPORT_NAMESPACE is used by the Qt packages to make features
available to the consuming CMake project. The value was moved to the
BuildInternals Config file, but that's wrong because consuming
applications not including the BuildInternals component would fail
to use any other Qt package.

Move QT_CMAKE_EXPORT_NAMESPACE to be propagated with QtCore package
again.

Amends 9542e78525.

Change-Id: I9841ac8c2828b00c0111d59e8976c889554e0ce1
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-17 11:10:44 +00:00
Alexandru Croitor
9542e78525 Use the qt_build_repo() macros for building qtbase as well
To implement this, create a new Qt5BuildInternals package.

All child Qt modules like qtsvg should use
find_package(Qt5BuildInternals) or
find_package(Qt5 COMPONENTS BuildInternals) in the their
top level CMakeLists.txt.
This will make the qt_build_repo() macros available.

For qtbase we slightly cheat, and specify a CMAKE_PREFIX_PATH
pointing to the source folder that contains the BuildInternals
package.

For the other modules we actually use a configured and installed
package Config file.

This change moves variables that used to be written into the
QtCore Config file into the BuildInternals package. This way
things that are relevant only for building additional Qt modules
does not pollute the QtCore package.

Task-number: QTBUG-75580
Change-Id: I5479adff2f7903c9c2862d28c05c7f485ce3e4eb
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-15 17:33:51 +00:00
Alexandru Croitor
c097256ee4 Encapsulate commands for building other repos into two macros
Currently to build qtsvg we have some copy-pasted code to set up
the paths for QtSetup and QtPostProcess to be found.

To make it cleaner, introduce two new macros called
qt_build_repo_begin and qt_build_repo_end(). The first one
should be called in a child repo like qtsvg, right after
a find_package(Qt5) call, and the second one at the end of the
repo top-level CMakeLists.txt file.

In order for the macros to work, extract some of the variables
which were set in Qt5Config into Qt5CoreConfig instead. This
makes sure that it works also for find_package(Qt5Core) calls.

Task-number: QTBUG-75580
Change-Id: I85267c6bd86f9291ec2e170fddab1006ab684b5c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-15 11:40:03 +00:00
Alexandru Croitor
02a015375a Implement developer / non-prefix builds
A non-prefix build is a build where you don't have to run
make install.

To do a non-prefix build, pass -DFEATURE_developer_build=ON when
invoking CMake on qtbase. Note that this of course also enables
developer build features (private tests, etc).

When doing a non-prefix build, the CMAKE_INSTALL_PREFIX cache variable
will point to the qtbase build directory.

Tests can be run without installing Qt (QPA plugins are picked up from
the build dir).

This patch stops installation of any files by forcing the
make "install" target be a no-op.

When invoking cmake on the qtsvg module (or any other module),
the CMAKE_INSTALL_PREFIX variable should be set to the qtbase build
directory.

The developer-build feature is propagated via the QtCore Config file,
so that when building other modules, you don't have to specify it
on the command line again.

As a result of the change, all libraries, plugins, tools, include dirs,
CMake Config files, CMake Targets files, Macro files, etc,
will be placed in the qtbase build directory, mimicking the file layout
of an installed Qt file layout.

Only examples and tests are kept in the separate module build
directories, which is equivalent to how qmake does it.

The following global variables contain paths for the
appropriate prefix or non prefix builds:
QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR,
QT_CONFIG_INSTALL_DIR. These should be used by developers
when deciding where files should be placed.

All usages of install() are replaced by qt_install(), which has some
additional logic on how to handle associationg of CMake targets to
export names.

When installing files, some consideration should be taken if
qt_copy_or_install() needs to be used instead of qt_install(),
which takes care of copying files from the source dir to the build dir
when doing non-prefix builds.

Tested with qtbase and qtsvg, developer builds, non-developer builds
and static developer builds on Windows, Linux and macOS.

Task-number: QTBUG-75581
Change-Id: I0ed27fb6467662dd24fb23aee6b95dd2c9c4061f
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-15 11:31:31 +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
Cristian Adam
1a92808a78 Add support for MinGW
Tested with MinGW 7.3.0 64 from Qt 5.12 installation.
The CMake 3rd party libraries I used from hunter project (with some
package, and target names changes)

Change-Id: Ie89555a6cd8bdb7182f9b2dd2c3c39784c523ead
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-04 20:56:17 +00:00
Alexandru Croitor
a907d7df34 Handle generating find_dependency() calls for nolink targets
Previously we just recorded that Gui has to link against
Vulkan::Vulkan_nolink, but if an application consumed Gui, it wouldn't
find that target.

We need to record that if a module links against Vulkan_nolink, and
then generate a find_dependency(Vulkan) call in the module config
file.

We also have to assign the _nolink interface library to an export
(the Qt5 one), so that it gets installed as a target.

Change-Id: Icbc29ff4161ab18fdd162196ae128e29c1ee8c80
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 13:51:13 +00:00
Kevin Funk
aef11e420d cmake: Generate config files with Qt:: prefix
Generate CMake config files which export Qt targets with a Qt:: prefix
(i.e. without a major version suffix in the namespace)

Change-Id: Ia07f98be6d0e24c196e3880b7469f1f0c6232c06
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 13:51:02 +00:00
Kevin Funk
d8cdbc4f97 cmake: Make add_qt_executable work
Also needs the include/ from the top-level binary dir added to the
include path.

Change-Id: I7e0d82a2ee24d9bf9ffe9da5fd02b3b223fd48e7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 12:49:37 +00:00
Jean-Michaël Celerier
753d35cd56 cmake: move dependencies accumulation in QtPostProcess.cmake
This is needed because dependencies added after add_qt_module with extend_target
are currently not taken into account.

Task-number: QTBUG-75538
Change-Id: I2c72207fb88b2480e41a2c8550978fb194275617
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 12:42:43 +00:00
Simon Hausmann
914b367c7f Fix finding host tools when cross-compiling
* When using a sysroot, just setting CMAKE_PREFIX_PATH to the
  QT_HOST_PATH is not sufficient in finding for example Qt5CoreTools
  because the QT_HOST_PATH would be prefixed by the sysroot. So this
  patch switches the mode to also enable looking outside of the sysroot.
  (done by Alexandru)

* Once the Qt5CoreToolsConfigVersion.cmake was found, the built-in check
  for 32 vs. 64 bit compatibility by looking at the provided
  CMAKE_SIZEOF_VOID_P (4 when target is armv7 for example) and comparing
  it against the void* size used when building the tools would fail.
  Explicitly unsetting CMAKE_SIZEOF_VOID_P disables this check, and
  that's fine as we're not interested in any exported library targets --
  where this could cause problems -- but merely programs to run.

Change-Id: If2931dad023e39a3dbdaa17ac095131ad2c0ca60
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 12:14:22 +00:00
Jean-Michaël Celerier
db5f99f451 cmake: make the qt_find_package PROVIDED_TARGETS optional
This is because some FindPackage may produce some targets only on some
platforms - e.g. qt_find_package(OpenGL) needs to define
the provided target OpenGL::GLX which will only exist on linux but
is required by various CMakeLists.txt files.

Change-Id: I74515470f5d56c246f489df74901ad4223a92a70
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-03 08:11:19 +00:00
Jean-Michaël Celerier
1b36fe53c6 cmake: export locally-built dependencies in static build
Change-Id: Ifbcedd32cef3b9c8b4b8c9ca0d229850f696f406
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-02 11:41:55 +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
42d3b21c92 Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.

Third party projects that require just these tools, and not the Qt
modules themselves,  should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.

It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.

Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.

This commit also changes the behavior regarding when to build tools
while building Qt itself.

When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.

When not cross compiling, tools added by add_qt_tool are built from
source.

When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.

Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.

Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr  -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools

Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-02 07:30:30 +00:00
Alexandru Croitor
f38ebcbe32 Fix add_qt_tool to properly propagate NO_QT option
Otherwise add_qt_executable will still link against Core,
and thus building qmake in a static build will fail.

Amends a1752276e0

Change-Id: Iebbdf9d0a2808a9eaeffdf8fbdb44ff5e2920f3b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-29 15:26:54 +00:00
Tobias Hunger
a1752276e0 CMake: Do not link qmake against Qt (not even the bootstrap one)
Qmake should not rebuild all the code in QtCore, but currently it does.
When linking against QtCore, all the symbols get duplicated. A clever
linker will "deduplicate" the symbols again, so this actually works
with shared Qt builds, but it fails for static builds.

Do not rely on the linker being clever and just do not link Qt at all
for qmake.

Change-Id: I0f79ed9176a19ee884dd425e5f23c26cf69dc422
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-29 12:05:06 +00:00
Alexandru Croitor
d0d63aa260 Append syncqt header include dir when building plugins
Change-Id: I899d4562155fbc82cfd13979b424d751095a381b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-26 14:02:13 +00:00
Alexandru Croitor
5fd882803e Fix dbusxml2cpp custom command invocation
Use absolute paths for source files, and relative paths plus a correct
working directory for output files.

This is required to work around a limitation of the dbusxml2cpp tool
where it splits a command line option on a colon ":". Windows paths
contain colons, and that breaks the internal logic of the tool when
passing absolute paths.

Change-Id: Ic653f1317ae4f68bb2f488c117fe48c34310c76e
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-16 14:40:25 +00:00
Alexandru Croitor
51b7fbb626 Work around issue of missing Windows qtmain static library
Applications that have the WIN32_EXECUTABLE property set,
must have a WinMain function. In qmake's case, this function
is provided by the qtmain static library.

Until that is implemented in CMake land, disable the property on
Windows for all qt executables. This fixes the linker issues while
building examples.

Task-number: QTBUG-75195
Change-Id: I323d4dd899f716cd6b9b7f4b5ecb76b22f462fc4
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-16 14:40:12 +00:00
Tobias Hunger
859b36ca14 CMake: Use imported target to create _nolink targets
Use an imported target to create _nolink targets. This gets rid of
the need to have an helper target that gets aliases to get work
around the problem of the original target might having a "::" in
its name.

Change-Id: I4618980cf2c673ebf5caca593bccf122b3c81480
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-11 15:07:14 +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
Alexandru Croitor
f896a5019a Stop installing test helpers
Tests and their helpers should only be used in the build directory.

Change-Id: I5aa9fcf734b6b3667f91df7c84d083f944c452c9
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-08 14:53:35 +00:00
Albert Astals Cid
067d5dc027 cmake: Run tests from their build dir
It's what the qmake build does

Change-Id: I99663735859941b56c2211898908d61bc6c4b48f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-05 15:57:20 +00:00
Albert Astals Cid
9947909bfa cmake: Put the test helpers binaries in their parent folder
Makes qtextcodec test succeed

Like qmake does

qt_test_helper.prf says
"
If an auto test needs a helper application, this helper should
be put into the same directory as the test itself.
"

Change-Id: I02cb36d2237cdb72912c943250b843c33ffcd64a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-04-04 14:12:03 +00:00
Alexandru Croitor
bb04a85bdf Stop installing unnecessary things
This includes:
- tests
- tools that are only used duing the Qt build (tracegen and
  qfloat16-tables)

Change-Id: I3a5f678682b5b9318012568a9e4dcdda0967f89b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-03 11:08:57 +00:00
Alexandru Croitor
8fa9a987ea Install test executables into $prefix/tests instead of $prefix/bin
The install path takes into account the path structure of the source
directory, so that not all tests are bunched up into /tests, but
rather /tests/auto/foo/bar.

Change-Id: I5e32d2e41ae8f095f4eac6654973508efd598df0
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-03-27 16:58:44 +00:00
Tobias Hunger
7406c124cb CMake: Set QT_STATICPLUGIN for static plugins
Change-Id: I5439935b5db2babd47cdc85647e464fe845279cf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-27 14:35:56 +00:00
Tobias Hunger
72404ef3e1 CMake: allow custom plugin output/install directories
Only require TYPE if no OUTPUT_DIRECTORY, ARCHIVE_INSTALL_DIRECTORY
and INSTALL_DIRECTORY is provided.

Change-Id: I6db1cfaa576bfa3ee3dc8ecf81db20e3afcd61e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-27 14:35:46 +00:00
Alexandru Croitor
890ddd2540 Fix AUTOMOC and friends to run only once the tools are built
While building on macOS, AUTOMOC sometimes hanged indefinitely.
The problem was that AUTOMOC was executed for the qmacstyle
plugin before moc was actually built.

Because of an upstream bug in CMake, AUTOMOC was caught in a deadlock
without reporting that spawning the moc process failed. Specifically
if a libuv spawn() call failed, the condition variable for a waiting
thread was not notified, and the thread kept waiting forever for the
process launch to finish.

Fix the dependency by setting the AUTOGEN_TARGET_DEPENDS property
on all targets that have AUTOGEN tools enabled. This makes sure that
moc and friends are built before they are used.

Also add some special cases to disable autogen tools on certain targets
to break cycles between targets.

Fixes: QTBUG-74636
Change-Id: I6e689e63cba1962525f169f332a58498d173c0a6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2019-03-22 14:40:48 +00:00
Tobias Hunger
dedc645510 CMake: Make add_qt_executable link to Qt::Core by default
Make add_qt_executable link to Qt::Core by default. Add a BOOTSTRAP
flag to disable this behavior again.

Pass BOOTSTRAP on from add_qt_tool to add_qt_executable.

Change-Id: I26e7f1e03254122f626b3765cccc0dc4414a4fc0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-20 12:29:50 +00:00
Tobias Hunger
485e96c4ee CMake: Handle INSTALL_DIRECTORY for qt_executables
Allow to override the install directory for Qt executables.

Change-Id: I9561976eefe9c7b573bb97ddaaa39e30d3b6d9fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-20 11:55:19 +00:00
Tobias Hunger
74aa6abac6 CMake: Fix names for generated DBus adaptor/interface files
Use the same names for DBus adaptor/interface files that are also
used by qmake. E.g. io.qt.something.xml will be turned into
something_interface.(cpp|h) or something_adaptor.(cpp|h).

Change-Id: I799b8aee7addd1fe590e8f3ec078e5325b68d5b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-20 10:44:19 +00:00
Tobias Hunger
b173f0b905 CMake: Treat OUTPUT_DIRECTORY as relative to top level build directory
Treat a relative path in OUTPUT_DIRECTORY as relative to the top level
build directory, not to the current build directory.

Change-Id: I4d409d1362a8f73d13b93cf5ab98e82e60dd62cb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-20 10:38:32 +00:00
Alexandru Croitor
a9af99c926 Add windows platform plugin and its requirements
- executed pro2cmake script on windows qpa plugin
- added windowsuiautomation platformsupport project
- fixed plugin dlls and lib files to be written to the same path
- fixed an issue comErrorString which used implicit casting
  from QString to char*, but plugins are currently built
  with QT_NO_CAST_TO_ASCII

Task-number: QTBUG-74140
Change-Id: I5db3b6c5264bbd5dfba2998b049fda36eb312c70
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-18 15:35:07 +00:00
Alexandru Croitor
3f03917b54 Fix Windows build
- Fix qmake build
- Fix QtNetwork moc-ing, by including the moc files
  inside the cpp files
- Fix sql odbc plugin by including QT_PLUGIN define
- Fix Boostrap to link against the Platform target, to get the
  correct Unicode and WIN64 defines.
- Fix vulkan headers to be found
- Fix freetype bzip and png unresolved symbols / linker issues
  when building minimal platform plugin (also need to make
  sure to use the vcpkg toolchain instead of CMAKE_PREFIX_PATH
  because then find_package is overridden, which does magic
  to properly propagate static library dependencies).
- Fix qfilesystementry test not to be built without private
  tests feature (it led to undefined symbols issues).
- Make sure to remove QT_NO_CAST_TO_ASCII define when building
  QtCore, so that the qstringbuilder3 test builds
  successfully.

Task-number: QTBUG-74140
Change-Id: I353d08392b604d55f8e62cdd8696d1e19a3c084a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-18 15:34:52 +00:00
Tobias Hunger
6e16f127ad CMake: pro2cmake.py: Handle SIMD sources
Change-Id: Ib445888e769432e8c247ae2d2fb5d8af2d5cd275
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-18 11:37:47 +00:00
Tobias Hunger
becbe4df3a Improve add_qt_resource function
* Handle BASE to give the directory files will be relative to.
* Support lang="foo" for qresource sections.

Change-Id: I36087220d03789a97105dc6dd1aca7a25a063d9f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-11 09:14:33 +00:00
Mikhail Svetkin
25ee3d1c3b cmake: Fix moc on macOS
moc does not generate moc_defs.h and that's why moc does not understand
that he runs on macOS.
It happens because cmake can not find Qt version.

Change-Id: I34c51ebb69dc1ff782a0f129e114cda819122805
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-06 13:17:48 +00:00
Tobias Hunger
e1de70933e CMake: Handle gc-sections linker flags
Add a function to set gc-sections flags on the linker.

Change-Id: I9ac02364836d2aa8de239adb8d3a5d29659a4007
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-04 15:37:48 +00:00
Alexandru Croitor
58bd86443c Fix usage of linker -no-undefined flag for macOS
Change-Id: I41c55871a8db3d860fc20ad17eb9a97b01d62448
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-02-27 16:11:43 +00:00
Simon Hausmann
c604a1265a Fix use of uic when cross-compiling
Don't try to build uic but instead import it. This is done centrally now
in add_qt_tool.

Change-Id: I241fbb924de68549e9c0320e157351bd7b1bf5c3
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2019-02-19 08:45:35 +00:00
Kevin Funk
cf7426e8c9 cmake: Make sure to finddeps of private target
Public interface libraries of the private target need to be first looked
up via `find_dependency(...)` in the CMake config files as well.

This patch is just changing the foreach() loop and defer the package
config file generation.

Change-Id: Iecaf7f778379b526f12ac6a42e76d714d9349b2c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-14 07:39:21 +00:00
Kevin Funk
0896e203d6 cmake: Make sure QT_SYNCQT is persisted
Lifetime of the variable is bound to the function body. Use a CACHE
variable to escape it (and to speed up future calls to the function).

Change-Id: I2d164a1c94e64cc652e65c1eea0522f3d911ad82
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-14 07:38:50 +00:00
Kevin Funk
b2337e1d00 cmake: Make sure QtModuleConfig.cmake.in is found
... when QtBuild.cmake is being included from another Qt module

Change-Id: Ia55e03422cc84a56dd9eac640621e5b2ee9681bd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-14 07:38:47 +00:00
Kevin Funk
f0d6fd6b95 cmake: Also use -Wl,--no-undefined for Clang
Change-Id: Ida6bf41e496a0e800f1146d15edf192d0635a3c9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-13 11:48:02 +00:00
Simon Hausmann
96c0dc07a7 Use rpath by default not only for building but also installed binaries
This makes it possible to use the binaries out of the box. This is
particularly relevant for program binaries that link against QtCore
dynamically, when trying to use these binaries during cross-compilation.

Change-Id: I7dee93194be3fff5c6e3bbb9e202e4cf5e19b6d0
Reviewed-by: Volker Krause <volker.krause@kdab.com>
2019-02-13 08:59:49 +00:00
Simon Hausmann
1f96506748 Fix build without Vulkan
The syncqt generated headers are optional, i.e. their source may not
exist -- so for now make their installation optional (as it seems to
have been the case with qmake).

Change-Id: Ieaeb3d13a1d8ff1f158b5b1c918750fec48d3bef
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2019-02-12 15:33:06 +00:00
Kevin Funk
988162eaf8 cmake: Start to use ConfigExtra.cmake files
Enables the use of e.g. QT_NO_DEBUG in compiler flags, -fPIC, passing on of
QT_NAMESPACE, etc. pp.

Dropping a lot of custom code which handled adding imported targets for
the command-line tools (this is all being handled by CMake already).

It needs to be investigated if we need to resurrect
Qt5GuiConfigExtras.cmake.in in one way or the other.

Change-Id: I4fa141b68fddaad4f33e628c59d5d0b3a7b3a096
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-12 13:37:08 +00:00
Jean-Michaël Celerier
bb2ae3e409 cmake: replace unused macro with a proper value
Change-Id: Icc2b5a63fc503aa99bbb0c8ee9ffddc985e0e3da
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-12 11:28:08 +00:00
Kevin Funk
4bfd6c010b cmake: Create Qt5 compat targets in config files
For now create targets a la "Qt5::Core" to stay compatible with the
current Qt5 naming scheme. The name is controllable via a CMake option.

Change-Id: If43c058221949b1900c2093f39ccc9d0f38028f1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-12 11:09:03 +00:00
Kevin Funk
b3560a66ae cmake: Set up VERSION/SOVERSION properly
Change-Id: Ic8cddf5ec8182873a6b1e03c76f514284b423322
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-12 11:08:28 +00:00
Kevin Funk
c5e2838b64 cmake: Make find_package(Qt5 ...) work properly
Introduce a new cached variable INSTALL_CMAKE_NAMESPACE for defining the
prefix used for CMake config files (c.f. "${PREFIX}Core/${PREFIX}CoreConfig.cmake")

Also make sure to `find_dependency(...)` the required packages inside
the individual CMake config files. I.e. in Qt5WidgetsConfig.cmake,
search for Qt5Core, etc. pp..

Change-Id: Idc027925fe9d5323091c4853803ad5ce44b1afc6
Reviewed-by: Jean-Michaël Celerier <jean-michael.celerier@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-02-11 17:13:51 +00:00
Kevin Funk
082a7c4655 cmake: Parse SYNCQT.INJECTIONS
Allows to install headers such as QtCore/qtconfig.h,
QtGui/qvulkanfunctions.h, etc.

Change-Id: I93f384cdc8bbee07fab316d7e232aae1d209f33e
Reviewed-by: Jean-Michaël Celerier <jean-michael.celerier@kdab.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-11 16:51:27 +00:00
Tobias Hunger
3e36bcdca0 CMake: Introduce QT_HAS_NAMESPACE
This makes testing for Qt with namespace builds easier in extend_target.

Change-Id: I58ab985a2ed39859fb65d35f8f69065fed2a5c9b
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-31 13:57:33 +00:00
Tobias Hunger
06e8dd31e9 CMake: Add debugging support for extend_target(...) calls
Enable a flag so that cmake documents which extend_target calls it
acts upon and which ones are skipped.

Change-Id: I1e2d4da47b93d6b5d7b7ec25b7bc6341f38b3dca
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-01-31 10:33:52 +00:00
Tobias Hunger
210762ae46 CMake: pro2cmake.py: Pass QMAKE_MOC_OPTIONS on to CMake
Change-Id: I39c1b0aedbffaa29a34253e0c1c4bb4a4dddbe98
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-01-31 10:02:40 +00:00
Tobias Hunger
4d4bf61f9f CMake: pro2cmake.py: Convert more settings from .pro-file to CMake
Convert QMAKE_USE, QMAKE_CXX_FLAGS and QMAKE_LFLAGS into CMake.

Change-Id: I53a5b91664b6ab71892d4381c00f8d744d7d7abd
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-01-31 10:02:24 +00:00
Albert Astals Cid
e2dc030ac0 cmake: test: Enable the build of qdbusabstractinterface
Since the code wants pinger_interface.h as include
name and the qt_create_qdbusxml2cpp_command function was
using the filename as source for the next filename i introduced
a new option DBUS_ADAPTOR_BASENAME/DBUS_INTERFACE_BASENAME to set the
name of the resulting file

Change-Id: I582d578b68275e4530e91a88631ae43fd1ae06fd
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-01-30 16:15:08 +00:00
Tobias Hunger
6a1ee4de07 CMake: Store Qt features in CMake Cache
This is less self-contained than what we have, but significantly speeds
up cmake configure/generate runs.

This patch also warns when a feature is already defined.

Change-Id: I8cab63e208ba98756b47d362a39b462f5ec55e20
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-17 16:16:55 +00:00
Tobias Hunger
4f26758978 CMake: Introduce Qt::GlobalConfig to hold the global features
This simplifies the handling of features a bit as it removes the special
code to store two sets of features in Qt::Core.

Change-Id: I536d41cfc76a02af054e3cfbad6bda50b1e9e49a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-17 08:33:27 +00:00
Tobias Hunger
e57a94cbd8 CMake: Use AUTOMOC/AUTOUIC/AUTORCC
Change-Id: I0235ca4f227623e5937348b4b010637921dbf154
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-12-14 14:04:59 +00:00
Tobias Hunger
42d6e5c5fa CMake: Simplify
* Only import features once
* Move Core specific code into its CMakeLists.txt file
* More consistently use target names like "Core" to
  refer to "Qt modules". We tend to require either "Core"
  or "QtCore" in places, which I find confusing.

Change-Id: Id54161bc5468412750cb9eb7eeb15de3812e8a09
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-12-14 14:00:21 +00:00
Tobias Hunger
3a8d8344e5 CMake: Merge qt_internal_module_include_dir and qt_internal_module_info
... and fix the fallout of this change. It results in more targets being
passed overall (instead of a strange mix of targets and module names),
so this is a good thing(TM).

Change-Id: I1c4326b80e2c6675356587879ec8471ef7249a50
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-12-14 14:00:11 +00:00
Tobias Hunger
ece38e7e18 CMake: Unify creation of target aliases
For Qt6 we want to have Qt6::foo and Qt::foo. Enable that consistently.

Change-Id: I3cf05c4171b13029bf508d307945e8be4687e86b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2018-12-14 14:00:02 +00:00
Tobias Hunger
78d34c3a30 CMake: Refactor qt module name related code
Change-Id: Ib14c030ef6d2e988aaaebca354cf1a6881e05e25
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2018-12-14 11:43:00 +00:00
Tobias Hunger
8d5c9ebf8c Prefer qt_internal_ over _qt_ for internal functions
Change-Id: Idb6f3d8f29890bb4d8f0d1d644c0d1103342946a
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2018-12-14 08:44:02 +00:00
Tobias Hunger
c22dcf6ae1 CMake: Unify on variable names without _ in functions
Change-Id: I28883775d8f9bd718de477c03628b291972f4590
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2018-12-14 08:37:22 +00:00
Tobias Hunger
a2da0175cd CMake: Do less feature-pushing
Do not try to push features up into the parent scope if none were added.

This avoids a lot of iterations over all defined variables.

Change-Id: Idb9a4c86643c0ca773584a05b3a0590cfab7514d
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 15:20:59 +00:00
Tobias Hunger
74e9278553 CMake: Simplify registration of known Qt targets
Change-Id: Ibd7b5f628c0a1a3087bdfebb0c35242b42c5e938
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 15:20:42 +00:00
Tobias Hunger
24fe921161 CMake: Add simple test for moc handling and fix the implementation
Add a simple test for moc-file handling and fix the implementation
to make the test pass.

Change-Id: I34e8d65a5e01a6f557d3a3d8cb262fd147ad78e4
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 15:20:17 +00:00
Tobias Hunger
13e1c93e37 CMake: Add test for QRC and make it pass
Add a test for QRC file handling in cmake and fix the qrc file handling
to handle qrc files in subfolders properly.

Change-Id: Iff4224e59e7ee1badacce5fc00dbf68aef69bffe
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 15:19:41 +00:00
Tobias Hunger
f4dc3dcacb CMake: Add test for uic handling
Add a test for uic handling and make it pass.

Change-Id: I7e11f9f1fba0e40c748e3590a0d0cbb72c9ebc28
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 15:19:22 +00:00
Tobias Hunger
bdb5e2a48e CMake: Simplify qt_make_output_file
Simplify qt_make_output_file and add a simple test for it.

Change-Id: I87694291cd877545ade5d9c42d1424d7b3b7b567
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 10:38:04 +00:00
Mikhail Svetkin
1dd5acf9aa CMake: Fix import of features while generating CMakeLists
extend_target does not import public and private features.
For example:
Qt::CorePrivate matches as ('CorePrivate'), but it should be ('Core', 'Private')

Change-Id: I99144d42b7e0a8f7c4501d3e0eaf04b270c6b4d6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-11-06 14:32:48 +00:00
Tobias Hunger
cda5d06bd8 CMake: Fix import of features
Make sure the features of Qt libraries are available when linking to that
library via the add_qt_* functions.

This was broken for any library that did not end with "Privat" or
"Private".

Change-Id: Iff0ad441b601e0d131b0e30f2069110806410297
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-11-05 15:44:43 +00:00
Tobias Hunger
b7b4af575f CMake: Simplify Feature handling
Simplify the scope handling of features by providing a function that
just pushes all QT_FEATURES into the parent scope. Use it.

Change-Id: Ic6552fe495394d73fcec6becf6852745ec2d6d59
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-05 15:01:58 +00:00
Tobias Hunger
b5aaea7998 Support dbus adaptors and interfaces
Change-Id: I06ffff19574bbb8df79adabfcc447acff09d7ecf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-01 11:49:30 +00:00
Simon Hausmann
e9c45bbddd Begin port of qtbase to CMake
Done-by: Alexandru Croitor <alexandru.croitor@qt.io>
Done-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Done-by: Kevin Funk <kevin.funk@kdab.com>
Done-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Done-by: Simon Hausmann <simon.hausmann@qt.io>
Done-by: Tobias Hunger <tobias.hunger@qt.io>
Done-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Done-by: Volker Krause <volker.krause@kdab.com>
Change-Id: Ida4f8bd190f9a4849a1af7b5b7981337a5df5310
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2018-11-01 11:48:46 +00:00