Set compiler to c99.

This commit is contained in:
Andreas Schneider 2009-09-12 12:26:09 +02:00
parent 16c76166bd
commit 3a265152d8

View file

@ -3,6 +3,10 @@
include(CheckCCompilerFlag)
if (UNIX AND NOT WIN32)
if (CMAKE_COMPILER_IS_GNUCC)
# add -Wconversion ?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute")
# with -fPIC
check_c_compiler_flag("-fPIC" WITH_FPIC)
if (WITH_FPIC)
@ -29,12 +33,10 @@ if (UNIX AND NOT WIN32)
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
string(REGEX REPLACE "[\r\n]" " " ${_lfs_CFLAGS} "${${_lfs_CFLAGS}}")
string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
add_definitions(${_lfs_CFLAGS})
add_definitions(-Wall -Wextra -Wmissing-prototypes -Wdeclaration-after-statement -Wunused)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR)
if (WITH_STACK_PROTECTOR)
@ -46,4 +48,12 @@ if (UNIX AND NOT WIN32)
add_definitions(-D_FORTIFY_SOURCE=2)
endif (WITH_FORTIFY_SOURCE)
# Set linker flags
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
endif (CMAKE_COMPILER_IS_GNUCC)
endif (UNIX AND NOT WIN32)
# suppress warning about "deprecated" functions
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif (MSVC)