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")
8 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}/Zi")
9 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}/Zi")
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 ")
17 if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
18 string(REPLACE "-Wclobbered " "" warnCFLAGS "${warnCFLAGS}")
21 set(CMAKE_Fortran_FLAGS "-Wall") # FIXME: Q&D hack
23 set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint")
26 if(enable_compile_optimizations)
27 set(optCFLAGS "-O3 -finline-functions -funroll-loops -fno-strict-aliasing ")
29 if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.7")
30 # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293
31 set(optCFLAGS "${optCFLAGS} -flto ")
33 # On non-windows, 4.6 is enough for that
34 if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
35 set(optCFLAGS "${optCFLAGS} -flto ")
42 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
43 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
48 set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}")
51 if(enable_msg_deprecated)
52 set(CMAKE_C_FLAGS "-DMSG_USE_DEPRECATED ${CMAKE_C_FLAGS}")
55 set(CMAKE_C_FLAGS "${optCFLAGS}${warnCFLAGS}${CMAKE_C_FLAGS}")
57 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${optCFLAGS}")
59 # Try to make Mac a bit more complient to open source standards
60 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
61 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE")
66 find_program(GCOV_PATH gcov)
68 SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
69 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOVERAGE")
70 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
71 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fprofile-arcs -ftest-coverage")
72 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
73 set(TESH_OPTION --enable-coverage)
74 add_definitions(-fprofile-arcs -ftest-coverage)
78 if(NOT $ENV{CFLAGS} STREQUAL "")
79 message(STATUS "Add CFLAGS: \"$ENV{CFLAGS}\" to CMAKE_C_FLAGS")
80 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}")
83 if(NOT $ENV{LDFLAGS} STREQUAL "")
84 message(STATUS "Add LDFLAGS: \"$ENV{LDFLAGS}\" to CMAKE_C_LINK_FLAGS")
85 set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} $ENV{LDFLAGS}")
88 if(enable_model-checking AND enable_compile_optimizations)
89 message(WARNING "Sorry for now GCC optimizations does not work with model checking.\nPlease turn off optimizations with command:\ncmake -Denable_compile_optimizations=off .")