CMake: Don't create *Depends header for header-only modules

Set the target property INTERFACE_MODULE_IS_HEADER_ONLY for
header-only modules, and only create *Depends header files if this
property is falsy.

Change-Id: Ic6b100787d18b3ff1f7b9d0f2b5c744018b1f295
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-05-15 12:47:09 +02:00
parent 395fa85403
commit e875f45805
2 changed files with 9 additions and 3 deletions

View File

@ -1923,6 +1923,7 @@ function(qt_add_module target)
if(${arg_HEADER_MODULE})
add_library("${target}" INTERFACE)
set(is_interface_lib 1)
set_target_properties(${target} PROPERTIES INTERFACE_MODULE_IS_HEADER_ONLY TRUE)
elseif(${arg_STATIC})
add_library("${target}" STATIC)
elseif(${QT_BUILD_SHARED_LIBS})
@ -2037,7 +2038,11 @@ function(qt_add_module target)
### FIXME: Can we replace headers.pri?
set(module_include_dir "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module_include_name}")
qt_read_headers_pri("${module_include_dir}" "module_headers")
set(module_depends_header "${module_include_dir}/${module}Depends")
if(arg_HEADER_MODULE)
set(module_depends_header "")
else()
set(module_depends_header "${module_include_dir}/${module}Depends")
endif()
if(is_framework)
if(NOT is_interface_lib)
set(public_headers_to_copy "${module_headers_public}" "${module_depends_header}")
@ -2046,7 +2051,7 @@ function(qt_add_module target)
endif()
else()
set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER "${module_headers_public}")
set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER ${module_depends_header})
set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER "${module_depends_header}")
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER "${module_headers_private}")
endif()
if (NOT ${arg_HEADER_MODULE})

View File

@ -169,7 +169,8 @@ function(qt_internal_create_module_depends_file target)
endif()
get_target_property(hasModuleHeaders "${target}" INTERFACE_MODULE_HAS_HEADERS)
if (${hasModuleHeaders})
get_target_property(isHeaderModule "${target}" INTERFACE_MODULE_IS_HEADER_ONLY)
if (hasModuleHeaders AND NOT isHeaderModule)
get_target_property(module_include_name "${target}" INTERFACE_MODULE_INCLUDE_NAME)
qt_internal_write_depends_file(${module_include_name} ${qtdeps})
endif()