-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
162 lines (136 loc) · 4.78 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Copyright 2023 The IceFlow Authors.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.18)
set(version 0.1.0)
set(so_version 0)
project(
IceFlow
VERSION ${version}
DESCRIPTION "NDN-based stream processing library written in C++.")
set(CMAKE_CXX_STANDARD 20)
option(USE_GRPC "Enable gRPC support" ON)
find_package(Boost)
find_package(PkgConfig)
find_package(OpenSSL REQUIRED)
if(USE_GRPC)
add_definitions(-DUSE_GRPC=1)
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
find_program(gRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
endif()
pkg_check_modules(NDN_CXX REQUIRED libndn-cxx)
pkg_check_modules(SVS REQUIRED libndn-svs)
include(cmake/docs.cmake)
include(cmake/format.cmake)
include(cmake/lint.cmake)
include(GNUInstallDirs)
add_library(iceflow SHARED src/iceflow.cpp src/consumer.cpp src/producer.cpp
src/measurements.cpp src/dag-parser.cpp)
if(USE_GRPC)
target_sources(
iceflow
PRIVATE src/services/node-instance-service.cpp
src/services/node-executor-service.cpp
src/scaler.cpp
src/executor.cpp
proto/node-executor.proto
proto/node-instance.proto)
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
file(MAKE_DIRECTORY ${PROTO_BINARY_DIR})
set(PROTO_IMPORT_DIRS "${CMAKE_CURRENT_LIST_DIR}/proto")
protobuf_generate(TARGET iceflow IMPORT_DIRS ${PROTO_IMPORT_DIRS}
PROTOC_OUT_DIR "${PROTO_BINARY_DIR}")
if(CMAKE_CROSSCOMPILING)
set(_gRPC_CPP_PLUGIN "protoc-gen-grpc=${gRPC_CPP_PLUGIN_EXECUTABLE}")
else()
set(_gRPC_CPP_PLUGIN
"protoc-gen-grpc=\$<TARGET_FILE:gRPC::grpc_cpp_plugin>")
endif()
protobuf_generate(
TARGET
iceflow
LANGUAGE
grpc
GENERATE_EXTENSIONS
.grpc.pb.h
.grpc.pb.cc
PLUGIN
${_gRPC_CPP_PLUGIN}
IMPORT_DIRS
${PROTO_IMPORT_DIRS}
PROTOC_OUT_DIR
"${PROTO_BINARY_DIR}")
target_link_libraries(iceflow PRIVATE gRPC::grpc++ protobuf::libprotobuf)
endif()
set_target_properties(iceflow PROPERTIES VERSION ${version} SOVERSION
${so_version})
target_compile_options(iceflow PRIVATE -D_GNU_SOURCE -DBOOST_LOG_DYN_LINK)
target_link_libraries(
iceflow
PRIVATE ${Boost_LIBRARIES}
-lboost_log
-lboost_system
-lpthread
-lndn-cxx
-lndn-svs
OpenSSL::SSL)
option(BUILD_APPS "Build IceFlow examples" ON)
option(BUILD_TESTS "Build library tests" OFF)
configure_file(${IceFlow_SOURCE_DIR}/pkg/iceflow-config.cmake.in
${IceFlow_BINARY_DIR}/pkg/iceflow-config.cmake @ONLY)
configure_file(${IceFlow_SOURCE_DIR}/iceflow-config-version.cmake.in
${IceFlow_BINARY_DIR}/iceflow-config-version.cmake @ONLY)
install(FILES ${IceFlow_BINARY_DIR}/pkg/iceflow-config.cmake
${IceFlow_BINARY_DIR}/iceflow-config-version.cmake
DESTINATION lib/iceflow)
target_include_directories(
iceflow PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/iceflow>
"$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")
install(
FILES include/iceflow/congestion-reporter.hpp
include/iceflow/consumer.hpp
include/iceflow/dag-parser.hpp
include/iceflow/executor.hpp
include/iceflow/iceflow.hpp
include/iceflow/measurements.hpp
include/iceflow/producer.hpp
include/iceflow/ringbuffer.hpp
include/iceflow/scaler.hpp
DESTINATION include/iceflow)
if(USE_GRPC)
install(
FILES include/iceflow/node-executor-service.hpp
include/iceflow/node-instance-service.hpp
${CMAKE_CURRENT_BINARY_DIR}/generated/node-executor.grpc.pb.h
${CMAKE_CURRENT_BINARY_DIR}/generated/node-executor.pb.h
${CMAKE_CURRENT_BINARY_DIR}/generated/node-instance.grpc.pb.h
${CMAKE_CURRENT_BINARY_DIR}/generated/node-instance.pb.h
DESTINATION include/iceflow)
endif()
install(
TARGETS iceflow
DESTINATION lib
EXPORT iceflow-targets)
install(EXPORT iceflow-targets DESTINATION lib/iceflow)
if(BUILD_APPS)
message(STATUS "Building IceFlow examples...")
add_subdirectory(examples)
endif()
if(BUILD_TESTS)
message(STATUS "Building tests...")
add_subdirectory(tests)
enable_testing()
endif()