Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
510c77b2eed9c2e949a8cdc0b5747850d79befdd
[simgrid.git] / buildtools / Cmake / Flags.cmake
1 set(warnCFLAGS "")
2 set(optCFLAGS "")
3
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__)
11
12 if(enable_compile_warnings)
13         set(warnCFLAGS "-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-clobbered -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ")
14 endif(enable_compile_warnings)
15
16 if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
17         set(warnCFLAGS "${warnCFLAGS} -Wno-unused-but-set-variable ")
18 endif(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
19
20 if(enable_compile_optimizations)
21         set(optCFLAGS "-O3 -finline-functions -funroll-loops -fno-strict-aliasing ")
22         if(${COMPILER_C_VERSION_MAJOR_MINOR} STRGREATER "4.5")
23             set(optCFLAGS "${optCFLAGS}-flto ")
24         endif(${COMPILER_C_VERSION_MAJOR_MINOR} STRGREATER "4.5")
25 else(enable_compile_optimizations)
26         set(optCFLAGS "-O0 ")
27 endif(enable_compile_optimizations)
28
29 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
30     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")      
31     set(optCFLAGS "-O0 ")
32 endif(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
33
34 if(NOT enable_debug)
35                 set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}")
36 endif(NOT enable_debug)
37
38 set(CMAKE_C_FLAGS "${optCFLAGS}${warnCFLAGS}${CMAKE_C_FLAGS}")
39
40 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${custom_flags}")
41 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${optCFLAGS}")
42
43 # Try to make Mac a bit more complient to open source standards
44 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
45         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE")
46 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
47
48 set(TESH_OPTION "")
49 if(enable_coverage)
50         find_program(GCOV_PATH gcov)
51         if(GCOV_PATH)
52                 SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
53                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
54                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
55                 set(TESH_OPTION --enable-coverage)
56                 add_definitions(-fprofile-arcs -ftest-coverage)
57         endif(GCOV_PATH)
58 endif(enable_coverage)
59