diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-08-07 12:15:35 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-08-17 07:38:18 +0000 |
commit | 8a1e204edf44ab4c0bf3d53eed492dfcf4d20cd0 (patch) | |
tree | bc6ec35d6a73fea44046018e7f48ecc980bac2c4 /qt_cmdline.cmake | |
parent | a44a81ceb712ceb80473f79d78f8bf21b2f89263 (diff) |
CMake: Allow installation of example sources into the Qt prefix
In Qt 5 times, if Qt was configured with -make examples, running
make install would not only build and install the example binaries,
but would also install the example sources into the prefix.
Installation of example sources was not implemented when the Qt 6
build system has switched to using CMake.
There is still a use case for it though, mainly for Qt Creator, which
only shows the examples of a Qt kit if the sources are available.
In contrast to Qt 5, in Qt 6 we will not install example sources
by default. It will be opt in.
To enable installation of examples sources, configure with
configure -make examples -install-examples-sources
or
cmake -DQT_BUILD_EXAMPLES=ON -DQT_INSTALL_EXAMPLES_SOURCES=ON
The -make examples part is required, otherwise
-install-examples-sources has no effect.
All example sources can be installed by calling
cmake --install . --component examples_sources
in the qt repo build directory.
In a top-level build, per-repo installation can be done using
cmake --install . --component examples_sources_<repo_name>
where repo_name could be 'qtbase'.
A single example's source can be installed by calling
cmake --install . --component examples_sources_<subdir_name>
where subdir_name is the subdirectory name of the example, e.g.
'gallery'.
Implement installation of example sources by hooking into the
qt_internal_add_example command.
This means that all examples in all repos need to be added via
qt_internal_add_example instead of add_subdirectory, to ensure the
sources are installed. The majority of repos already use it.
For testing purposes one can configure with
-DQT_BUILD_EXAMPLES=ON -DQT_INSTALL_EXAMPLES_SOURCES=ON
-DQT_INTERNAL_NO_CONFIGURE_EXAMPLES=ON to allow testing installation
of examples sources without building them.
Take into account an additional variable called
QT_INTERNAL_EXAMPLES_SOURCES_INSTALL_PREFIX to allow installation of
example sources into a location different from the example binaries.
As a cleanup, the NAME option that could previously be passed to
qt_internal_add_example_external_project has been removed.
That's because it's never used anywhere and could not have worked
anyway because qt_internal_add_example_in_tree never handled it.
Fixes: QTBUG-112135
Change-Id: I52aa5ec643ff7e212276c88d8dd2dfecdbdbeb0d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 121f7f382badc0f8af6fdbb547f8649b5e1b75c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'qt_cmdline.cmake')
-rw-r--r-- | qt_cmdline.cmake | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/qt_cmdline.cmake b/qt_cmdline.cmake index 9c507906a6..28e8bcc3ae 100644 --- a/qt_cmdline.cmake +++ b/qt_cmdline.cmake @@ -78,6 +78,7 @@ qt_commandline_option(ltcg TYPE boolean) qt_commandline_option(intelcet TYPE boolean) qt_commandline_option(make TYPE addString VALUES examples libs tests tools benchmarks manual-tests minimal-static-tests) +qt_commandline_option(install-examples-sources TYPE boolean) qt_commandline_option(mips_dsp TYPE boolean) qt_commandline_option(mips_dspr2 TYPE boolean) qt_commandline_option(nomake TYPE addString VALUES examples tests tools benchmarks |