diff --git a/CMakeLists.txt b/CMakeLists.txt index c933c8e1..d7a9ac40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ endif ( POLICY CMP0063 ) include ( DefaultDirs ) # Basic C library checks +include ( CheckCCompilerFlag ) include ( CheckSTDC ) include ( CheckIncludeFile ) include ( CheckFunctionExists ) @@ -184,7 +185,13 @@ if ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_C endif ( NOT APPLE AND NOT OS2 ) # define some warning flags - set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement -Werror=implicit-function-declaration -Werror=incompatible-pointer-types" ) + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement -Werror=implicit-function-declaration" ) + check_c_compiler_flag ( "-Werror=incompatible-pointer-types" HAVE_INCOMPATIBLE_POINTER_TYPES ) + if ( HAVE_INCOMPATIBLE_POINTER_TYPES ) + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=incompatible-pointer-types" ) + endif ( HAVE_INCOMPATIBLE_POINTER_TYPES ) + + set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -Wpointer-arith -Wcast-qual -Wno-unused-parameter" ) # prepend to build type specific flags, to allow users to override set ( CMAKE_C_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}" )