@@ -106,6 +106,8 @@ set(CMAKE_C_STANDARD 99)
106106set (CMAKE_C_STANDARD_REQUIRED ON )
107107set (CMAKE_C_EXTENSIONS OFF )
108108
109+ include (CheckCCompilerFlag )
110+
109111# Set compiler flags and options.
110112if (MSVC )
111113 message ("Not supported yet!" )
@@ -126,8 +128,27 @@ elseif(UNIX OR MINGW)
126128 set (OPT_DBG "-DNDEBUG" ) # disable assert
127129 endif ()
128130
129- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } ${OPT_DBG} -${OPT_LV} -fomit-frame-pointer" )
130- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -Wall -Wno-unused-function -Wno-pointer-sign -Wno-pointer-to-int-cast" )
131+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } ${OPT_DBG} -${OPT_LV} " )
132+ check_c_compiler_flag ("-fomit-frame-pointer" HAS_FLAG_OMIT_FRAME_POINTER )
133+ if (HAS_FLAG_OMIT_FRAME_POINTER)
134+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -fomit-frame-pointer" )
135+ endif ()
136+ check_c_compiler_flag ("-Wall" HAS_FLAG_WARNING_ALL )
137+ if (HAS_FLAG_WARNING_ALL)
138+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -Wall" )
139+ endif ()
140+ check_c_compiler_flag ("-Wno-unused-function" HAS_FLAG_NO_UNUSED_FUNCTION )
141+ if (HAS_FLAG_NO_UNUSED_FUNCTION)
142+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -Wno-unused-function" )
143+ endif ()
144+ check_c_compiler_flag ("-Wno-pointer-sign" HAS_FLAG_NO_POINTER_SIGN )
145+ if (HAS_FLAG_NO_POINTER_SIGN)
146+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -Wno-pointer-sign" )
147+ endif ()
148+ check_c_compiler_flag ("-Wno-pointer-to-int-cast" HAS_FLAG_NO_POINTER_INT_CAST )
149+ if (HAS_FLAG_NO_POINTER_INT_CAST)
150+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -Wno-pointer-to-int-cast" )
151+ endif ()
131152 if (NOT WIN32 )
132153 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS } -pthread" )
133154 endif ()
0 commit comments