qt5base-lts/src
Alexandru Croitor ac4a913f33 CMake: Deduce install prefix of example in qt_internal_add_example
We want to get rid of the INSTALL_EXAMPLEDIR and INSTALL_EXAMPLESDIR
code in each example project.

This was an internal workaround to ensure examples are installed into
a relative path somewhere under $qt_prefix/examples and not in
$qt_prefix/bin or similar.

To achieve that we do two things.

First, deduce the install prefix for each example in the
implementation of qt_internal_add_example (our add_subdirectory
wrapper) and assign it to CMAKE_INSTALL_PREFIX before calling
add_subdirectory. We need to make sure to remove the default
value of CMAKE_INSTALL_PREFIX in the generated
cmake_install.cmake file.

Second, we set an internal variable called
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT before the add_subdirectory
call, which will be checked whenever find_package(Qt6Core) is called
in an example project. If the variable is set, the
INSTALL_EXAMPLEDIR var is set to "." in the scope of where Qt6Core
is found.

This ensures that the hardcoded INSTALL_EXAMPLEDIR values in our
example projects are changed to ".".

With both changes, our example project install(TARGET DESTINATION)
calls will now install to
"${CMAKE_INSTALL_PREFIX}/examples/${example_relative_dir}/."

Once all repositories are updated to use qt_internal_add_example
instead of add_subdirectory, we can get rid of the
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT workaround.

For repositories that still don't use qt_internal_add_example,
the install prefix rewriting will not happen, but the examples will
still be installed to the proper place because they use their own
hardcoded INSTALL_EXAMPLEDIR value.

Amends d97fd7af2b

Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Task-number: QTBUG-98545
Change-Id: I78c118e10c41b519c570c7d87529afd15aeed900
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-01 16:51:00 +01:00
..
3rdparty SQLite: Update SQLite to v3.37.0 2022-01-06 13:55:53 +00:00
android Android A11Y: fix content update notification when object is hidden 2022-01-28 00:22:41 +01:00
concurrent Fix memory leak in QtConcurrent::run when called with a NULL QThreadPool 2022-01-24 22:40:35 +01:00
corelib CMake: Deduce install prefix of example in qt_internal_add_example 2022-02-01 16:51:00 +01:00
dbus Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] (QtGui) 2022-01-21 11:22:35 +00:00
entrypoint QtBase: replace windows.h with qt_windows.h 2021-11-23 12:53:46 +08:00
gui rhi: d3d11: Switch the default swap effect and scaling mode 2022-02-01 15:06:46 +01:00
network QNetworkReply: rename socketConnecting to socketStartedConnecting 2022-01-31 14:24:11 +01:00
opengl Fix run time failure for UI autotests (INTEGRITY) 2022-01-25 02:59:36 +02:00
openglwidgets Migrate to autogenerated cpp exports 2021-06-25 19:33:12 +02:00
platformsupport evdev: Prevent race condition in touch events processing 2022-01-26 01:01:31 +00:00
plugins Bump version to 6.4.0 2022-01-31 17:20:06 +02:00
printsupport Remove unused .qrc files 2022-01-17 23:17:01 +01:00
sql Check for null driver() before trying to exec() 2022-01-25 16:18:35 +01:00
testlib Make counts of various types of test result add up correctly 2022-01-13 19:47:22 +01:00
tools Remove QSharedMemory from the bootstrap library 2022-01-27 13:31:56 +01:00
widgets QAbstractItemView: do not access invalid model indices (2/N) 2022-02-01 14:32:57 +01:00
xml Doc: Use find_package(Qt6 REQUIRED COMPONENTS ...) idiom 2021-12-09 22:20:04 +01:00
CMakeLists.txt Make it possible to disable the PrintSupport module 2021-02-09 09:17:21 +01:00