CMake: Check for syncqt private headers directory before using

Only existing directory paths should be added to
INTERFACE_INCLUDE_DIRECTORIES, otherwise projects fail to configure.

If after running syncqt there is no private headers directory created
(due to the module not having any _p.h files), such a path should not
be added as an interface include path.

This fixes consumers of QtZlib, where there are no private headers.

Change-Id: I3fd1a7b5eb8f816d178d6d91223baa6f377e6f9f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
bb10
Alexandru Croitor 2020-02-24 16:52:36 +01:00
parent 173079819d
commit 1b47411832
1 changed files with 7 additions and 1 deletions

View File

@ -1978,7 +1978,13 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
if(NOT arg_NO_SYNC_QT)
list(APPEND interface_includes "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
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
"$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}>"
"$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}/${module}>")