diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-08-07 12:15:35 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-08-16 19:04:40 +0200 |
commit | 121f7f382badc0f8af6fdbb547f8649b5e1b75c3 (patch) | |
tree | 8ba9a6c285f09070662581489a48b129fb2b521c /configure.cmake | |
parent | 120fc8244a484a5fde5b19f2e603b05692b79f61 (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.
Pick-to: 6.6
Fixes: QTBUG-112135
Change-Id: I52aa5ec643ff7e212276c88d8dd2dfecdbdbeb0d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'configure.cmake')
-rw-r--r-- | configure.cmake | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/configure.cmake b/configure.cmake index 385b460e4d..80c8b38384 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1133,6 +1133,13 @@ qt_configure_add_summary_entry(ARGS "sanitize_fuzzer_no_link") qt_configure_add_summary_entry(ARGS "sanitize_undefined") qt_configure_end_summary_section() # end of "Sanitizers" section qt_configure_add_summary_build_parts("Build parts") +if(QT_INSTALL_EXAMPLES_SOURCES) + set(_examples_sources_entry_message "yes") +else() + set(_examples_sources_entry_message "no") +endif() +qt_configure_add_summary_entry(ARGS "Install examples sources" TYPE "message" + MESSAGE "${_examples_sources_entry_message}") qt_configure_add_summary_entry( ARGS "appstore-compliant" CONDITION APPLE OR ANDROID OR WIN32 |