A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Need to pass additional -Zc:__cplusplus flag when using
MSVC, so that the __cplusplus define has correct values.
Additionally make the option be propagated to consumers of Qt
via the public Platform target, which QtCore links against.
Change-Id: Ie1283c25334b93f993529beb7fb32bdb001627f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Hardcoding "lib" caused build issues and wrong
INTERFACE_INCLUDE_DIRECTORIES paths in generated CMake configuration
files if INSTALL_INCLUDEDIR pointed to a different location.
Contributes to QTBUG-81289
Change-Id: I3276ecbb4bf5df1c0b4c496c0287b4a69586d683
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
INSTALL_BINDIR may point to a different location than "bin". In order
to avoid errors when trying to install qtbase, "bin" is replaced with
"INSTALL_BINDIR" where necessary.
Contributes to QTBUG-81289
Change-Id: I1d4f9fb2617547c9b0e44d6690caebb2b6768e2f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Linux distributions may want to install mkspecs files into a
different subdir in order to make Qt6 co-installable with
older versions.
Contributes to QTBUG-81289
Change-Id: Ie4a64370d742948d5ca4f2eaed6ea550d2676707
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Rather than pass the build type in the wrapper, make sure the build
type is a cache var, so it gets picked up when building other repos.
This reverts commit f72ca4cf85.
Change-Id: I5d91ab66249b6c40c5e548b0eec0e467ba0f2ebc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This allows doing debug_and_release builds with Ninja on all
platforms.
The "Ninja Multi-Config generator" is available starting with CMake
3.17.
Desired configurations can be set via CMAKE_CONFIGURATION_TYPES.
Possible values: "Release, Debug, RelWithDebInfo, MinRelSize".
For example -DCMAKE_CONFIGURATION_TYPES="Release;Debug".
The first configuration is the 'default' configuration which is
built when calling ninja with no arguments.
To build all targets of a certain configuration use "ninja all:Release"
or "ninja all:Debug".
To build all targets in all configurations use "ninja all:all".
Note that the first configuration influences which configuration of
tools will be used when building the libraries for all configurations.
In simple terms, when configured with
-DCMAKE_CONFIGURATION_TYPES="Release;Debug" the release version of moc
is used by AUTOMOC.
When configured with -DCMAKE_CONFIGURATION_TYPES="Debug;Release"
the debug version of moc is used by AUTOMOC.
Framework builds and Ninja Multi-Config don't currently work together
due to multiple bugs in CMake, which ends up generating an invalid ninja
file with duplicate rules. There are also issues with placement of the
debug artifacts.
This will be handled in a follow up patch after CMake is fixed.
Task-number: QTBUG-76899
Change-Id: If224adc0b71b7d1d6606738101536146aa866cd7
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Tested locally with the following configurations:
- iOS device builds (arm64)
- iOS simulator builds (x86_64)
- iOS simulator_and_device builds (fat arm64 and x86_64 archives)
All iOS builds currently require a custom vcpkg fork which contains
fixes for building the required 3rd party libraries.
qtsvg, qtdeclarative, qtgraphicaleffects and qtquickcontrols2
have also been tested to build successfully.
simulator_and_device builds are also supported, but require an umerged
patch in upstream CMake as well as further patches to vcpkg.
Task-number: QTBUG-75576
Change-Id: Icd29913fbbd52a60e07ea5253fd9c7af7f8ce44c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Write out a file with some JSON data to describe a module.
This file contains information on how that module has been built.
Change-Id: I8a604692663cbb7b76b96b97124130e30b822e4b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
In the ICC configuration we can't build the qtbase libraries with ICC
and qtdeclarative with gcc, mixing won't work well. On Windows we've
covered this compiler mixing scenario using our toolchain file, but the
ICC case makes it clear that we have to be consistent about caching the
compiler in the toolchain file across platforms.
Change-Id: Iad2005ab00655f902e5f5cea2f0563d790d8aa93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This patch moves all of the underlying code for add_qt_resource
into a common reusable snippet for both the Qt build and user projects.
For users, the new API is available under QT5_ADD_RESOURCES. If
outfiles is a CMAKE target we will use the new API, otherwise
we will fall back to the old behavior.
This patch also adds EXTRA_CMAKE_FILES and EXTRA_CMAKE_INCLUDES to
add_qt_module so that module specific cmake files can be installed
and loaded by the module's config.cmake.
The code will be installed under CMAKE_BINARY_DIR/Qt{}CoreResource.cmake
and is injected into Qt{}Core_Config.cmake via the extra cmake includes
passed into add_qt_module.
To make sure it still works with QtBuild, we do the actual generation
of the file from QtBaseGlobalTargets and include the generated file
there as well.
Change-Id: I85fefaa11dde01a6790d23c62d6a64cd157e2617
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Previously the cmake install prefix was added twice during a non-prefix
build, which evaluated to an incorrect path.
Set another absolute dir variable, and use that instead.
Change-Id: I73099510dadc8f401d5a763f21840c9671686c10
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
Add QtAutoDectect cmake which has routines to handle the vcpkg detection
as well as set up some android configuration parameters. The latter will
contribute towards keeping the cmake configuration commands shorter when
targeting android.
Change-Id: I721291c8dce39b5c298565a46867ddcab2df90e8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Mixing compilers won't work well on Windows, so if qtbase is built using
cl.exe and Ninja and then later cmake is called on another module and
gcc is found in %PATH%, then cmake will prefer that. Let's avoid that.
Change-Id: I8294482939efa6a16e0a4df8df3aeef8243c3657
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
We need to save them in the toolchain file, otherwise we can't compile
anything :)
Change-Id: Ic5c53524fa4aa05d0b3229c2905dff92ca437ec1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
Similar to the shell script, this makes it easier to invoke cmake by
just extending your PATH.
Change-Id: I1f83e93c507032f6ecf4838c11d62f49f4d93ed6
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Due to scoping this variable needs to be written into the cache.
Change-Id: I2704fe9ac138210571e0b7acada5eb5c65e265af
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This gets us a step into the direction of convenience that qmake
offered:
* QtBase is configured with a long command line (especially when
cross-compiling)
* Afterwards application developers (or other module builds) can
just use qmake && make
By generating a toolchain file we can capture vcpkg and toolchain
chain-loading and a shell script can take care of providing the prefix
path.
Change-Id: Ided81f5432cab862306f2bea86cfe8e56adf71b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
All the other PlatformModuleInternal, PlatformPluginInternal,
PlatformToolInternal target will depend on the common one.
Also add the QT_NO_DEBUG definition when the build type is not Debug.
This fixes the lookup of the Qt platform plugin on macOS, which
uses a "_debug" prefix in the plugin name depending on if the
QT_NO_DEBUG definition is present or not.
This is the same as it is done in mkspecs/features/qt.prf.
Change-Id: I82cf461d44b8a3b3c5dc2b2d9f25baa246fc1e4b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This changes many different CMake places to mention Qt6 instead of
Qt5.
Note that some old qt5 cmake config files in corelib are probably not
needed anymore, but I still renamed and kept them for now.
Change-Id: Ie69e81540386a5af153f76c0242e18d48211bec4
Builds fail on Windows, due to splitting on ':' on absolute file paths,
when handling syncqt injections.
Revert for now to get qt6 merge in faster.
This reverts commit 7559d508d1.
Change-Id: If139a8a1eb4ae7ccc8d7b835b12e83b03176e28b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Qt CMake Build Bot
In case of a CMake superbuild, the actual install root in a non-prefix
build is the top-level build directory (not $TOP_BUILDDIR/qtbase anymore).
This is more in line how CMake lays out things by default.
Task-number: QTBUG-75582
Change-Id: I4e1744b5c877508fedc33e237eec28cb7436010b
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
It's already installed right where QtSetup.cmake is installed.
Change-Id: Ie88363ae3878cda8f92aa44160333886f64565d8
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Generate the android deployment settings json for android apk
targets. QtPlatformAndroid is now also deployed as a public
build dependency of QtCore. Some minor refactoring has been
performed to the naming of variables and functions to
better match the public facing apis.
Extra settings for the file can be configured using the
following target properties:
set_target_properties(Core
PROPERTIES QT_ANDROID_DEPLOYMENT_DEPENDENCIES "foo;bar"
QT_ANDROID_EXTRA_LIBS "foo;bar"
QT_ANDROID_EXTRA_PLUGINS "foo;bar"
QT_ANDROID_PACKAGE_SOURCE_DIR "/foo/bar/"
)
The file is generated using the function
qt_android_generate_depoyment_settings().
We need to install the android template files and jar
files during the android build as the androiddeployqt tool
wont work if parts of it are split between the host
install and the android install.
Added QT_BUILD_QT variable to check whether we are building
Qt from source.
Finally, we also force the stdlib to shared via cmake
configuration with -DANDROID_STL="c++_shared"
Change-Id: I063c47e11749d56ba4c6f02101dbcc09e1b9fe87
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Link to them from add_qt_module/plugin/tool
This way we set the warnings_are_errors flags just once
and also non-qtbase modules get them
Change-Id: I2b65a81694aaebdd7c886249f217c11f79492bad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Enable building androiddeployqt when performing host builds only.
Added QtPlatformAndroid.cmake to locate Java and the setup the
android SDK platform when building on android.
Install the androiddeployqt support files when performing a host
build.
Added ANDROID_SDK_ROOT configuration variable for specifying the
android sdk directory.
Generating the deployment-settings.json will be done in another
change.
Change-Id: I1bf15315af4ed904d2fb1d22b0e8e834df32d6ed
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Create CMake config files which can be used from the very same CMake
project. These CMake config files simply do not create any targets,
controlled via the QT_NO_CREATE_TARGETS.
This patch also allows to build qtbase.git:examples as a standalone
project, against an already-built Qt.
Ran this:
ag -s "QT " examples -l -0 | xargs -0 -n 1 .../util/cmake/pro2cmake.py --is-example
Task-number: QTBUG-74713
Change-Id: I44cce5a4048618b30f890c5b789592c227a8b47d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This fixes the build when building qtsvg, qtimageformats, etc.
Amends 0900298d46
Change-Id: Ie732ef6faa99e2ebe7e8da6ee2aa5fc0cf59d3f3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Until we have some convenience in place, it is strictly necessary to set
the NDK API level, otherwise the libraries from vcpkg are statically
built against a newer libc headers than what we finally link against.
This also means that we can remove the manual libc linkage again.
Change-Id: If1f2eec4df5ed800ac6b060561edff89236891e9
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
For the android platform library add dependencies on liblog and libc
for every Qt target.
The libraries are shipped by default in the Android NDK so they will
always be present.
Change-Id: Ic4a13be32118710b11effabfb16e27bd2d10809f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@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>
The GlobalConfig target is not an actual module, so there's no point
in trying to create forwarding headers for GlobalConfig's qconfig.h
within qt_feature_module_end.
qconfig.h's forwarding header will be created implicitly while
processing QtCore target's SYNCQT.INJECTIONS value, which is read
from the headers.pri file generated by syncqt.
This also fixes trying to create forwarding headers when processing
the sqldrivers project.
Amends 02a015375a.
Change-Id: Ifd70d8c3ebf881ffdcf90db8d5d3b23309bc8fed
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
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>
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>
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>
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>
It broke builds because the qconfig.h file was created in the wrong
directory.
This reverts commit 25f67fbb07.
Change-Id: Ia458ef4193a3985a9ba613d82f679b7df5ca0107
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Presumably this was a copy paste that was not intended.
Change-Id: I09e3bb12b3b3f7af75726d7a952d79814ea9c876
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Only has warnings for now
Next to come is the support for developer-build and enabling Werror
Change-Id: I8070dc06eb439c2a03007cce975c8147ff7e1582
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>