aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-12-11 09:41:46 -0800
committerChris Robinson <[email protected]>2015-12-11 09:41:46 -0800
commite034afe107dde75e34599a549a75f479bc692908 (patch)
tree2ee87dedbca474bd1717d3db5ae6b691d559e3f9 /CMakeLists.txt
parent01e43e5d4da47423a0457276febb01fb5efa84e4 (diff)
Check if _XOPEN_SOURCE needs to be set
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt35
1 files changed, 25 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78059dba..2fb0632b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,16 +98,31 @@ 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)
+if(NOT WIN32)
+ # 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()
+ ENDIF()
+
+ # Check if _XOPEN_SOURCE needs to be set (if POSIX < 2008)
+ CHECK_SYMBOL_EXISTS(scandir dirent.h HAVE_SCANDIR_DEFAULT)
+ IF(NOT HAVE_SCANDIR_DEFAULT)
+ SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_XOPEN_SOURCE=700")
+ CHECK_SYMBOL_EXISTS(scandir dirent.h HAVE_SCANDIR_XOPEN)
+ IF(NOT HAVE_SCANDIR_XOPEN)
+ SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
+ ELSE()
+ ADD_DEFINITIONS(-D_XOPEN_SOURCE=700)
+ ENDIF()
ENDIF()
UNSET(OLD_REQUIRED_FLAGS)
ENDIF()