diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 48c38f3d8a..4c5a7a6019 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1978,7 +1978,13 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})") if(NOT arg_NO_SYNC_QT) list(APPEND interface_includes "$") - if(NOT arg_NO_MODULE_HEADERS) + # syncqt.pl does not create a private header directory like 'include/6.0/QtFoo' unless + # the module has foo_p.h header files. For QtZlib, there are no such private headers, so we + # need to make sure not to add such include paths unless the directory exists, otherwise + # consumers of the module will fail at CMake generation time stating that + # INTERFACE_INCLUDE_DIRECTORIES contains a non-existent path. + if(NOT arg_NO_MODULE_HEADERS + AND EXISTS "${module_include_dir}/${PROJECT_VERSION}/${module}") list(APPEND interface_includes "$" "$")