build: check c++ compliler flags seperately
authorBernhard Miklautz <bernhard.miklautz@thincast.com>
Wed, 30 Apr 2014 10:05:51 +0000 (12:05 +0200)
committerBernhard Miklautz <bernhard.miklautz@thincast.com>
Wed, 30 Apr 2014 10:05:51 +0000 (12:05 +0200)
Flags for C and C++ compiler need to be checked seperately since
the c and c++ compiler might not support the same flags (even if
they are the same version).

CMakeLists.txt

index 90cdb98..02faa54 100755 (executable)
@@ -119,9 +119,11 @@ endif()
 CHECK_C_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefined)
 if(Wno-builtin-macro-redefined)
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-builtin-macro-redefined")
-       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined")
-
        set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'")
+endif()
+CHECK_CXX_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefinedCXX)
+if(Wno-builtin-macro-redefinedCXX)
+       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined")
        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'")
 endif()
 
@@ -154,6 +156,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
        CHECK_C_COMPILER_FLAG(-Wno-deprecated-declarations Wno-deprecated-declarations)
        if(Wno-deprecated-declarations)
                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
+       endif()
+       CHECK_CXX_COMPILER_FLAG(-Wno-deprecated-declarations Wno-deprecated-declarationsCXX)
+       if(Wno-deprecated-declarationsCXX)
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
        endif()
        if(NOT EXPORT_ALL_SYMBOLS)
@@ -188,6 +193,9 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
        CHECK_C_COMPILER_FLAG(-Wno-deprecated-declarations Wno-deprecated-declarations)
        if(Wno-deprecated-declarations)
                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
+       endif()
+       CHECK_CXX_COMPILER_FLAG(-Wno-deprecated-declarations Wno-deprecated-declarationsCXX)
+       if(Wno-deprecated-declarationsCXX)
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
        endif()
 endif()