summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-11-06 16:14:46 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-11-26 00:01:35 +0000
commit907edee1a6644e3349a8681699b26faa786d3c7f (patch)
tree5b28afc874f64abe9aa7c65258dd391425cf7408 /cmake
parent1d30822deaa73df36ecabafda13817f063a9c068 (diff)
CMake: Fix headersclean interaction with header only modules
Before CMake 3.19, we are not allowed to query non INTERFACE_ prefixed property names from INTERFACE libraries. And it was the wrong thing to do as well. Prefix the properties with INTERFACE_ as appropriate. Don't try to add INTERFACE_COMPILE_DEFINITIONS from header only modules to the headerclean compile commands. This causes configuration issues with UiPlugin in qttools. Fortunately it seems that qmake doesn't do that for 'header_module's either. Finally don't query for the FRAMEWORK property on the passed target (INTERFACE libs can't be frameworks). Instead just query if the whole Qt build itself is a framework build. An issue was discovered regarding QT_NO_ENTRYPOINT genexes breaking headersclean add_custom_commands for UiPlugin in qttools. To avoid this the property was renamed to all lower case in 6ca66de9120537134b63d42de6c53c6e5834e8f3. This avoided the immediate issue, but it's possible it might resurface in the future with a different property name that wasn't renamed. In particular I thought it might happen with QT_NO_UTF8_SOURCE but it didn't. In case something like that happens again, the two possible solutions are to bump minimum CMake version requirement to 3.19 (where upper case property names are allowed to be queried from INTERFACE libs) or to implement recursive include directory fetching similar to our qt_internal_walk_libs implementation. Task-number: QTBUG-86053 Task-number: QTBUG-82615 Change-Id: I7815d555ec9ea049a8fd40f2a2f072dcb9f5e9c3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 9b84ea6b47979b5d789b72f9f74326ecbe3a579a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtHeadersClean.cmake43
1 files changed, 31 insertions, 12 deletions
diff --git a/cmake/QtHeadersClean.cmake b/cmake/QtHeadersClean.cmake
index b363a86b4e..e9cd956d2e 100644
--- a/cmake/QtHeadersClean.cmake
+++ b/cmake/QtHeadersClean.cmake
@@ -37,15 +37,36 @@ function(qt_internal_add_headers_clean_target
list(PREPEND compiler_to_run "${CMAKE_CXX_COMPILER_LAUNCHER}")
endif()
- set(target_includes_genex "$<TARGET_PROPERTY:${module_target},INCLUDE_DIRECTORIES>")
+ set(prop_prefix "")
+ get_target_property(target_type "${target}" TYPE)
+ if(target_type STREQUAL "INTERFACE_LIBRARY")
+ set(prop_prefix "INTERFACE_")
+ endif()
+
+ set(target_includes_genex
+ "$<TARGET_PROPERTY:${module_target},${prop_prefix}INCLUDE_DIRECTORIES>")
set(includes_exist_genex "$<BOOL:${target_includes_genex}>")
set(target_includes_joined_genex
"$<${includes_exist_genex}:-I$<JOIN:${target_includes_genex},;-I>>")
- set(target_defines_genex "$<TARGET_PROPERTY:${module_target},COMPILE_DEFINITIONS>")
- set(defines_exist_genex "$<BOOL:${target_defines_genex}>")
- set(target_defines_joined_genex
- "$<${defines_exist_genex}:-D$<JOIN:${target_defines_genex},;-D>>")
+ # qmake doesn't seem to add the defines that are set by the header_only_module when checking the
+ # the cleanliness of the module's header files.
+ # This allows us to bypass an error with CMake 3.18 and lower when trying to evaluate
+ # genex-enhanced compile definitions. An example of that is in
+ # qttools/src/designer/src/uiplugin/CMakeLists.txt which ends up causing the following error
+ # message:
+ # CMake Error at qtbase/cmake/QtModuleHelpers.cmake:35 (add_library):
+ # INTERFACE_LIBRARY targets may only have whitelisted properties. The
+ # property "QT_PLUGIN_CLASS_NAME" is not allowed.
+ # Call Stack (most recent call first):
+ # src/designer/src/uiplugin/CMakeLists.txt:7 (qt_internal_add_module)
+ if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
+ set(target_defines_genex
+ "$<TARGET_PROPERTY:${module_target},${prop_prefix}COMPILE_DEFINITIONS>")
+ set(defines_exist_genex "$<BOOL:${target_defines_genex}>")
+ set(target_defines_joined_genex
+ "$<${defines_exist_genex}:-D$<JOIN:${target_defines_genex},;-D>>")
+ endif()
# TODO: FIXME
# Passing COMPILE_OPTIONS can break add_custom_command() if the values contain genexes
@@ -69,7 +90,8 @@ function(qt_internal_add_headers_clean_target
#set(target_compile_options_joined_genex
# "$<${compile_options_exist_genex}:$<JOIN:${target_compile_options_genex},;>>")
- set(target_compile_flags_genex "$<TARGET_PROPERTY:${module_target},COMPILE_FLAGS>")
+ set(target_compile_flags_genex
+ "$<TARGET_PROPERTY:${module_target},${prop_prefix}COMPILE_FLAGS>")
set(compile_flags_exist_genex "$<BOOL:${target_compile_flags_genex}>")
set(target_compile_flags_joined_genex
"$<${compile_flags_exist_genex}:$<JOIN:${target_compile_flags_genex},;>>")
@@ -131,14 +153,11 @@ function(qt_internal_add_headers_clean_target
list(APPEND cxx_flags "${CMAKE_CXX_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}")
endif()
- if(APPLE)
+ if(APPLE AND QT_FEATURE_framework)
# For some reason CMake doesn't generate -iframework flags from the INCLUDE_DIRECTORIES
# generator expression we provide, so pass it explicitly and hope for the best.
- get_target_property(is_framework "${target}" FRAMEWORK)
- if(is_framework)
- list(APPEND framework_includes
- "-iframework" "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
- endif()
+ list(APPEND framework_includes
+ "-iframework" "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
endif()
foreach(header ${hclean_headers})