1include(CheckIncludeFiles)
2check_include_files(byteswap.h HAVE_BYTESWAP_H)
3check_include_files(dirent.h HAVE_DIRENT_H)
4check_include_files(endian.h HAVE_ENDIAN_H)
5check_include_files(inttypes.h HAVE_INTTYPES_H)
6check_include_files(pthread.h HAVE_PTHREAD_H)
7check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H)
8check_include_files(sys/param.h HAVE_SYS_PARAM_H)
9check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H)
10check_include_files(fcntl.h HAVE_FCNTL_H)
11check_include_files(unistd.h HAVE_UNISTD_H)
12check_include_files(wctype.h HAVE_WCTYPE_H)
13
14include(CheckFunctionExists)
15if(WIN32 AND MSVC)
16  check_function_exists(_access HAVE__ACCESS) #Windows <io.h>
17  check_function_exists(_getpid HAVE__GETPID) #Windows <process.h>
18  check_function_exists(_mkdir HAVE__MKDIR) #Windows <direct.h>
19  check_function_exists(_open HAVE__OPEN) #Windows <io.h>
20  check_function_exists(_snprintf HAVE__SNPRINTF) #Windows <stdio.h>
21  check_function_exists(_stat HAVE__STAT) #Windows <sys/types.h>,<sys/stat.h>
22  check_function_exists(_strdup HAVE__STRDUP) #Windows <string.h>
23  check_function_exists(_stricmp HAVE__STRICMP) #Windows <string.h>
24  check_function_exists(_strnicmp HAVE__STRNICMP) #Windows <string.h>
25  check_function_exists(_read HAVE__READ) #Windows <io.h>
26  check_function_exists(_write HAVE__WRITE) #Windows <io.h>
27else()
28  check_function_exists(access HAVE_ACCESS) #Unix <unistd.h>
29  check_function_exists(fork HAVE_FORK) #Unix <unistd.h>
30  check_function_exists(getopt HAVE_GETOPT) #Unix <unistd.h>
31  check_function_exists(getpid HAVE_GETPID) #Unix <unistd.h>
32  check_function_exists(getpwent HAVE_GETPWENT) #Unix <sys/types.h>,<pwd.h>
33  check_function_exists(gmtime_r HAVE_GMTIME_R) #Unix <time.h>
34  check_function_exists(localtime_r HAVE_LOCALTIME_R) #Unix <time.h>
35  check_function_exists(mkdir HAVE_MKDIR) #Unix <sys/stat.h>,<sys/types.h>
36  check_function_exists(open HAVE_OPEN) #Unix <sys/stat.h>,<sys/types.h>,<fcntl.h>
37  check_function_exists(nanosleep HAVE_NANOSLEEP) #Unix <time.h>
38  check_function_exists(signal HAVE_SIGNAL) #Unix <signal.h>
39  check_function_exists(stat HAVE_STAT) #Unix <sys/stat.h>,<sys/types.h>,<unistd.h>
40  check_function_exists(strdup HAVE_STRDUP) #Unix <string.h>
41  check_function_exists(strcasecmp HAVE_STRCASECMP) #Unix <strings.h>
42  check_function_exists(strncasecmp HAVE_STRNCASECMP) #Unix <strings.h>
43  check_function_exists(read HAVE_READ) #Unix <unistd.h>
44  check_function_exists(unlink HAVE_UNLINK) #Unix <unistd.h>
45  check_function_exists(usleep HAVE_USLEEP) #Unix <unistd.h>
46  check_function_exists(waitpid HAVE_WAITPID) #Unix <sys/types.h>,<sys/wait.h>
47  check_function_exists(write HAVE_WRITE) #Unix <unistd.h>
48  if(NOT MINGW)
49    check_function_exists(alarm HAVE_ALARM) #Unix <unistd.h>
50  endif()
51endif()
52
53check_function_exists(backtrace HAVE_BACKTRACE)
54check_function_exists(iswspace HAVE_ISWSPACE) #Linux <wctype.h>
55check_function_exists(setenv HAVE_SETENV)
56check_function_exists(unsetenv HAVE_UNSETENV)
57check_function_exists(snprintf HAVE_SNPRINTF) #Available with MSVC 2015
58#TODO:BUILDSYSTEM:Figure out why check_function_exists fails to find snprintf for MSVC2015
59if(MSVC_VERSION GREATER 1899)
60  set(HAVE_SNPRINTF true)
61endif()
62
63set(_SAVE_RQL ${CMAKE_REQUIRED_LIBRARIES})
64set(CMAKE_REQUIRED_LIBRARIES kernel32.lib)
65check_function_exists(GetNumberFormat HAVE_GETNUMBERFORMAT) #Windows <windows.h>
66set(CMAKE_REQUIRED_LIBRARIES ${_SAVE_RQL})
67
68include(CheckTypeSize)
69check_type_size(intptr_t SIZEOF_INTPTR_T)
70check_type_size(pid_t SIZEOF_PID_T)
71check_type_size(size_t SIZEOF_SIZE_T)
72check_type_size(ssize_t SIZEOF_SSIZE_T)
73check_type_size(time_t SIZEOF_TIME_T)
74check_type_size(wint_t SIZEOF_WINT_T)
75
76include(FindThreads)
77check_library_exists(pthread pthread_attr_get_np "" HAVE_PTHREAD_ATTR_GET_NP)
78check_library_exists(pthread pthread_getattr_np "" HAVE_PTHREAD_GETATTR_NP)
79check_library_exists(pthread pthread_create "" HAVE_PTHREAD_CREATE)
80check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
81