Commit Graph

23 Commits

Author SHA1 Message Date
Amir Masoud Abdol
da2b0307f8 Replace STREQUAL cases with variable checks
As I was investigating the NO_UNITY_BUILD_SOURCES issue, I realized that
we don't need to pass these quoted, especially now that we have moved
to `cmake_parse_arguments(PARSE_ARGV`, and we can check their existence
just by checking the `arg_*`, and that should be sufficient.

I also left a warning that we are aware of this.

Pick-to: 6.5
Change-Id: I4d939e80dc4671ea3ae9dc61516279f69ba2c5a5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-04-04 08:55:02 +02:00
Amir Masoud Abdol
936c3bd224 Add NO_UNITY_BUILD support to qt_internal_add_app
Task-number: QTBUG-109394
Pick-to: 6.5
Change-Id: Iefeb3b846cd889d6ae0aa786f9ae23fbfc811b64
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-04-03 12:41:14 +02:00
Amir Masoud Abdol
7e82577680 Retire the qt_parse_all_arguments
This replaces the qt_parse_all_arguments macro with the built-in
`cmake_parse_arguments(PARSE_ARGV`. In addition, a new function,
_qt_internal_validate_all_args_are_parsed, can be used to check whether
any _UNPARSED_ARGUMENTS have been passed to the function.

Fixes: QTBUG-99238
Change-Id: I8cee83dc92dc6acdaaf747ea6ff9084c11dc649b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-01-18 14:47:12 +01:00
Amir Masoud Abdol
ca24ee14df Create the versioned variant of Qt tools in cross platform build
In cross builds, we are not creating versioned links for qt tools. This
patch addresses that. I've changed the signature of the
`qt_internal_install_versioned_link` such that it can be used for
non-target as well, so in cross build the qmake or qtmake.bat can be
processed with the same function.

Fixes: QTBUG-109024
Change-Id: I246621c18325d084622ca92b422e815ed06f1381
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-07 07:09:15 +01:00
Ivan Solovev
b83fc9f41a CMake: propagate deprecations definitions to tools and apps
If Qt itself is built without the deprecated APIs, so should be the
tools and apps.

This patch makes sure that the specified QT_DISABLE_DEPRECATED_UP_TO
and QT_WARN_DEPRECATED_UP_TO values are correctly used in the internal
tools and apps.

Fixes: QTBUG-105102
Change-Id: I7a51bddbd839c7b71efa0bff8ec959df64c53b82
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-07 19:51:38 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Alexandru Croitor
ea8645d846 CMake: Deprecate _add_app/executable/test/tool PUBLIC_LIBRARIES option
Warn projects not to use it because PUBLIC_LIBRARIES don't make
sense for executable targets and it also led to some issues in the
internal functions where some of them did not expect to receive
PUBLIC_LIBRARIES.

To ensure builds don't needlessly break, treat PUBLIC_LIBRARIES values
as regular LIBRARIES. In the future we might add an error instead.

Using PUBLIC_LIBRARIES in qt_internal_add_app, etc, accidentally
worked because the option name and the values following it were
parsed as values of the "previous" option, like SOURCES or
INCLUDE_DIRECTORIES or LIBRARIES, and when those got
passed through to qt_internal_extend_target, things magically worked.

We have a lot of projects using PUBLIC_LIBRARIES, mostly due to the
way qmake pro files were written and how pro2cmake converted them.
We'll have to clean up each repo.

Change-Id: I69e09d34afdf98f0d47c08d324643fc986f8131c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-29 18:33:00 +02:00
Robert Griebl
f7d42e6b0c cmake: add support for EXCEPTIONS to qt_internal_add_app
Change-Id: I79088f6647496ed455573cab9d403bd8a3f26c76
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-28 20:50:18 +02:00
Tor Arne Vestbø
3ad0f755f5 cmake: Don't reference global data in qt_internal_get_title_case
The only place the function was used was to generate the title case of
a target, so the issue wasn't spotted until now.

Pick-to: 6.2 6.3 6.4
Change-Id: Iee66ecea569e7411c6b5a5e5312cde910a48fa01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-14 14:09:33 +02:00
Kai Köhne
04cc705947 CMake: Fix typos
Found by codespell

