mirror of https://github.com/libsdl-org/SDL
cmake: test -Wl,--version-script with minimal version script
Android ndk 26 errors when a symbol in the version script is not defined.
This commit is contained in:
parent
0efa196989
commit
3a36433a3c
|
@ -423,7 +423,7 @@ if(WINDOWS_STORE)
|
||||||
sdl_compile_options(PRIVATE "-ZW")
|
sdl_compile_options(PRIVATE "-ZW")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_linker_flag(C "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/dynapi/SDL_dynapi.sym" HAVE_WL_VERSION_SCRIPT)
|
check_linker_supports_version_file(HAVE_WL_VERSION_SCRIPT)
|
||||||
if(HAVE_WL_VERSION_SCRIPT)
|
if(HAVE_WL_VERSION_SCRIPT)
|
||||||
sdl_shared_link_options("-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/dynapi/SDL_dynapi.sym")
|
sdl_shared_link_options("-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/dynapi/SDL_dynapi.sym")
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -82,16 +82,25 @@ if(APPLE)
|
||||||
enable_language(OBJC)
|
enable_language(OBJC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
function(check_linker_supports_version_file VAR)
|
||||||
|
cmake_push_check_state()
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.sym" "n_0 {\n global:\n func;\n local: *;\n};\n")
|
||||||
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/dummy.sym")
|
||||||
|
check_c_source_compiles("int func(void) {return 0;} int main(int argc,char*argv[]){(void)argc;(void)argv;return func();}" LINKER_SUPPORTS_VERSION_SCRIPT FAIL_REGEX "(unsupported|syntax error)")
|
||||||
|
cmake_pop_check_state()
|
||||||
|
set(${VAR} "${LINKER_SUPPORTS_VERSION_SCRIPT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.18)
|
if(CMAKE_VERSION VERSION_LESS 3.18)
|
||||||
function(check_linker_flag LANG FLAG VAR)
|
function(check_linker_flag LANG FLAG VAR)
|
||||||
cmake_push_check_state()
|
cmake_push_check_state()
|
||||||
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${FLAG} )
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${FLAG} )
|
||||||
if(LANG STREQUAL "C")
|
if(LANG STREQUAL "C")
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
check_c_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "warning")
|
check_c_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")
|
||||||
elseif(LANG STREQUAL "CXX")
|
elseif(LANG STREQUAL "CXX")
|
||||||
include(CheckCXXSourceCompiles)
|
include(CheckCXXSourceCompiles)
|
||||||
check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "warning")
|
check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported language: ${LANG}")
|
message(FATAL_ERROR "Unsupported language: ${LANG}")
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue