-
Notifications
You must be signed in to change notification settings - Fork 106
/
CMakeLists.txt
114 lines (92 loc) · 3.24 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Copyright 2019 U.C. Berkeley RISE Lab
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CMAKE_MINIMUM_REQUIRED(VERSION 3.6 FATAL_ERROR)
PROJECT(Anna)
SET(ANNA_VERSION_MAJOR 0)
SET(ANNA_VERSION_MINOR 1)
SET(ANNA_VERSION_PATCH 0)
IF(NOT DEFINED BUILD_TEST)
SET(BUILD_TEST OFF)
ENDIF()
IF(${BUILD_TEST})
ENABLE_TESTING()
ENDIF()
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED on)
SET(VENDOR_DIR common/vendor)
IF(${CMAKE_CXX_COMPILER} STREQUAL "/usr/bin/clang++")
SET(CMAKE_CXX_FLAGS_COMMON
"-std=c++11 \
-stdlib=libc++ -pthread")
ENDIF()
IF(${CMAKE_CXX_COMPILER} STREQUAL "/usr/bin/g++")
SET(CMAKE_CXX_FLAGS_COMMON
"-std=c++11 -pthread")
ENDIF()
SET(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} \
${CMAKE_CXX_FLAGS_COMMON} \
-g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} \
${CMAKE_CXX_FLAGS_COMMON} \
-O3")
ADD_SUBDIRECTORY(${VENDOR_DIR}/spdlog)
ADD_SUBDIRECTORY(${VENDOR_DIR}/yamlcpp)
ADD_SUBDIRECTORY(${VENDOR_DIR}/zeromq)
ADD_SUBDIRECTORY(${VENDOR_DIR}/zeromqcpp)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES(${SPDLOG_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${ZEROMQCPP_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${ZEROMQ_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${YAMLCPP_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(common/include)
INCLUDE_DIRECTORIES(include)
INCLUDE(FindProtobuf)
FIND_PACKAGE(Protobuf REQUIRED)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER
./common/proto/anna.proto
./common/proto/shared.proto
./include/proto/metadata.proto
)
PROTOBUF_GENERATE_CPP(BPROTO_SRC BPROTO_HEADER
./include/proto/benchmark.proto
)
ADD_LIBRARY(anna-proto ${PROTO_HEADER} ${PROTO_SRC})
ADD_LIBRARY(anna-bench-proto ${BPROTO_HEADER} ${BPROTO_SRC})
FILE(GLOB_RECURSE ZMQ_UTIL_SRC common/include/zmq/*.cpp)
FILE(GLOB_RECURSE ZMQ_UTIL_HEADER common/include/zmq/*.hpp)
ADD_LIBRARY(hydro-zmq STATIC ${ZMQ_UTIL_HEADER} ${ZMQ_UTIL_SRC})
ADD_DEPENDENCIES(hydro-zmq zeromq zeromqcpp spdlog)
IF(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
INCLUDE(common/cmake/clang-format.cmake)
INCLUDE(common/cmake/CodeCoverage.cmake)
ENDIF()
LINK_DIRECTORIES(${ZEROMQ_LINK_DIRS} ${YAMLCPP_LINK_DIRS})
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(client/cpp)
IF(${BUILD_TEST})
INCLUDE(common/cmake/DownloadProject.cmake)
DOWNLOAD_PROJECT(PROJ googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
UPDATE_DISCONNECTED 1
)
ADD_SUBDIRECTORY(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
INCLUDE_DIRECTORIES(common/mock)
INCLUDE_DIRECTORIES(tests)
ADD_SUBDIRECTORY(common/mock)
ADD_SUBDIRECTORY(tests)
ENDIF()