Pick-to: 6.4
Change-Id: I4907e423b6b345acf82f2d7e0ed62479719d694e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-13 15:37:36 +02:00
Alexandru Croitor
251033fb0a CMake: Work around build rpath issue when CMAKE_STAGING_PREFIX is set
CMake has logic to rewrite build rpaths that contain
CMAKE_STAGING_PREFIX to instead point to CMAKE_INSTALL_PREFIX.

This breaks running executables from the build directory, because
their build rpath will point to a location where the libraries might
not exist yet (we didn't install Qt yet).

Work around this by setting CMAKE_STAGING_PREFIX to a fake path, so
that CMake does not do the rewriting anymore.

CMAKE_STAGING_PREFIX needs to be set at subdirectory scope, not
function scope, which is why
qt_internal_apply_staging_prefix_build_rpath_workaround() is a macro
that is called from within each Qt internal function that creates
a target.

The workaround can be disabled by configuring with
-DQT_NO_STAGING_PREFIX_BUILD_RPATH_WORKAROUND=ON

The downside of this workaround is that it breaks per-subdirectory
install rules like 'ninja src/gui/install'.
Regular global installation like 'ninja install' works fine.

This is similar to what we do for tests in
qt_set_up_fake_standalone_tests_install_prefix()
introduced by 20292250d4
The reason it's not as good for other target types is because in
contrast to tests, we do want to install them.

In case if someone does call `ninja src/gui/install' they will most
likely get a permission error, telling them it's not possible to
install into
/qt_fake_staging_prefix/
 check_qt_internal_apply_staging_prefix_build_rpath_workaround

Fixes: QTBUG-102592
Change-Id: I6ce78dde1924a8d830ef5c62808ff674c9639d65
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-22 14:34:47 +02:00
Joerg Bornemann
d48609a9c4 CMake: Add INSTALL_DIR argument to qt_internal_add_app
Add the possibility to install a Qt app into a directory different from
${INSTALL_BINDIR}.

If INSTALL_DIR is not specified, qt_internal_add_app still installs to
${INSTALL_BINDIR}.

Pick-to: 6.2 6.3
Task-number: QTBUG-99295
Task-number: QTBUG-100047
Change-Id: I52371aa0f770d80c32bb0b3442ce3c463916be63
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-22 18:37:48 +01:00
Alexandru Croitor
7b3d9efc04 CMake: Place internal apps in the correct output directory
In a -debug-and-release build, apps were placed under bin/Release
rather than just bin.

Apply the logic we use for tools for apps as well. Rename and move
the common functions into QtTargetHelpers.cmake.

Pick-to: 6.2
Fixes: QTBUG-95028
Change-Id: I5a9082ea50c9238c8fcf0c6dd099708fbc571bf8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-09 09:44:58 +02:00
Joerg Bornemann
9f444ce533 Add a way to install versioned hard-links for tools
Add the option argument INSTALL_VERSIONED_LINK to qt_internal_add_tool
and qt_internal_add_app. For tools/apps with this argument we create an
install rule that creates a versioned hard link. For example, for
bin/qmake we create bin/qmake6.

Note that this only applies to prefix builds.

Apply this argument to qmake.
The qt_internal_add_app change is necessary for qtdiag and in qttools.

Task-number: QTBUG-89170
Change-Id: Id32d6055544c475166f4d854aaeb6292fbb5fbb5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit c19d957f45fa27f61b5ecc566f8dbc19f12a44c3)
2021-03-25 16:31:39 +01:00
Joerg Bornemann
b1ad7f938e Generate information about user-facing applications in build dir
When packaging different Qt versions for Linux distributions (or any
distribution with a common bin dir), Qt tools cannot be installed to
/usr/bin, because the executable names of the different Qt versions
clash.

To solve this conflict, our recommendation is to install Qt's tools to
/usr/lib/qt6/bin and to create versioned symlinks to user-facing tools
in /usr/bin.

User-facing tools are tools that are supposed to be started manually by
the user. They are marked in Qt's build system. Distro package
maintainers can now configure with
  -DCMAKE_INSTALL_PREFIX=/usr
  -DINSTALL_BINDIR=/usr/lib/qt6/bin
  -DINSTALL_PUBLICBINDIR=/usr/bin
and will find a file called user_facing_tool_links.txt in the build
directory after the cmake run. Nothing will be installed to
INSTALL_PUBLICBINDIR.

Each line of user_facing_tool_links.txt consists of the installation
path of a user-facing application followed by a space and the versioned
link name in INSTALL_PUBLICBINDIR.

Example content:
/usr/lib/qt6/bin/qmake /usr/bin/qmake6

To actually create the versioned symlinks, the content of this file can
be fed to ln like this:
  xargs ln -s < build-dir/user_facing_tool_links.txt

Or the package maintainer may decide to do something completely
different as suits their needs.

This patch adds the USER_FACING argument to qt_internal_add_tool to mark
tools as user-facing. In addition, every Qt created by
qt_internal_add_app is treated as user-facing.

The only tool this patch marks as user-facing in qtbase is qmake.

Pick-to: 6.1
Fixes: QTBUG-89170
Change-Id: I52673b1c8d40f40f56a74203065553115e2c4de5
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-03-02 22:00:51 +01:00
Joerg Bornemann
5b136abd21 CMake: Fix installation errors in multi-config build
In multi-config builds (which equals the debug-and-release feature) we
exclude tools of the non-main configurations from the default build.
But we still create installation rules for them.  Mark those as optional
to avoid "cmake --install" yielding errors if those tools weren't built.

Fixes: QTBUG-85411
Change-Id: Ic2d3897d1a1c28a715d9a024ec8606fff00e0315
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 04:24:28 +01:00
Alexandru Croitor
1f9ec097b2 CMake: Rename some public API functions
Some of them have a different (hopefully better) name now.
Some are marked as Technical Preview.
Some are renamed to be internal.

Marking add_qt_gui_executable as TP with the intention to un-TP it
after we rename it and change its behavior as discussed in the API
review meeting.

Additional changes to add_qt_gui_executable and qt6_add_resources have
been filed as separate tasks that will be worked on separately.

See comments on PS1 for details.

Task-number: QTBUG-86827
Change-Id: I56a84a1943b0902bb807310dc620eb381824e8dd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-16 13:53:04 +02:00
Alexandru Croitor
e0c62a48b8 CMake: Rename internal functions to contain qt_internal
Offer compatibility wrapper functions until we update all of the Qt
repos to use the new names.

Task-number: QTBUG-86815
Change-Id: I5826a4116f52a8509db32601ef7c200f9bd331de
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-09-23 16:59:05 +02:00
Alexandru Croitor
9a2ee31059 CMake: Fix rpaths set for Qt internal apps like Designer
qt_apply_rpaths takes into account properties like MACOSX_BUNDLE. This
property might not yet be set when qt_internal_add_app is called, but
later.

To handle that, move the call of qt_apply_rpaths to
qt_internal_finalize_app.

As a result, the installed apps will have 2 rpaths, the $ORIGIN style
relocatable one, and an absolute path one pointing to the Qt
prefix/lib. The last one might be unnecessary.

Fixes: QTBUG-86514
Change-Id: I25e0d695c78c8b5703e94c99cc2457f772721456
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-11 19:49:50 +02:00
Joerg Bornemann
e3c6e19ad0 CMake: Fix call to qt_apply_rpaths in qt_internal_add_app
We never passed a valid target name to qt_apply_rpaths.
This amends fde98f7794.

Task-number: QTBUG-85399
Change-Id: I1c023ce30a3a8b5ec43d020373960d19fe20f59a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-09-01 11:35:39 +00:00
Joerg Bornemann
fde98f7794 CMake: Fix rpath for Qt internal applications (non-bootstrapped tools)
We need to call qt_apply_rpaths for targets that are created with
qt_internal_add_app too. This is in line with what qt_app.prf does.

Task-number: QTBUG-85399
Change-Id: If5ffb05cca191c6cae9a330e1f4556d342a68ff8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-08-28 09:44:18 +00:00
Alexandru Croitor
44cce1a2ea CMake: Split QtBuild.cmake into smaller files
QtBuild.cmake is huge. Split it.

Move module, plugin, tools, executables and test related functions out
of QtBuild.cmake into separate files.
Do the same for many other things too.

An additional requirement is that all the new Helpers files only
define functions and macros.
No global variable definitions are allowed, nor execution of commands
with side effects.

Some notes:
qt_install_qml_files is removed because it's dead code.

Some functions still need to be figured out, because they are
interspersed and depend on various global state assignments.

Task-number: QTBUG-86035
Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-14 13:17:11 +02:00