forked from nyfix/OZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·56 lines (50 loc) · 2.91 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
cmake_minimum_required (VERSION 2.8.7)
project (OpenMAMA-zmq)
# enable warnings
set(WARNFLAGS "${WARNFLAGS} -Wall")
set(WARNFLAGS "${WARNFLAGS} -Wextra")
set(WARNFLAGS "${WARNFLAGS} -Wcast-align")
set(WARNFLAGS "${WARNFLAGS} -Wformat")
set(WARNFLAGS "${WARNFLAGS} -Wformat-nonliteral") # warn about non-literal format strings in printf etc.
#set(WARNFLAGS "${WARNFLAGS} -Wexit-time-destructors")
# disable warnings
set(WARNFLAGS "${WARNFLAGS} -Wno-reorder") # order of initialization in ctor
set(WARNFLAGS "${WARNFLAGS} -Wno-unused-parameter") # given that API is defined in interface, this is kind of hard to enforce
set(WARNFLAGS "${WARNFLAGS} -Wno-ignored-qualifiers") # e.g., const on value return types
option(ENABLE_ASAN "Build with address sanitizer" OFF)
if(ENABLE_ASAN)
message(STATUS "Instrumenting with Address Sanitizer")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
endif()
option(ENABLE_TSAN "Build with thread sanitizer" OFF)
if(ENABLE_TSAN)
message(STATUS "Instrumenting with Thread Sanitizer")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=thread -fPIE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=thread -fPIE")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -pie")
endif()
option(ENABLE_UBSAN "Build with undefined behavior sanitizer" OFF)
if(ENABLE_UBSAN)
message(STATUS "Instrumenting with Undefined Behavior Sanitizer")
set(CMAKE_BUILD_TYPE "Debug")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fno-omit-frame-pointer")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize=undefined")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize=implicit-conversion")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize=implicit-integer-truncation")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize=integer")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize=nullability")
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize=vptr")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${UBSAN_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${UBSAN_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${UBSAN_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${UBSAN_FLAGS}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNFLAGS}")
add_subdirectory(src)
add_subdirectory(examples)