Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't use the compile optimizations with gcc4.6 and osx.
[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 else(NOT __VISUALC__ AND NOT __BORLANDC__)
7     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}/Zi")
8     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}/Zi")
9 endif(NOT __VISUALC__ AND NOT __BORLANDC__)
10
11 if(enable_compile_warnings)
12         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 ")
13 endif(enable_compile_warnings)
14
15 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
16     message(STATUS "With gcc 4.6 and OSX compile optimizations is disable")
17     set(optCFLAGS "-O0 ")
18 else(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
19     if(enable_compile_optimizations)
20         set(optCFLAGS "-O3 -finline-functions -funroll-loops -fno-strict-aliasing ")
21     else(enable_compile_optimizations)
22             set(optCFLAGS "-O0 ")
23     endif(enable_compile_optimizations)
24 endif(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
25
26 if(NOT enable_debug)
27                 set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}")
28 endif(NOT enable_debug)
29
30 set(CMAKE_C_FLAGS "${optCFLAGS}${warnCFLAGS}${CMAKE_C_FLAGS}")
31
32 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${custom_flags}")
33
34 if(WIN32)
35         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i486")
36 endif(WIN32)
37
38 # Try to make Mac a bit more complient to open source standards
39 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
40         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE")
41 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
42
43 if(enable_coverage)
44         find_program(GCOV_PATH gcov)
45         if(GCOV_PATH)
46                 SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
47                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
48                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
49                 add_definitions(-fprofile-arcs -ftest-coverage)
50                 endif(GCOV_PATH)
51 endif(enable_coverage)
52