-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
76 lines (69 loc) · 2.03 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
# Minimum version is CMake 3.26
cmake_minimum_required(VERSION 3.25)
# Export compile commands for the language server
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Project instantiation
project(chlorobot VERSION 1.5.0.52)
# Fetch gRPC
option(USE_SYSTEM_GRPC "Use system installed gRPC" ON)
if(USE_SYSTEM_GRPC)
# Find system-installed gRPC
find_package(gRPC CONFIG REQUIRED)
else()
include(FetchContent)
FetchContent_Declare(
gRPC
GIT_REPOSITORY https://github.com/grpc/grpc
GIT_TAG v1.65.1
)
set(FETCHCONTENT_QUIET OFF)
FetchContent_MakeAvailable(gRPC)
endif()
# Add Protobuf
find_package(Protobuf REQUIRED)
# Add OpenSSL
find_package(OpenSSL REQUIRED)
# Add LibreTLS
pkg_check_modules(LibTLS REQUIRED libtls)
# Configure the project header
configure_file(include/configuration.txt
${PROJECT_SOURCE_DIR}/include/configuration.hpp)
# Build our main executable
add_executable(${PROJECT_NAME}
src/tls_socket.cpp
src/irc_data.cpp
src/irc.cpp
src/main.cpp
)
# Use C++20 on target too
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED TRUE)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
# Include headers here
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/include
${LibTLS_INCLUDE_DIRS}
${Protobuf_INCLUDE_DIRS}
)
# Finally link
target_link_libraries(${PROJECT_NAME}
${LibTLS_LIBRARIES}
OpenSSL::SSL OpenSSL::Crypto
gRPC::grpc++
gRPC::grpc++_reflection
${Protobuf_LIBRARIES}
)
# Protocol buffer generation
protobuf_generate(TARGET ${PROJECT_NAME}
IMPORT_DIRS ${PROJECT_SOURCE_DIR}/
PROTOS ${PROJECT_SOURCE_DIR}/chlorobot_rpc.proto
PROTOC_OUT_DIR ${PROJECT_SOURCE_DIR}/protos
)
protobuf_generate(
TARGET ${PROJECT_NAME}
IMPORT_DIRS ${PROJECT_SOURCE_DIR}/
PROTOS ${PROJECT_SOURCE_DIR}/chlorobot_rpc.proto
PROTOC_OUT_DIR ${PROJECT_SOURCE_DIR}/protos
LANGUAGE grpc
PLUGIN protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>
GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
)