-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
112 lines (88 loc) · 3.71 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
# This file is a part of RPCXX project
#[[
Copyright 2024 "NEOLANT Service", "NEOLANT Kalinigrad", Alexey Doronin, Anastasia Lugovets, Dmitriy Dyakonov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
cmake_minimum_required(VERSION 3.16)
project(rpcxx VERSION 1.0 LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_SHARED_LIBS "Build libs as shared" OFF)
option(RPCXX_WITH_CODEGEN "Compile Code Generator" ON)
option(RPCXX_TEST_SANITIZERS "Enable sanitizers" OFF)
option(RPCXX_TEST_RPS "Build QT5 based RPS test" OFF)
option(RPCXX_WITH_TESTS "Build tests" OFF)
include(cmake/RPCXXCodegen.cmake)
include(cmake/CPM.cmake)
CPMAddPackage("gh:p-ranav/argparse@3.0")
CPMAddPackage("gh:fmtlib/fmt#11.0.2")
CPMAddPackage("gh:cyanidle/describe@3.0")
add_library(rpcxx-warnings INTERFACE)
add_library(rpcxx-options INTERFACE)
add_library(rpcxx-headers INTERFACE)
target_include_directories(rpcxx-headers INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(rpcxx-warnings INTERFACE -Wall -Wextra)
endif()
add_library(rpcxx-future STATIC src/future.cpp)
target_link_libraries(rpcxx-future PRIVATE rpcxx-options rpcxx-warnings)
target_link_libraries(rpcxx-future PUBLIC rpcxx-headers)
file(GLOB JSON_VIEW_SOURCES CONFIGURE_DEPENDS src/json_view/*.cpp)
add_library(rpcxx-json STATIC ${JSON_VIEW_SOURCES})
target_link_libraries(rpcxx-json PRIVATE rpcxx-options rpcxx-warnings)
target_link_libraries(rpcxx-json PUBLIC rpcxx-headers describe)
file(GLOB RPCXX_SOURCES CONFIGURE_DEPENDS src/rpcxx/*.cpp)
add_library(rpcxx STATIC ${RPCXX_SOURCES})
add_library(rpcxx::rpcxx ALIAS rpcxx)
target_link_libraries(rpcxx PRIVATE rpcxx-options rpcxx-warnings)
target_link_libraries(rpcxx PUBLIC rpcxx-json rpcxx-headers rpcxx-future)
install(TARGETS rpcxx OPTIONAL)
# Do not clone submodules
cmake_policy(SET CMP0097 NEW)
CPMAddPackage(NAME rapidjson
GITHUB_REPOSITORY Tencent/rapidjson
VERSION 1.1.1
GIT_TAG 7c73dd7
GIT_SUBMODULES ""
DOWNLOAD_ONLY YES
)
target_include_directories(rpcxx-json PRIVATE ${rapidjson_SOURCE_DIR}/include)
if(RPCXX_WITH_TESTS)
CPMAddPackage("gh:doctest/doctest@2.4.11")
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.8.3
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
GIT_SHALLOW YES
EXCLUDE_FROM_ALL YES
)
endif()
if(WIN32)
target_link_libraries(rpcxx-json PRIVATE ws2_32)
target_link_libraries(rpcxx PRIVATE ws2_32)
endif()
if(RPCXX_WITH_CODEGEN)
add_subdirectory(codegen)
endif()
if(RPCXX_WITH_TESTS)
include(CTest)
enable_testing()
add_subdirectory(test)
endif()