cmake: Check for _GNU_SOURCE and add it if available.
authorAndreas Schneider <asn@cryptomilk.org>
Mon, 25 Jun 2012 12:30:31 +0000 (14:30 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 25 Jun 2012 12:30:31 +0000 (14:30 +0200)
This is needed for strsignal().

cmake/Modules/DefineCompilerFlags.cmake

index 3a6a454..239ddeb 100644 (file)
@@ -29,6 +29,11 @@ if (UNIX AND NOT WIN32)
         if (WITH_FORTIFY_SOURCE)
             set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
         endif (WITH_FORTIFY_SOURCE)
+
+        check_c_compiler_flag("-D_GNU_SOURCE" WITH_GNU_SOURCE)
+        if (WITH_GNU_SOURCE)
+            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
+        endif (WITH_GNU_SOURCE)
     endif (${CMAKE_C_COMPILER_ID} MATCHES GNU)
 
     #