CMake: Fix install destination of in-tree examples
Previously we called _qt_internal_override_example_install_dir_to_dot
in Qt6CoreConfigExtras.cmake as part of a
find_package(Qt6 COMPONENTS Core) call, and we assumed that the
Extras file would always be included in each example project.
But our package dependencies handling code skips calling
find_package(Qt6Core) if Qt6Core_FOUND is already set to TRUE,
which will definitely happen due to root-scope find_package
calls when configuring other repos.
That means we wouldn't override INSTALL_EXAMPLEDIR to "."
and the install destination would end up being something like
${CMAKE_INSTALL_PREFIX}/example_relative_path/example_relative_path
aka a double nested path.
Make sure we call the
_qt_internal_override_example_install_dir_to_dot function
in Qt6ConfigConfig.cmake in addition to Qt6CoreConfig.cmake.
That way, even if Qt6Core is skipped during dependency resolution,
it's still handled by the Qt6 package itself.
Because the function is defined in the Core package, guard the call
with an if(COMMAND) and only call the function if it wasn't previously
called within the current or ancestor scopes.
Amends ac4a913f33
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-102879
Change-Id: Id47e3ce06faec6d156ae1473942dae0f9b90cb46
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
578f4ba00c
commit
0e0352ab4d
@ -257,6 +257,12 @@ if(@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS AND _Qt_NOTFOUND_MESSAGE)
|
||||
unset(_Qt_NOTFOUND_MESSAGE)
|
||||
endif()
|
||||
|
||||
if(@INSTALL_CMAKE_NAMESPACE@_FOUND
|
||||
AND COMMAND _qt_internal_override_example_install_dir_to_dot
|
||||
AND NOT _qt_internal_example_dir_set_to_dot)
|
||||
_qt_internal_override_example_install_dir_to_dot()
|
||||
endif()
|
||||
|
||||
__qt_internal_defer_promote_targets_in_dir_scope_to_global()
|
||||
if(CMAKE_VERSION VERSION_LESS 3.21)
|
||||
__qt_internal_check_link_order_matters()
|
||||
|
@ -2664,6 +2664,7 @@ macro(_qt_internal_override_example_install_dir_to_dot)
|
||||
# to CMAKE_INSTALL_PREFIX.
|
||||
if(QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT)
|
||||
set(INSTALL_EXAMPLEDIR ".")
|
||||
set(_qt_internal_example_dir_set_to_dot TRUE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user