From 389507a047e0ec0721535052df6ddf957fbb95b3 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Tue, 23 May 2023 16:41:08 +0800 Subject: [PATCH] CMake: make compile options consistent for Qt created libraries Currently some libraries created by Qt are lacking some compile definitions and compile options, and this issue is causing us troubles when building Qt statically. This patch tries to reduce the parameter difference when compiling Qt's own libraries. Change-Id: I3842943a874fab32ef90980e8aa29f5beb01feeb Reviewed-by: Alexey Edelev --- cmake/QtModuleHelpers.cmake | 3 --- cmake/QtPlatformTargetHelpers.cmake | 4 ++++ qmake/CMakeLists.txt | 18 ++++++------------ src/tools/qtpaths/CMakeLists.txt | 1 - 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index e4dccd7f320..c368cebb2e0 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -487,8 +487,6 @@ function(qt_internal_add_module target) endif() endif() - qt_internal_library_deprecation_level(deprecation_define) - if(NOT arg_HEADER_MODULE) qt_autogen_tools_initial_setup(${target}) endif() @@ -578,7 +576,6 @@ function(qt_internal_add_module target) QT_DEPRECATED_WARNINGS QT_BUILDING_QT QT_BUILD_${module_define_infix}_LIB ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore - ${deprecation_define} ) list(APPEND arg_LIBRARIES Qt::PlatformModuleInternal) endif() diff --git a/cmake/QtPlatformTargetHelpers.cmake b/cmake/QtPlatformTargetHelpers.cmake index 54d1916f9eb..b1a78e69c79 100644 --- a/cmake/QtPlatformTargetHelpers.cmake +++ b/cmake/QtPlatformTargetHelpers.cmake @@ -63,6 +63,10 @@ function(qt_internal_setup_public_platform_target) # Generate a pkgconfig for Qt::Platform. qt_internal_generate_pkg_config_file(Platform) + + # Make sure Qt users use the same symbols as how we build Qt. + qt_internal_library_deprecation_level(deprecation_defines) + target_compile_definitions(Platform INTERFACE ${deprecation_defines}) endfunction() function(qt_internal_get_platform_definition_include_dir install_interface build_interface) diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt index 35e06b4e8f6..2c2c777b2cb 100644 --- a/qmake/CMakeLists.txt +++ b/qmake/CMakeLists.txt @@ -16,14 +16,14 @@ qt_add_library(QtLibraryInfo OBJECT qmakelibraryinfo.cpp qmakelibraryinfo.h ) +# Make sure we use same parameters when building QtLibraryInfo and other Qt libraries, +# otherwise some compilers may have compilation errors, such as clang-cl. +target_link_libraries(QtLibraryInfo PUBLIC PlatformCommonInternal) + +target_link_libraries(QtLibraryInfo PUBLIC Qt::CorePrivate) + qt_internal_add_sync_header_dependencies(QtLibraryInfo Core) -set_target_properties(QtLibraryInfo PROPERTIES - COMPILE_OPTIONS $ - COMPILE_DEFINITIONS $ - INCLUDE_DIRECTORIES $ - INCLUDE_DIRECTORIES $ -) target_include_directories(QtLibraryInfo PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/library" @@ -35,18 +35,13 @@ if("${hostdatadir}" STREQUAL "") set(hostdatadir ".") endif() -qt_internal_library_deprecation_level(deprecation_define) - target_compile_definitions(QtLibraryInfo PUBLIC PROEVALUATOR_FULL QT_BUILD_QMAKE QT_USE_QSTRINGBUILDER - QT_NO_FOREACH - QT_VERSION_STR="${PROJECT_VERSION}" QT_HOST_MKSPEC="${QT_QMAKE_HOST_MKSPEC}" QT_TARGET_MKSPEC="${QT_QMAKE_TARGET_MKSPEC}" QT_HOST_DATADIR="${hostdatadir}" - ${deprecation_define} ) qt_internal_set_exceptions_flags(QtLibraryInfo OFF) @@ -99,7 +94,6 @@ qt_internal_add_tool(${target_name} PRECOMPILED_HEADER "qmake_pch.h" LIBRARIES - Qt::CorePrivate QtLibraryInfo ) qt_internal_return_unless_building_tools() diff --git a/src/tools/qtpaths/CMakeLists.txt b/src/tools/qtpaths/CMakeLists.txt index eef33c588d5..1bd1cc907b9 100644 --- a/src/tools/qtpaths/CMakeLists.txt +++ b/src/tools/qtpaths/CMakeLists.txt @@ -25,7 +25,6 @@ qt_internal_return_unless_building_tools() qt_internal_extend_target(${target_name} CONDITION QT_FEATURE_settings LIBRARIES QtLibraryInfo - Qt::CorePrivate ) if(WIN32 AND TARGET ${target_name})