ENDIF()
ENDIF()
-# Process with warn flags
-SET(CMAKE_C_WARN_FLAGS "")
CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL)
CHECK_C_COMPILER_FLAG(-W SUPPORT_W)
CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER)
CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM)
CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION)
+CHECK_C_COMPILER_FLAG(-Wno-strict-aliasing SUPPORT_WSTRICT_ALIASING)
CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR)
CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN)
CHECK_C_COMPILER_FLAG(-Wno-sign-compare SUPPORT_WSIGN_COMPARE)
CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD99_FLAG)
ENDIF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
IF(SUPPORT_W)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W")
+ ADD_DEFINITIONS("-W")
ENDIF(SUPPORT_W)
IF(SUPPORT_WALL)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall")
+ ADD_DEFINITIONS("-Wall")
ENDIF(SUPPORT_WALL)
IF(SUPPORT_WPOINTER)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith")
+ ADD_DEFINITIONS("-Wpointer-arith")
ENDIF(SUPPORT_WPOINTER)
IF(SUPPORT_WPARAM)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter")
+ ADD_DEFINITIONS("-Wno-unused-parameter")
ENDIF(SUPPORT_WPARAM)
IF(SUPPORT_WFUNCTION)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function")
+ ADD_DEFINITIONS("-Wno-unused-function")
ENDIF(SUPPORT_WFUNCTION)
IF(SUPPORT_WUNUSED_VAR)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable")
+ ADD_DEFINITIONS("-Wunused-variable")
ENDIF(SUPPORT_WUNUSED_VAR)
IF(SUPPORT_WPOINTER_SIGN)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign")
+ ADD_DEFINITIONS("-Wno-pointer-sign")
ENDIF(SUPPORT_WPOINTER_SIGN)
IF(SUPPORT_WSTRICT_PROTOTYPES)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes")
+ ADD_DEFINITIONS("-Wstrict-prototypes")
ENDIF(SUPPORT_WSTRICT_PROTOTYPES)
+IF(SUPPORT_WSTRICT_ALIASING)
+ ADD_DEFINITIONS("-Wno-strict-aliasing")
+ ADD_DEFINITIONS("-fno-strict-aliasing")
+ENDIF(SUPPORT_WSTRICT_ALIASING)
#IF(SUPPORT_PEDANTIC_FLAG)
# SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic")
#ENDIF(SUPPORT_PEDANTIC_FLAG)
IF(SUPPORT_WNULL_DEREFERENCE)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wnull-dereference")
+ ADD_DEFINITIONS("-Wnull-dereference")
ENDIF()
IF(SUPPORT_WDUPLICATED_COND)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wduplicated-cond")
+ ADD_DEFINITIONS("-Wduplicated-cond")
ENDIF()
IF(SUPPORT_WLOGICAL_OP)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wlogical-op")
+ ADD_DEFINITIONS("-Wlogical-op")
ENDIF()
IF(SUPPORT_WNO_UNUSED_CONST)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-const-variable")
+ ADD_DEFINITIONS("-Wno-unused-const-variable")
ENDIF()
IF(SUPPORT_WSIGN_COMPARE)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-sign-compare")
+ ADD_DEFINITIONS("-Wno-sign-compare")
ENDIF()
IF(SUPPORT_STD11_FLAG)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c11")
+ ADD_DEFINITIONS("-std=c11")
ELSE(SUPPORT_STD11_FLAG)
MESSAGE("C11 compatible compiler is strongly recommended")
IF(SUPPORT_STD99_FLAG)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99")
+ ADD_DEFINITIONS("-std=c99")
ENDIF(SUPPORT_STD99_FLAG)
ENDIF(SUPPORT_STD11_FLAG)
IF(SUPPORT_WIMPLICIT_FALLTHROUGH)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-implicit-fallthrough")
+ ADD_DEFINITIONS("-Wno-implicit-fallthrough")
ENDIF(SUPPORT_WIMPLICIT_FALLTHROUGH)
CHECK_C_COMPILER_FLAG(-fPIC SUPPORT_FPIC)
IF(SUPPORT_FPIC)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+ ADD_DEFINITIONS("-fPIC")
ENDIF(SUPPORT_FPIC)
# Optimization flags
MARK_AS_ADVANCED(CMAKE_GCC_AR CMAKE_GCC_RANLIB)
ENDIF()
IF(CMAKE_GCC_AR AND CMAKE_GCC_RANLIB)
- SET(CMAKE_C_OPT_FLAGS "-g -O3 -fstrict-aliasing -flto")
+ SET(CMAKE_C_OPT_FLAGS "-g -O3 -flto")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
SET(CMAKE_C_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_APPEND "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_FINISH "${CMAKE_GCC_RANLIB} <TARGET>")
ENDIF()
ELSE()
- SET(CMAKE_C_OPT_FLAGS "-g -O3 -fstrict-aliasing")
+ SET(CMAKE_C_OPT_FLAGS "-g -O3")
ENDIF()
ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
IF(ENABLE_FULL_DEBUG MATCHES "ON")
- SET(CMAKE_C_OPT_FLAGS "-g -O0 -fstrict-aliasing")
+ SET(CMAKE_C_OPT_FLAGS "-g -O0")
ELSE(ENABLE_FULL_DEBUG MATCHES "ON")
- SET(CMAKE_C_OPT_FLAGS "-g -O2 -fstrict-aliasing")
+ SET(CMAKE_C_OPT_FLAGS "-g -O2")
ENDIF(ENABLE_FULL_DEBUG MATCHES "ON")
ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")
ENDIF(NOT CMAKE_C_OPT_FLAGS)
IF(ENABLE_COVERAGE)
- SET(CMAKE_C_OPT_FLAGS "-g -O0 -fno-strict-aliasing")
+ SET(CMAKE_C_OPT_FLAGS "-g -O0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
ENDIF(ENABLE_COVERAGE)
SET(WITH_LUA_TRACE 1)
ENDIF(ENABLE_LUA_TRACE)
-SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS}")
ADD_DEFINITIONS(-DHAVE_CONFIG_H)