The plugin dll files were missing from install_dir/plugins/
Change-Id: I68655faf949e4b8fcab153c6c9b8ee14d3ad8ecc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
We can't use the gold linker with the android NDK, which is the default
option. Using the gold linker results in linker crashes. QMake builds
also disables the gold linker.
Change-Id: I73de93150b160b4411715007bc7e40238b96d400
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Dlls were missing from the install_dir/bin directory.
Change-Id: I0b5ef685b779c91969bbfa877f226be2060f6e56
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
In order for test lib to locate the file requested via QFINDTESTDATA, it
needs the build directory of the test (for example
$builddir/tests/auto/foo/bar) and __FILE__ expanding to a path to the
source relative to this build directory.
With ninja, __FILE__ is a path that is always relative to the top-level
build directory, not the per-test case one. Therefore the path
resolution in testlib fails.
To accommodate this, add_qt_test() now always sets QT_TESTCASE_BUILDDIR
as well as the newly introduced QT_TESTCASE_SOURCEDIR, which, as an
absolute path, removes the need to use __FILE__.
Change-Id: I16c2b0001e38162e6da9fdb1a61f4f8ce634fe46
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Hunter has recently added aliased target names that conform with upstream
CMake find module target names.
Extended the WrapFreetype to work with Hunter's freetype (lowercase) package
name.
Change-Id: I0e25f342c6930658f07f05d2e6a58cf94d2d168d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit introduces infrastructure work to allow static builds of Qt
to handle importing of plug-ins.
Change-Id: Ife0ca3ca7276ea8ec96fe0eb6adf934fad7620ec
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
It's needed when building QtQml on Windows, otherwise
compilation fails.
Add it as a private define for every module being built,
as it is done in qt_module.prf.
Change-Id: I1e322d1da15adea8b3f037a722b3260a552dfb62
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The warning used to be a fatal error, until we found out that certain
packages might provide optional targets, or provide one target
out of a possible set.
Until we figure out a better way to deal with that, remove the
barrage of warnings while configuring.
Change-Id: Iacf93a997a8f87f81167ac7c4cc991212e7fca5d
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Jean-Michaël Celerier <jean-michael.celerier@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
We use
qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3)
which intends to find cmake's FindSQLite3.cmake and expects the
existence of the corresponding target. However qt_find_package first
tries to call find_package in config mode, which does not interact well
with vcpkg's sqlite, where sqlite3-config.cmake is provided to support
multi-config targets. So that call will appear to succeed, yet the
expected targets are not there of course.
Therefore this patch adds a sanity check for the target existence and
allows for a fallback to the module mode for find_package, in order to
find CMake's FindSQLite3.cmake.
Change-Id: I660f26c38369c3504df1c590e9d3a51ff1f65c6c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Also fix the QT_BUILD_SHARED_LIBS usage. While building qtbase, it
is assigned later than the call for
qt_generate_global_config_pri_file(), so it used always choose static.
Make sure to check for BUILD_SHARED_LIBS as well.
Change-Id: I66f03e5adacc89646147fc96154bee8002b2b9cc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
We used to copy a qconfig.cpp.in file verbatim.
Add some plumbing to actually compute the strings and their lengths
as it is done in qtbase/configure.pri.
Also make sure to replace the hardcoded linux mkspec with one that is
automatically determined.
Of course both the detection of the mkspec, and the hardcoded strings
for include, lib, etc. should be fixed in the future.
This is a stepping stone to allow building a Qt application using
the qmake built by CMake.
Change-Id: I2e6754f44b20b09b09d14fd85785d56288e6517b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Generate module .pri files
* Generate qconfig.pri
* Propagate MODULE_CONFIG from the .pro files
This enables the basic use-case of simple application builds that for
example use the moc. Omitted from the patch is support for private
module configurations, prl files (should we do this?) and possibly more
hidden gems that need to be implemented to for example support building
Qt modules with qmake.
Task-number: QTBUG-75666
Change-Id: Icbf0d9ccea4cd683e4c38340b9a2320bf7951d0d
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Since LINUX is not set when targeting Android, we must extend these
conditions manually.
Change-Id: Ie78167d452e0806bfa64773c1e311a99f4a28f8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
QtQml uses QLALR to generate a grammar, but the qmake qlalr feature
seems to be a general one, so the corresponding CMake implementations
are kept in qtbase for now.
Change-Id: Ibe916878b18155ddc5bb08793dd2075ebfa8f282
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
Before this patch we enabled AUTOMOC, AUTORCC, AUTOUIC for all targets
that did not opt out.
Aside from being wasteful from a performance point of view,
this also caused issues when trying to build qtimageformats which
does not depend on Widgets which is the package that exposes uic.
To avoid this, enable only AUTOMOC for all targets by default, and
UIC and RCC can be opted in via the ENABLE_AUTOGEN_TOOLS option.
To facilitate this some refactoring had to be done, like moving some
common setup for all autogen tools into a separate call, and making
sure that extend_target understands the autogen options, because some
ui files are only added conditionally.
Also the conversion script has been adapted to output the
ENABLE_AUTOGEN_TOOLS option whenever a .pro file contains at least
one FORMS += foo assignment.
Note that we don't really use AUTORCC while building Qt, so nothing
opts into that at the moment.
Task-number: QTBUG-75875
Change-Id: I889c4980e9fb1b74ba361abed4044737f8842ea4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>