Merge commit '3105cc20ef3173b87fdc1688962ed6318a1fd039'
This commit is contained in:
38
external/toxcore/c-toxcore/cmake/StrictAbi.cmake
vendored
38
external/toxcore/c-toxcore/cmake/StrictAbi.cmake
vendored
@ -20,8 +20,10 @@ endmacro()
|
||||
function(_make_version_script target)
|
||||
set(${target}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${target}.ld")
|
||||
|
||||
file(WRITE ${${target}_VERSION_SCRIPT}
|
||||
"{ global:\n")
|
||||
if(NOT APPLE)
|
||||
file(WRITE ${${target}_VERSION_SCRIPT}
|
||||
"{ global:\n")
|
||||
endif()
|
||||
|
||||
foreach(sublib ${ARGN})
|
||||
string(REPLACE "^" ";" sublib ${sublib})
|
||||
@ -32,24 +34,40 @@ function(_make_version_script target)
|
||||
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '[a-z0-9_]+' | sort -u"
|
||||
OUTPUT_VARIABLE sublib_SYMS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if("${sublib_SYMS}" STREQUAL "")
|
||||
continue()
|
||||
endif()
|
||||
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})
|
||||
|
||||
foreach(sym ${sublib_SYMS})
|
||||
file(APPEND ${${target}_VERSION_SCRIPT}
|
||||
"${sym};\n")
|
||||
if(APPLE)
|
||||
file(APPEND ${${target}_VERSION_SCRIPT} "_")
|
||||
endif()
|
||||
file(APPEND ${${target}_VERSION_SCRIPT} "${sym}")
|
||||
if(NOT APPLE)
|
||||
file(APPEND ${${target}_VERSION_SCRIPT} ";")
|
||||
endif()
|
||||
file(APPEND ${${target}_VERSION_SCRIPT} "\n")
|
||||
endforeach(sym)
|
||||
endforeach(sublib)
|
||||
|
||||
file(APPEND ${${target}_VERSION_SCRIPT}
|
||||
"local: *; };\n")
|
||||
if(NOT APPLE)
|
||||
file(APPEND ${${target}_VERSION_SCRIPT}
|
||||
"local: *; };\n")
|
||||
endif()
|
||||
|
||||
set_target_properties(${target}_shared PROPERTIES
|
||||
LINK_FLAGS -Wl,--version-script,${${target}_VERSION_SCRIPT})
|
||||
if(APPLE)
|
||||
set_target_properties(${target}_shared PROPERTIES
|
||||
LINK_FLAGS -Wl,-exported_symbols_list,${${target}_VERSION_SCRIPT})
|
||||
else()
|
||||
set_target_properties(${target}_shared PROPERTIES
|
||||
LINK_FLAGS -Wl,--version-script,${${target}_VERSION_SCRIPT})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF)
|
||||
if((WIN32 AND NOT MINGW) OR APPLE)
|
||||
# Windows and macOS don't have this linker functionality.
|
||||
if(WIN32 AND NOT MINGW)
|
||||
# Windows doesn't have this linker functionality.
|
||||
set(STRICT_ABI OFF)
|
||||
endif()
|
||||
|
||||
|
Reference in New Issue
Block a user