summaryrefslogtreecommitdiffstats
path: root/cmake/QtModuleHelpers.cmake
diff options
context:
space:
mode:
authorChristophe Giboudeaux <christophe@krop.fr>2021-01-13 09:19:32 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-13 19:34:28 +0000
commit4bbff3fa215a7200cc6a9cd445e99efda219805c (patch)
tree3bfae4b93694d0666fa3aea1160115975a722439 /cmake/QtModuleHelpers.cmake
parent59785478c3912551da9308942eccef8f0987dd1c (diff)
CMake: Use -ffat-lto-objects for static libraries with ltcg and GCC
CMake <= 3.19 adds the '-fno-fat-lto-objects' compiler flag unconditionally when CMAKE_INTERPROCEDURAL_OPTIMIZATION is enabled. This is fine for shared libraries but static ones need the opposite compiler flag. Task-number: QTBUG-89426 Change-Id: Ie5f48178803a270f6d94408f7a8e85d379eb123c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9563be2870b85309e163db950fefcb9200cac6f4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake/QtModuleHelpers.cmake')
-rw-r--r--cmake/QtModuleHelpers.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake
index cc755c9d00..806f97b8e1 100644
--- a/cmake/QtModuleHelpers.cmake
+++ b/cmake/QtModuleHelpers.cmake
@@ -82,6 +82,14 @@ function(qt_internal_add_module target)
endif()
endif()
+ if(FEATURE_ltcg AND GCC AND is_static_lib)
+ # CMake <= 3.19 appends -fno-fat-lto-objects for all library types if
+ # CMAKE_INTERPROCEDURAL_OPTIMIZATION is enabled. Static libraries need
+ # the opposite compiler option.
+ # (https://gitlab.kitware.com/cmake/cmake/-/issues/21696)
+ target_compile_options(${target} PRIVATE -ffat-lto-objects)
+ endif()
+
if (ANDROID)
qt_android_apply_arch_suffix("${target}")
endif()