4 if(NOT __VISUALC__ AND NOT __BORLANDC__)
5 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-g3")
6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-g3")
7 else(NOT __VISUALC__ AND NOT __BORLANDC__)
8 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}/Zi")
9 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}/Zi")
10 endif(NOT __VISUALC__ AND NOT __BORLANDC__)
12 if(enable_compile_warnings)
13 set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wclobbered -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror -Wno-error=clobbered ")
14 if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
15 set(warnCFLAGS "${warnCFLAGS}-Wno-error=unused-but-set-variable ")
16 endif(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
17 endif(enable_compile_warnings)
19 if(enable_compile_optimizations)
20 set(optCFLAGS "-O3 -finline-functions -funroll-loops -fno-strict-aliasing ")
21 if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
22 set(optCFLAGS "${optCFLAGS}-flto ")
23 endif(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
24 else(enable_compile_optimizations)
26 endif(enable_compile_optimizations)
28 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
29 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
31 endif(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
34 set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}")
35 endif(NOT enable_debug)
37 if(enable_msg_deprecated)
38 set(CMAKE_C_FLAGS "-DMSG_USE_DEPRECATED ${CMAKE_C_FLAGS}")
39 endif(enable_msg_deprecated)
41 set(CMAKE_C_FLAGS "${optCFLAGS}${warnCFLAGS}${CMAKE_C_FLAGS}")
43 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${optCFLAGS}")
45 # Try to make Mac a bit more complient to open source standards
46 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
47 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE")
48 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
52 find_program(GCOV_PATH gcov)
54 SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
55 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOVERAGE")
56 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
57 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
58 set(TESH_OPTION --enable-coverage)
59 add_definitions(-fprofile-arcs -ftest-coverage)
61 endif(enable_coverage)
63 if(NOT $ENV{CFLAGS} STREQUAL "")
64 message(STATUS "Add CFLAGS: \"$ENV{CFLAGS}\" to CMAKE_C_FLAGS")
65 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}")
66 endif(NOT $ENV{CFLAGS} STREQUAL "")
68 if(NOT $ENV{LDFLAGS} STREQUAL "")
69 message(STATUS "Add LDFLAGS: \"$ENV{LDFLAGS}\" to CMAKE_C_LINK_FLAGS")
70 set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} $ENV{LDFLAGS}")
71 endif(NOT $ENV{LDFLAGS} STREQUAL "")
73 if(enable_model-checking AND enable_compile_optimizations)
74 message(WARNING "Sorry for now GCC optimizations does not work with model checking.\nPlease turn off optimizations with command:\ncmake -Denable_compile_optimizations=off. ")
75 endif(enable_model-checking AND enable_compile_optimizations)