Build: c99 and GNU source fixups
authorAdriaan de Groot <groot@kde.org>
Sun, 10 Jul 2016 03:16:24 +0000 (05:16 +0200)
committerAdriaan de Groot <groot@kde.org>
Sun, 10 Jul 2016 03:47:55 +0000 (05:47 +0200)
 - Use gnu99 / c99 if possible
 - .. but c99 doesn't give us all of POSIX, so re-add that for sigaction
 - h_addr is a FreeBSD or GNU backwards-compatibility thing.

cmake/CheckC99Flags.cmake [new file with mode: 0644]
src/3rdparty/fcgi-2.4.0/CMakeLists.txt
src/3rdparty/fcgi-2.4.0/libfcgi/os_unix.c
src/CMakeLists.txt

diff --git a/cmake/CheckC99Flags.cmake b/cmake/CheckC99Flags.cmake
new file mode 100644 (file)
index 0000000..f0ce38e
--- /dev/null
@@ -0,0 +1,12 @@
+# Check which flag to pass in for C C99 support.
+#
+include(CheckCCompilerFlag)
+CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_SUPPORTS_C99)
+CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_SUPPORTS_G99)
+if(COMPILER_SUPPORTS_G99)
+       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
+elseif(COMPILER_SUPPORTS_C99)
+       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+else()
+        message(FATAL "The compiler ${CMAKE_C_COMPILER} has no C99 support. Please use a different C compiler.")
+endif()
index dec96fe..1ecbdf3 100644 (file)
@@ -11,6 +11,8 @@ cmake_minimum_required(VERSION 2.8.11)
 
 include_directories(include .)
 
+add_definitions(-D_POSIX_C_SOURCE=1)
+
 set(LIBFCGI_SRC
   libfcgi/fcgiapp.c
   libfcgi/fcgio.cpp
index 73e6a7f..779e18c 100755 (executable)
@@ -63,6 +63,10 @@ static const char rcsid[] = "$Id: os_unix.c,v 1.37 2002/03/05 19:14:49 robs Exp
 #define INADDR_NONE ((unsigned long) -1)
 #endif
 
+#ifndef h_addr
+#define h_addr h_addr_list[0]
+#endif
+
 /*
  * This structure holds an entry for each oustanding async I/O operation.
  */
index 9c2485a..f4ad8d6 100644 (file)
@@ -10,6 +10,7 @@ project(steamworks)
 
 include(MacroEnsureOutOfSourceBuild)
 include(CheckCXX11Flags)
+include(CheckC99Flags)
 
 MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
   "Do not build Steamworks in the source directory.")