-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
73 lines (64 loc) · 2.35 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
cmake_minimum_required (VERSION 3.11)
project ("domain_block")
# 可执行文件输出到bin目录
## 静态库
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
## 动态库和可执行文件
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
# utis和server
include_directories(${CMAKE_SOURCE_DIR})
# boost
set(Boost_USE_STATIC_LIBS ON)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(Boost REQUIRED COMPONENTS thread system filesystem)
else()
find_package(Boost REQUIRED)
endif()
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost not found")
endif()
message(STATUS "Boost version: ${Boost_VERSION}")
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
include(FetchContent)
#spdlog-但是这就仓库的拉取还是比较耗时
## github访问较慢,使用gitee代替
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://gitee.com/moondaisy/spdlog
GIT_TAG v1.x
)
FetchContent_MakeAvailable(spdlog)
include_directories(${spdlog_SOURCE_DIR}/include)
message("fetch spdlog from gitee instead of github")
# toml:
include(FetchContent)
FetchContent_Declare(
tomlplusplus
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
GIT_TAG v3.3.0
)
FetchContent_MakeAvailable(tomlplusplus)
# json
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
FetchContent_MakeAvailable(json)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(MSVC)
# Disable warning C4819 (cannot represent character) for all targets
add_compile_options(/wd4819) # 字符提示禁用.代码中有的是在linux中编辑的是utf8编码,win上默认是gbk编码
add_compile_options(/wd4101) # 禁用未使用局部变量提示。
# vs库静态链接
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" /MT)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE}" /MTd)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" /MT)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELEASE}" /MTd)
endif()
add_subdirectory(UI/domain_block_client)
add_subdirectory(windows/WFP)
else()
add_subdirectory(UI/domain_block_client)
add_subdirectory(linux)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/package/linux")
include(package)
endif()