From 08f3aa32b768afc73b067b4f9e60c4ea5199cdac Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 26 May 2023 15:57:59 +0200 Subject: [PATCH] CMake: Add version tagging sources only if the linker supports it If the TEST_ld_version_script configure test fails with GCC or Clang, then we still added qversiontagging.cpp, and linking failed. Use the result of the configure test to decide whether to add qversiontagging.cpp or not. Task-number: QTBUG-111514 Change-Id: Id09e372a7a1e5cdbe59987be4481f64c6c45251e Reviewed-by: Alexandru Croitor Reviewed-by: Thiago Macieira Reviewed-by: Amir Masoud Abdol --- src/corelib/CMakeLists.txt | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 6b9fbfe77c..164016a208 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -34,9 +34,6 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/QtInstallPaths.cmake.in" ## Core Module: ##################################################################### -set(core_version_tagging_files - global/qversiontagging.cpp - global/qversiontagging.h) qt_internal_add_module(Core QMAKE_MODULE_CONFIG moc resources NO_GENERATE_METATYPES # metatypes are extracted manually below @@ -96,7 +93,6 @@ qt_internal_add_module(Core global/qtversion.h global/qtypeinfo.h global/qtypes.cpp global/qtypes.h - ${core_version_tagging_files} global/qvolatile_p.h global/q20algorithm.h global/q20chrono.h @@ -447,8 +443,22 @@ if(ANDROID) ) endif() -## Scopes: -##################################################################### +# Add version tagging source files if the linker has version script support +# or the platform supports it. +set(core_version_tagging_files + global/qversiontagging.cpp + global/qversiontagging.h) +qt_internal_extend_target(Core + CONDITION TEST_ld_version_script OR APPLE OR WIN32 + SOURCES ${core_version_tagging_files} +) + +# Disable LTO, as the symbols disappear somehow under GCC +# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200) +if(GCC) + set_source_files_properties(${core_version_tagging_files} + PROPERTIES COMPILE_OPTIONS "-fno-lto") +endif() qt_internal_extend_target(Core CONDITION ( TEST_architecture_arch STREQUAL i386 ) OR @@ -640,13 +650,6 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_journald PkgConfig::Libsystemd ) -# Disable LTO, as the symbols disappear somehow under GCC -# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200) -if(GCC) - set_source_files_properties(${core_version_tagging_files} - PROPERTIES COMPILE_OPTIONS "-fno-lto") -endif() - qt_internal_extend_target(Core CONDITION UNIX SOURCES io/qfilesystemengine_unix.cpp