Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2bcceac46f63b6ac99cdfa5c24d4333b573bc0d7
[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-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ")
14 endif(enable_compile_warnings)
15
16 if(enable_compile_warnings AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
17     set(warnCFLAGS "${warnCFLAGS} -Wno-error=unused-but-set-variable ")
18 endif(enable_compile_warnings AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
19
20 if(enable_compile_optimizations)
21         set(optCFLAGS "-O3 -finline-functions -funroll-loops -fno-strict-aliasing ")
22 else(enable_compile_optimizations)
23         set(optCFLAGS "-O0 ")
24 endif(enable_compile_optimizations)
25
26 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
27     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")      
28     set(optCFLAGS "-O0 ")
29 endif(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
30
31 if(NOT enable_debug)
32                 set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}")
33 endif(NOT enable_debug)
34
35 set(CMAKE_C_FLAGS "${optCFLAGS}${warnCFLAGS}${CMAKE_C_FLAGS}")
36
37 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${custom_flags}")
38 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${optCFLAGS}")
39
40 # Try to make Mac a bit more complient to open source standards
41 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
42         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE")
43 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
44
45 if(enable_coverage)
46         find_program(GCOV_PATH gcov)
47         if(GCOV_PATH)
48                 SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
49                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
50                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
51                 add_definitions(-fprofile-arcs -ftest-coverage)
52                 endif(GCOV_PATH)
53 endif(enable_coverage)
54