CMake: Add $import_prefix/include as an include path for each Qt module

To support finding Qt headers of modules installed into a different
prefix than the main one, add the $import_prefix/include path as a
public include path for each built Qt module. With this, includes like
 #include <QtNetworkAuth/QOAuth2AuthorizationCodeFlow> will work.

The macOS framework case is handled automagically by CMake, which
ends up passing '-iframework $import_prefix/lib'.

Change-Id: I02ce9cacf157aab9721c1d6073a377607c5b89c7
Fixes: QTBUG-86881
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-09-25 19:48:30 +02:00
parent 19d2e61f87
commit 151323b94b

View File

@ -297,6 +297,14 @@ function(qt_internal_add_module target)
if(NOT arg_NO_MODULE_HEADERS AND NOT arg_NO_SYNC_QT)
# For the syncqt headers
list(APPEND ${public_headers_list} "$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/${module}>")
# To support finding Qt module includes that are not installed into the main Qt prefix.
# Use case: A Qt module built by Conan installed into a prefix other than the main prefix.
# This does duplicate the include path set on Qt6::Platform target, but CMake is smart
# enough to deduplicate the include paths on the command line.
# Frameworks are automatically handled by CMake in cmLocalGenerator::GetIncludeFlags()
# by additionally passing the 'QtFoo.framework/..' dir with an -iframework argument.
list(APPEND ${public_headers_list} "$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>")
endif()
list(APPEND ${public_headers_list} ${arg_PUBLIC_INCLUDE_DIRECTORIES})