cmake: use check_symbol_exists, not check_function_exists (thanks, Manuel!) This fixes the problem where we think iOS has fseeko64, etc, but doesn't. Fixes Bugzilla #4885.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 96a63ee..22e4c38 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,6 @@ project(SDL2 C CXX)
# !!! FIXME: properly resolved.
#cmake_policy(SET CMP0042 OLD)
-include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckIncludeFile)
@@ -789,7 +788,8 @@ if(LIBC)
check_include_file("${_HEADER}" ${_HAVE_H})
endforeach()
- check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
+ set(STDC_HEADER_NAMES "dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;stdio.h;strings.h;wchar.h;string.h;float.h")
+ check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS)
check_type_size("size_t" SIZEOF_SIZE_T)
check_symbol_exists(M_PI math.h HAVE_M_PI)
# TODO: refine the mprotect check
@@ -803,14 +803,21 @@ if(LIBC)
_uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
wcscmp wcsdup wcslcat wcslcpy wcslen wcsncmp wcsstr
- sscanf vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp
- nanosleep sysconf sysctlbyname getauxval poll _Exit
+ sscanf vsscanf vsnprintf fopen64 fseeko fseeko64 _Exit
)
string(TOUPPER ${_FN} _UPPER)
set(_HAVEVAR "HAVE_${_UPPER}")
- check_function_exists("${_FN}" ${_HAVEVAR})
+ check_symbol_exists("${_FN}" "${STDC_HEADER_NAMES}" ${_HAVEVAR})
endforeach()
+ check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
+ check_symbol_exists(setjmp "setjmp.h" HAVE_SETJMP)
+ check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP)
+ check_symbol_exists(sysconf "unistd.h" HAVE_SYSCONF)
+ check_symbol_exists(sysctlbyname "sys/types.h;sys/sysctl.h" HAVE_SYSCTLBYNAME)
+ check_symbol_exists(getauxval "sys/auxv.h" HAVE_GETAUXVAL)
+ check_symbol_exists(poll "poll.h" HAVE_POLL)
+
check_library_exists(m pow "" HAVE_LIBM)
if(HAVE_LIBM)
set(CMAKE_REQUIRED_LIBRARIES m)
@@ -821,7 +828,7 @@ if(LIBC)
asin asinf trunc truncf)
string(TOUPPER ${_FN} _UPPER)
set(_HAVEVAR "HAVE_${_UPPER}")
- check_function_exists("${_FN}" ${_HAVEVAR})
+ check_symbol_exists("${_FN}" "math.h" ${_HAVEVAR})
endforeach()
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND EXTRA_LIBS m)
@@ -835,7 +842,7 @@ if(LIBC)
if(NOT APPLE)
check_include_file(alloca.h HAVE_ALLOCA_H)
- check_function_exists(alloca HAVE_ALLOCA)
+ check_symbol_exists(alloca "alloca.h" HAVE_ALLOCA)
else()
set(HAVE_ALLOCA_H 1)
set(HAVE_ALLOCA 1)
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 2d13729..4c34ed4 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -30,7 +30,7 @@ macro(FindLibraryAndSONAME _LIB)
endmacro()
macro(CheckDLOPEN)
- check_function_exists(dlopen HAVE_DLOPEN)
+ check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
if(NOT HAVE_DLOPEN)
foreach(_LIBNAME dl tdl)
check_library_exists("${_LIBNAME}" "dlopen" "" DLOPEN_LIB)
@@ -424,7 +424,7 @@ macro(CheckX11)
set(X11_SHARED OFF)
endif()
- check_function_exists("shmat" HAVE_SHMAT)
+ check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT)
if(NOT HAVE_SHMAT)
check_library_exists(ipc shmat "" HAVE_SHMAT)
if(HAVE_SHMAT)
@@ -476,7 +476,7 @@ macro(CheckX11)
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
endif()
- check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
+ check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
set(HAVE_VIDEO_X11_XCURSOR TRUE)
@@ -901,12 +901,14 @@ macro(CheckPTHREAD)
endif()
endif()
- check_c_source_compiles("
- #include <pthread.h>
- #include <pthread_np.h>
- int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
- check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
- check_function_exists(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP)
+ check_include_files("pthread.h" HAVE_PTHREAD_H)
+ check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H)
+ if (HAVE_PTHREAD_H)
+ check_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP)
+ if (HAVE_PTHREAD_NP_H)
+ check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
+ endif()
+ endif()
set(SOURCE_FILES ${SOURCE_FILES}
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c