forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.cmake
57 lines (46 loc) · 1.7 KB
/
common.cmake
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
57
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb3 -fno-omit-frame-pointer -Wall -Wextra -Werror -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -std=c++0x")
option(ENVOY_LIMIT_ERROR_LOG "limit the number of error log lines from compiler" OFF)
if (ENVOY_LIMIT_ERROR_LOG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=3")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
message(FATAL_ERROR "gcc >= 4.9 required for regex support")
endif()
endif()
option(ENVOY_DEBUG "build debug binaries" ON)
option(ENVOY_CODE_COVERAGE "build with code coverage intrumentation" OFF)
if (ENVOY_CODE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
add_definitions(-DCOVERAGE)
endif()
if (ENVOY_DEBUG AND NOT ENVOY_CODE_COVERAGE)
add_definitions(-DDEBUG)
else()
add_definitions(-DNDEBUG)
endif()
if (ENVOY_DEBUG OR ENVOY_CODE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
option(ENVOY_SANITIZE "build with address sanitizer" OFF)
if (ENVOY_SANITIZE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(ENVOY_TCMALLOC OFF CACHE BOOL "" FORCE)
endif()
option(ENVOY_TCMALLOC "build with tcmalloc" ON)
if (ENVOY_TCMALLOC)
add_definitions(-DTCMALLOC)
endif()
option(ENVOY_STRIP "strip symbols from binaries" OFF)
option(ENVOY_USE_CCACHE "build with ccache" OFF)
if (ENVOY_USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
endif()
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ENVOY_COTIRE_MODULE_DIR}")
include(cotire)