forked from helios-base/helios-base
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
95 lines (79 loc) · 2.49 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
cmake_minimum_required(VERSION 3.8)
project(helios-base VERSION 2023.03)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
# compliler options
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
set(CMAKE_CXX_FLAGS "-W -Wall")
# GRPC
# list(APPEND CMAKE_PREFIX_PATH "${GRPC_LIB_PATH}")
# set(LIBRARY_PATH "${GRPC_LIB_PATH}/lib")
# link_directories(${LIBRARY_PATH})
find_package(absl CONFIG REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${Protobuf_INCLUDE_DIRS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${gRPC_INCLUDE_DIRS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${absl_INCLUDE_DIRS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${GRPC_LIB_PATH}/include")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${GRPC_LIB_PATH}/lib")
set(_GRPC_GRPCPP gRPC::grpc++)
# check librcsc
set(LIBRCSC_INSTALL_DIR "$ENV{HOME}/.local;$ENV{HOME}/local" CACHE PATH "The path where librcsc is installed.")
find_library(LIBRCSC_LIB NAMES rcsc
PATHS ${LIBRCSC_INSTALL_DIR}
PATH_SUFFIXES lib
)
if(NOT LIBRCSC_LIB)
message(FATAL_ERROR "librcsc library not found!")
endif()
get_filename_component(LIBRCSC_LIBDIR ${LIBRCSC_LIB} DIRECTORY)
find_path(LIBRCSC_INCLUDE_DIR
NAME rcsc/types.h
PATHS ${LIBRCSC_INSTALL_DIR}
PATH_SUFFIXES include
)
if(NOT LIBRCSC_INCLUDE_DIR)
message(FATAL_ERROR "librcsc include dir not found!")
endif()
# remove variables from GUI
mark_as_advanced(
LIBRCSC_LIB
LIBRCSC_INCLUDE_DIR
LIBRCSC_LIBDIR
)
# boost
find_package(Boost 1.36.0 COMPONENTS system REQUIRED)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost not found!")
endif()
# zlib
find_package(ZLIB)
if(ZLIB_FOUND)
set(HAVE_LIBZ TRUE)
endif()
# generate config.h
add_definitions(-DHAVE_CONFIG_H)
configure_file(
${PROJECT_SOURCE_DIR}/cmake-config.h.in
${PROJECT_BINARY_DIR}/config.h
)
# thread
find_package(Threads REQUIRED)
# check the settings
message(STATUS "Found librcsc:")
message(STATUS " LIBRCSC_LIBDIR=${LIBRCSC_LIBDIR}")
message(STATUS " LIBRCSC_LIB=${LIBRCSC_LIB}")
message(STATUS " LIBRCSC_INCLUDE_DIR=${LIBRCSC_INCLUDE_DIR}")
message(STATUS "Build settings:")
message(STATUS " BUILD_TYPE=${CMAKE_BUILD_TYPE}")
# sub directories
add_subdirectory(grpc)
add_subdirectory(src)
include_directories("${GRPC_LIB_PATH}/include/google/protobuf")
add_definitions("${GRPC_LIB_PATH}/include/google/protobuf")