diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c6442e67..f3651dcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,9 @@ OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON) OPTION(ALSOFT_INSTALL "Install headers and libraries" ON) -IF(WIN32) +IF(NOT WIN32) + SET(LIBNAME openal) +ELSE() SET(LIBNAME OpenAL32) ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502") @@ -60,22 +62,7 @@ IF(WIN32) ENDIF() ENDIF() ENDIF() -ELSE() - SET(LIBNAME openal) - - # These are needed on non-Windows systems for extra features - ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700) - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700") -ENDIF() - -# Set defines for large file support -CHECK_FILE_OFFSET_BITS() -IF(_FILE_OFFSET_BITS) - ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}) - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}") ENDIF() -ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES) -SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES") # QNX's gcc do not uses /usr/include and /usr/lib pathes by default @@ -111,6 +98,29 @@ ELSE() ENDIF() ENDIF() +# Check if _POSIX_C_SOURCE needs to be set for POSIX functions +CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT) +IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT) + SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200809L") + CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX) + IF(NOT HAVE_POSIX_MEMALIGN_POSIX) + SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) + ELSE() + ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200809L) + ENDIF() + UNSET(OLD_REQUIRED_FLAGS) +ENDIF() + +# Set defines for large file support +CHECK_FILE_OFFSET_BITS() +IF(_FILE_OFFSET_BITS) + ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}") +ENDIF() +ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES) +SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES") + # MSVC may need workarounds for C99 restrict and inline IF(MSVC) # TODO: Once we truly require C99, these restrict and inline checks should go @@ -476,12 +486,12 @@ ENDIF() # Check if we have Windows headers CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0502) IF(NOT HAVE_WINDOWS_H) - CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) + CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) IF(NOT HAVE_GETTIMEOFDAY) MESSAGE(FATAL_ERROR "No timing function found!") ENDIF() - CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) + CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP) IF(NOT HAVE_NANOSLEEP) MESSAGE(FATAL_ERROR "No sleep function found!") ENDIF() |