cmake: Apply symbol visibility settings to Objective-C/C++ sources
Otherwise the Objective-C++ sources will be built with the default compiler visibility (visible), and then linked with moc-generated C++ sources that have the Qt overridden hidden visibility, resulting in linker warnings such as: ld: warning: direct access in function 'X' from file 'moc_foo.cpp.o' to global weak symbol 'Y' from file 'bar.mm.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility setting Change-Id: I22e15e7e181a74de8c0a22c73d06e600e582d7fd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
a418fd5cbb
commit
6d376ea5f4
@ -2087,6 +2087,8 @@ function(qt_set_symbol_visibility_preset target value)
|
||||
|
||||
set_target_properties("${target}" PROPERTIES C_VISIBILITY_PRESET "${value}")
|
||||
set_target_properties("${target}" PROPERTIES CXX_VISIBILITY_PRESET "${value}")
|
||||
set_target_properties("${target}" PROPERTIES OBJC_VISIBILITY_PRESET "${value}")
|
||||
set_target_properties("${target}" PROPERTIES OBJCXX_VISIBILITY_PRESET "${value}")
|
||||
endfunction()
|
||||
|
||||
function(qt_set_symbol_visibility_hidden target)
|
||||
@ -4150,6 +4152,8 @@ function(qt_add_cmake_library target)
|
||||
add_library("${target}" MODULE)
|
||||
set_property(TARGET ${name} PROPERTY C_VISIBILITY_PRESET default)
|
||||
set_property(TARGET ${name} PROPERTY CXX_VISIBILITY_PRESET default)
|
||||
set_property(TARGET ${name} PROPERTY OBJC_VISIBILITY_PRESET default)
|
||||
set_property(TARGET ${name} PROPERTY OBJCXX_VISIBILITY_PRESET default)
|
||||
|
||||
if(APPLE)
|
||||
# CMake defaults to using .so extensions for loadable modules, aka plugins,
|
||||
@ -4233,6 +4237,8 @@ function(qt_add_3rdparty_library target)
|
||||
add_library("${target}" MODULE)
|
||||
set_property(TARGET ${name} PROPERTY C_VISIBILITY_PRESET default)
|
||||
set_property(TARGET ${name} PROPERTY CXX_VISIBILITY_PRESET default)
|
||||
set_property(TARGET ${name} PROPERTY OBJC_VISIBILITY_PRESET default)
|
||||
set_property(TARGET ${name} PROPERTY OBJCXX_VISIBILITY_PRESET default)
|
||||
|
||||
if(APPLE)
|
||||
# CMake defaults to using .so extensions for loadable modules, aka plugins,
|
||||
|
@ -57,6 +57,8 @@ 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
|
||||
|
@ -433,6 +433,8 @@ function(add_qt_gui_executable target)
|
||||
# through dlopen()
|
||||
set_property(TARGET "${target}" PROPERTY C_VISIBILITY_PRESET default)
|
||||
set_property(TARGET "${target}" PROPERTY CXX_VISIBILITY_PRESET default)
|
||||
set_property(TARGET "${target}" PROPERTY OBJC_VISIBILITY_PRESET default)
|
||||
set_property(TARGET "${target}" PROPERTY OBJCXX_VISIBILITY_PRESET default)
|
||||
qt_android_apply_arch_suffix("${target}")
|
||||
else()
|
||||
add_executable("${target}" WIN32 MACOSX_BUNDLE ${ARGN})
|
||||
|
Loading…
Reference in New Issue
Block a user