-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
81 lines (63 loc) · 2.36 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
cmake_minimum_required(VERSION 3.10)
project(coro_actor)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose Release or Debug" FORCE)
endif()
option(SPDLOG_INSTALL "Generate the spdlog install target" ON)
option(YAML_CPP_INSTALL "Generate the yaml-cpp install target" ON)
option(CXXOPTS_ENABLE_INSTALL "Generate the cxxopts install target" ON)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb -Wall -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-unused -Wno-sign-compare -Wno-unused-variable")
add_subdirectory(third-party/spdlog)
add_subdirectory(third-party/yalantinglibs)
add_subdirectory(third-party/yaml-cpp)
add_subdirectory(third-party/cxxopts)
file(GLOB_RECURSE srcs ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE hrds ${PROJECT_SOURCE_DIR}/include/*.h)
include(cmake/search_path.cmake)
add_library(${PROJECT_NAME}d SHARED ${srcs})
target_include_directories(${PROJECT_NAME}d PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/third-party/yalantinglibs/include
${PROJECT_SOURCE_DIR}/third-party/yalantinglibs/include/ylt/thirdparty
)
target_link_libraries(${PROJECT_NAME}d PUBLIC
yalantinglibs::yalantinglibs
spdlog::spdlog
yaml-cpp::yaml-cpp
cxxopts::cxxopts
pthread
dl
)
add_library(coro_actor::coro_actor ALIAS ${PROJECT_NAME}d)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC coro_actor::coro_actor)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
#
# Clang-Format
#
find_program(CLANG_FORMAT_EXECUTABLE
NAME "clang-format"
PATHS "/usr/bin" "/usr/local/bin"
)
if (CLANG_FORMAT_EXECUTABLE)
message(STATUS "Successfully find program `clang-format`")
message(STATUS "You can use the `make clang-format` command to automatically format the code style")
add_custom_target(actor-format ALL
COMMAND
${CLANG_FORMAT_EXECUTABLE} --style=file -i ${hdrs};${srcs};${PROJECT_SOURCE_DIR}/main.cpp
COMMENT
"Automatically format the code style"
)
endif()
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}d ${PROJECT_NAME}
LIBRARY
DESTINATION lib
RUNTIME
DESTINATION bin
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include/)