cmake: Pass _FORTIFY_SOURCE directly to the preprocessor.
authorAndreas Schneider <asn@cryptomilk.org>
Wed, 10 Jul 2013 14:37:39 +0000 (16:37 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 10 Jul 2013 14:37:39 +0000 (16:37 +0200)
cmake/Modules/DefineCompilerFlags.cmake

index aea8128..dcf79ab 100644 (file)
@@ -29,9 +29,9 @@ if (UNIX AND NOT WIN32)
         if (CMAKE_BUILD_TYPE)
             string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
             if (NOT CMAKE_BUILD_TYPE_LOWER MATCHES debug)
-                check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
+                check_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
                 if (WITH_FORTIFY_SOURCE)
-                    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
+                    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-D_FORTIFY_SOURCE=2")
                 endif (WITH_FORTIFY_SOURCE)
             endif()
         endif()