forked from qt-creator/qt-creator
CMake: require no undefined symbols
The ELF default is historical legacy. We should always require all libraries and all plugins to link to their dependencies and not accidentally forget something (like implementing a virtual function). Change-Id: I5e00996d7f4b4a10bc98fffd1629f8bfcf0d1c8f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
@@ -244,6 +244,7 @@ function(add_qtc_library name)
|
|||||||
unset(NAMELINK_OPTION)
|
unset(NAMELINK_OPTION)
|
||||||
if (library_type STREQUAL "SHARED")
|
if (library_type STREQUAL "SHARED")
|
||||||
set(NAMELINK_OPTION NAMELINK_SKIP)
|
set(NAMELINK_OPTION NAMELINK_SKIP)
|
||||||
|
qtc_add_link_flags_no_undefined(${name})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
unset(COMPONENT_OPTION)
|
unset(COMPONENT_OPTION)
|
||||||
|
@@ -4,6 +4,7 @@ if (CMAKE_VERSION VERSION_LESS 3.18)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CheckLinkerFlag)
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -161,6 +162,19 @@ function(qtc_enable_sanitize _sanitize_flags)
|
|||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" PARENT_SCOPE)
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(qtc_add_link_flags_no_undefined target)
|
||||||
|
set(no_undefined_flag "-Wl,--no-undefined")
|
||||||
|
check_linker_flag(CXX ${no_undefined_flag} QTC_LINKER_SUPPORTS_NO_UNDEFINED)
|
||||||
|
if (NOT QTC_LINKER_SUPPORTS_NO_UNDEFINED)
|
||||||
|
set(no_undefined_flag "-Wl,-undefined,error")
|
||||||
|
check_linker_flag(CXX ${no_undefined_flag} QTC_LINKER_SUPPORTS_UNDEFINED_ERROR)
|
||||||
|
if (NOT QTC_LINKER_SUPPORTS_UNDEFINED_ERROR)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
target_link_options("${target}" PRIVATE "${no_undefined_flag}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(append_extra_translations target_name)
|
function(append_extra_translations target_name)
|
||||||
if(NOT ARGN)
|
if(NOT ARGN)
|
||||||
return()
|
return()
|
||||||
|
Reference in New Issue
Block a user