-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
119 lines (103 loc) · 4.46 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
###############################################################################
# CMakeLists.txt for zRPC library
# - Creates a CMake target library named 'zRPC'
###############################################################################
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(zRPC
VERSION "0.0.1"
DESCRIPTION "0MQ-based RPC client/server library with MessagePack support"
)
option(ZRPC_BUILD_TESTS "Enable build of unit test applications" ON)
# Setup default compiler flags
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(compile_options -pedantic-errors
-pedantic
-Wall
-Wextra
-Wconversion
-Wsign-conversion
-Wno-psabi
-Werror
CACHE INTERNAL "Compiler Options"
)
###############################################################################
# Bring in CPM
###############################################################################
include(cmake/CPM.cmake)
###############################################################################
# Bring in CPPZMQ header-only API
###############################################################################
CPMAddPackage(
NAME cppzmq
VERSION 4.8.1
GITHUB_REPOSITORY "zeromq/cppzmq"
OPTIONS "CPPZMQ_BUILD_TESTS OFF"
)
###############################################################################
# Bring in MSGPACK-C header-only API
###############################################################################
CPMAddPackage(
NAME msgpack
GIT_TAG cpp-4.1.1
GITHUB_REPOSITORY "msgpack/msgpack-c"
OPTIONS "MSGPACK_BUILD_DOCS OFF" "MSGPACK_CXX20 ON" "MSGPACK_USE_BOOST OFF"
)
###############################################################################
# Bring in C++ CRC header-only API
###############################################################################
CPMAddPackage(
NAME CRCpp
GIT_TAG release-1.1.0.0
GITHUB_REPOSITORY "d-bahr/CRCpp"
)
if(CRCpp_ADDED)
add_library(CRCpp INTERFACE)
target_include_directories(CRCpp SYSTEM INTERFACE ${CRCpp_SOURCE_DIR}/inc)
endif(CRCpp_ADDED)
###############################################################################
# zRPC library
###############################################################################
add_library(${PROJECT_NAME} SHARED)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PUBLIC cppzmq msgpackc-cxx CRCpp pthread)
target_sources(${PROJECT_NAME} PRIVATE src/zRPCClient.cpp
src/zRPCServer.cpp
src/zRPCPublisher.cpp
src/zRPCSubscriber.cpp
PUBLIC include/zRPC.hpp
)
target_compile_options(${PROJECT_NAME} PUBLIC ${compile_options})
###############################################################################
# Test applications
###############################################################################
if (ZRPC_BUILD_TESTS)
add_executable(clientDetached tests/clientDetached.cpp)
target_link_libraries(clientDetached zRPC)
target_compile_options(clientDetached PUBLIC ${compile_options})
add_executable(client tests/client.cpp)
target_link_libraries(client zRPC)
target_compile_options(client PUBLIC ${compile_options})
add_executable(server tests/server.cpp)
target_link_libraries(server zRPC)
target_compile_options(server PUBLIC ${compile_options})
add_executable(publisher tests/publisher.cpp)
target_link_libraries(publisher zRPC)
target_compile_options(publisher PUBLIC ${compile_options})
add_executable(subscriber tests/subscriber.cpp)
target_link_libraries(subscriber zRPC)
target_compile_options(subscriber PUBLIC ${compile_options})
include(cmake/CodeCoverage.cmake)
append_coverage_compiler_flags()
add_executable(unittest tests/unit.cpp)
target_link_libraries(unittest zRPC)
target_compile_options(unittest PUBLIC ${compile_options})
setup_target_for_coverage_gcovr_xml(NAME ${PROJECT_NAME}_coverage
EXECUTABLE unittest
DEPENDENCIES unittest
BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
EXCLUDE "tests"
)
endif(ZRPC_BUILD_TESTS)