diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-08-25 08:17:23 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-10-05 10:05:20 +0200 |
commit | c09df7b57c1e4b25b5e20c63d2bab63d0d12dea0 (patch) | |
tree | 3057953bd7c670ef9deb012095bdc1d6d492278b /cmake | |
parent | 313ed3d19ad41c2819265b4667bb7f28a024dd89 (diff) |
CMake: Implement configure -reduce-exports
This option maps to FEATURE_reduce_exports. The feature is on by
default, except for MSVC. The reduce_exports configure test is not used
in the CMake build.
The <LANG>_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target
properties are now explicitly initialized in the
qt_set_common_target_properties function, because we don't have access
to the feature in QtSetup.cmake where the CMAKE_<LANG>_VISIBILITY_PRESET
variables were set before.
Task-number: QTBUG-85373
Change-Id: I378453f0e0665731970016170302871e20ceb4e2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtSetup.cmake | 7 | ||||
-rw-r--r-- | cmake/QtTargetHelpers.cmake | 8 | ||||
-rw-r--r-- | cmake/configure-cmake-mapping.md | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index c0dbdca416..7a86b29037 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -54,13 +54,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Do not relink dependent libraries when no header has changed: set(CMAKE_LINK_DEPENDS_NO_SHARED ON) -# Default to hidden visibility for symbols: -set(CMAKE_C_VISIBILITY_PRESET hidden) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_OBJC_VISIBILITY_PRESET hidden) -set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) - # Detect non-prefix builds: either when the qtbase install prefix is set to the binary dir # or when a developer build is explicitly enabled and no install prefix is specified. # This detection only happens when building qtbase, and later is propagated via the generated diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index a78a02af98..d542eaafb8 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -175,6 +175,14 @@ endfunction() # Set target properties that are the same for all modules, plugins, executables # and 3rdparty libraries. function(qt_set_common_target_properties target) + if(QT_FEATURE_reduce_exports) + set_target_properties(${target} PROPERTIES + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + OBJC_VISIBILITY_PRESET hidden + OBJCXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN 1) + endif() if(FEATURE_static_runtime) if(MSVC) set_property(TARGET ${target} PROPERTY diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index b0fa969a75..95527273fd 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -61,7 +61,7 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349. | -R <string> | -DQT_EXTRA_RPATHS=path1;path2 | | | -rpath | negative CMAKE_SKIP_BUILD_RPATH | | | | negative CMAKE_SKIP_INSTALL_RPATH | | -| -reduce-exports | | | +| -reduce-exports | -DFEATURE_reduce_exports=ON | | | -reduce-relocations | -DFEATURE_reduce_relocations=ON | | | -plugin-manifests | | | | -static-runtime | -DFEATURE_static_runtime=ON | | |