4 if(NOT __VISUALC__ AND NOT __BORLANDC__)
5 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-std=gnu99 -g3")
6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-g3")
7 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
9 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}/Zi")
10 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}/Zi")
13 if(enable_compile_warnings)
14 set(warnCFLAGS "-fno-common -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 ")
15 if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
16 set(warnCFLAGS "${warnCFLAGS}-Wclobbered -Wno-error=clobbered ")
17 if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
18 set(warnCFLAGS "${warnCFLAGS}-Wno-error=unused-but-set-variable ")
20 if(COMPILER_C_VERSION_MAJOR_MINOR STREQUAL "4.6")
21 #some old compilers emit bogus warnings here, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45978 . Avoid failing the build in this case
22 set(warnCFLAGS "${warnCFLAGS}-Wno-error=array-bounds")
26 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wunused -Wpointer-arith -Wchar-subscripts -Wcomment -Wno-unknown-warning-option -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wclobbered -Wno-error=clobbered -Wno-format-nonliteral -Werror")
28 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") # FIXME: Q&D hack
30 set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint")
33 if(enable_compile_optimizations)
34 set(optCFLAGS "-O3 -funroll-loops -fno-strict-aliasing ")
35 if(CMAKE_COMPILER_IS_GNUCC AND (NOT enable_model-checking))
36 set(optCFLAGS "${optCFLAGS} -finline-functions ")
38 if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.7")
39 # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293
40 set(optCFLAGS "${optCFLAGS} -flto ")
43 # On non-windows, 4.6 is enough for that
44 if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5" AND LINKER_VERSION STRGREATER "2.22")
45 set(optCFLAGS "${optCFLAGS} -flto ")
54 add_definitions(-DUSE_SDT)
58 add_definitions(-DUSE_UST)
61 if(enable_model-checking AND enable_compile_optimizations)
62 # Forget it, do not optimize the code (because it confuses the MC):
64 # But you can still optimize this:
66 # src/xbt/mmalloc/mm.c
68 # src/xbt/log.c src/xbt/xbt_log_appender_file.c
69 # src/xbt/xbt_log_layout_format.c src/xbt/xbt_log_layout_simple.c
71 # src/xbt/dict.c src/xbt/dict_elm.c src/xbt/dict_multi.c
72 # src/xbt/set.c src/xbt/setset.c
77 # src/xbt/str.c src/xbt/strbuff.c
79 # src/xbt/xbt_os_time.c src/xbt/xbt_os_thread.c
80 # src/xbt/backtrace_linux.c
81 ${MC_SRC_BASE} ${MC_SRC})
82 set (mcCFLAGS "-O3 -funroll-loops -fno-strict-aliasing")
83 if(CMAKE_COMPILER_IS_GNUCC)
84 set (mcCFLAGS "${mcCFLAGS} -finline-functions")
86 set_source_files_properties(${s} PROPERTIES COMPILE_FLAGS ${mcCFLAGS})
90 if(enable_mc_content_adressable_pages)
91 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMC_PAGE_STORE_MD4")
92 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMC_PAGE_STORE_MD4")
95 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
96 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
101 set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}")
102 set(CMAKE_CXX_FLAGS "-DNDEBUG ${CMAKE_CXX_FLAGS}")
105 if(enable_msg_deprecated)
106 set(CMAKE_C_FLAGS "-DMSG_USE_DEPRECATED ${CMAKE_C_FLAGS}")
109 set(CMAKE_C_FLAGS "${optCFLAGS} ${warnCFLAGS} ${CMAKE_C_FLAGS}")
111 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${optCFLAGS}")
113 # Try to make Mac a bit more complient to open source standards
114 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
115 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE")
120 find_program(GCOV_PATH gcov)
122 set(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
123 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOVERAGE")
124 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
125 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
126 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fprofile-arcs -ftest-coverage")
127 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
128 set(TESH_OPTION --enable-coverage)
129 add_definitions(-fprofile-arcs -ftest-coverage)
133 if(NOT $ENV{CFLAGS} STREQUAL "")
134 message(STATUS "Add CFLAGS: \"$ENV{CFLAGS}\" to CMAKE_C_FLAGS")
135 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}")
138 if(NOT $ENV{CXXFLAGS} STREQUAL "")
139 message(STATUS "Add CXXFLAGS: \"$ENV{CXXFLAGS}\" to CMAKE_CXX_FLAGS")
140 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS}")
143 if(NOT $ENV{LDFLAGS} STREQUAL "")
144 message(STATUS "Add LDFLAGS: \"$ENV{LDFLAGS}\" to CMAKE_C_LINK_FLAGS")
145 set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} $ENV{LDFLAGS}")