summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-06-22 16:01:20 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-06-23 14:01:11 +0200
commitd7efb2a419a88c8f512b98194c8f7bc81dbe942b (patch)
tree3b6331cd687000e2eb919906b182672a66b86bdc /cmake
parent7e5a803c08c38e4fddc4338848768b7cfff4848f (diff)
CMake: Fix include paths for AUTOMOC when using frameworks
The qml app was crashing when used by qtdeclarative auto tests. It complained about unregistered QML types. qmltyperegistrar didn't create registration info for these types. moc didn't output class info about these types because the build system didn't provide the proper include paths. In qmake land, moc was given 2 sets of paths when building a module: the non-installed framework dirs as -F flags, and also the $repo_build_dir/include paths as regular -I flags. In CMake land we only gave include paths to the non-installed framework dirs as -I flags, not -F flags. That's because AUTOMOC checks for a specific pattern in the include paths to transform them into framework include paths (existence of Foo.Framework/Headers symlink), and we didn't pass such an include path. Make sure to mimic what qmake does, and pass -I flags to $repo_build_dir/include as public include paths, but only via BUILD_INTERFACE aka when building Qt itself. Also pass -F flags by specifying framework include paths in the pattern that AUTOMOC expects. Fixes the following qtdeclarative tests tst_qdebugmessageservice tst_qqmlinspector tst_qqmlenginedebuginspectorintegration tst_qqmlpreview Task-number: QTBUG-84886 Change-Id: Iab9693d9889bf6d2c40fed067ab9b9da8683a053 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake45
1 files changed, 28 insertions, 17 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index ff6e72eff2..68ef396e00 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -2570,24 +2570,19 @@ function(qt_add_module target)
set(public_headers_list "public_includes")
if(is_framework)
set(public_headers_list "private_includes")
- set(fw_bundle_subdir "${INSTALL_LIBDIR}/Qt${target}.framework")
- set(fw_headers_subdir "Versions/${PROJECT_VERSION_MAJOR}/Headers")
- list(APPEND public_includes
- # Add the lib/Foo.framework dir as include path to let CMake generate
- # the -F compiler flag.
- "$<BUILD_INTERFACE:${QT_BUILD_DIR}/${fw_bundle_subdir}>"
- "$<INSTALL_INTERFACE:${fw_bundle_subdir}>"
-
- # Add the fully resolved Headers subdir, because the Headers symlink might
- # not be there yet.
- "$<BUILD_INTERFACE:${QT_BUILD_DIR}/${fw_bundle_subdir}/${fw_headers_subdir}>"
-
- # After installing, the Headers symlink is guaranteed to exist.
- "$<INSTALL_INTERFACE:${fw_bundle_subdir}/Headers>"
- )
endif()
- # Handle cases like QmlDevTools which do not have their own headers, but rather borrow them
+ # Make sure the BUILD_INTERFACE include paths come before the framework headers, so that the
+ # the compiler prefers the build dir includes.
+ #
+ # Make sure to add non-framework "build_dir/include" as an include path for moc to find the
+ # currently built module headers. qmake does this too.
+ # Framework-style include paths are found by moc when cmQtAutoMocUic.cxx detects frameworks by
+ # looking at an include path and detecting a "QtFoo.framework/Headers" path.
+ # Make sure to create such paths for both the the BUILD_INTERFACE and the INSTALL_INTERFACE.
+ #
+ # Only add syncqt headers if they exist.
+ # This handles cases like QmlDevTools which do not have their own headers, but borrow them
# from another module.
if(NOT arg_NO_SYNC_QT AND NOT arg_NO_MODULE_HEADERS)
# Don't include private headers unless they exist, aka syncqt created them.
@@ -2597,12 +2592,28 @@ function(qt_add_module target)
"$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}/${module}>")
endif()
- list(APPEND ${public_headers_list}
+ list(APPEND public_includes
# For the syncqt headers
"$<BUILD_INTERFACE:${module_repo_include_dir}>"
"$<BUILD_INTERFACE:${module_include_dir}>")
endif()
+ if(is_framework)
+ set(fw_bundle_subdir "${INSTALL_LIBDIR}/Qt${target}.framework")
+ list(APPEND public_includes
+ # Add the lib/Foo.framework dir as include path to let CMake generate
+ # the -F compiler flag for framework-style includes to work.
+ "$<INSTALL_INTERFACE:${fw_bundle_subdir}>"
+
+ # Add the framework Headers subdir, so that non-framework-style includes work. The
+ # BUILD_INTERFACE Headers symlink was previously claimed not to exist at the relevant
+ # time, and a fully specified Header path was used instead. This doesn't seem to be a
+ # problem anymore.
+ "$<BUILD_INTERFACE:${QT_BUILD_DIR}/${fw_bundle_subdir}/Headers>"
+ "$<INSTALL_INTERFACE:${fw_bundle_subdir}/Headers>"
+ )
+ endif()
+
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}>")