generated from cyanray/mirai-cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
42 lines (42 loc) · 1.69 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
# CMake 版本要求 (最低 3.1)
cmake_minimum_required (VERSION 3.1)
# 项目名称(建议修改)
project(MisakaBot)
# 设置项目的 C++ 标准
set(CMAKE_CXX_STANDARD 20)
# 不要构建 mirai-cpp 自带的 examples
set(MIRAI_CPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples" FORCE)
# 添加子模块 mirai-cpp
add_subdirectory(mirai-cpp)
add_subdirectory(cpr)
# 源码以 UTF-8 编码保存,使用 MSVC 编译器时需要加编译参数提供支持
if(MSVC)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
message(STATUS "optional: /UTF-8")
endif(MSVC)
# 要添加.cpp源文件,请修改这一行
# 例如:add_executable(${PROJECT_NAME} src/main.cpp src/a.cpp src/b.cpp)
add_executable(${PROJECT_NAME} src/main.cpp)
# 设置头文件目录
include_directories(include)
include_directories("/usr/include/mysql++")
include_directories("/usr/include/mysql")
# 链接 mirai-cpp
target_link_libraries(${PROJECT_NAME} PRIVATE mirai-cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE cpr)
target_link_libraries(${PROJECT_NAME} PRIVATE mysqlpp)
# 使用 mirai-cpp 静态库
target_compile_definitions(${PROJECT_NAME} PRIVATE MIRAICPP_STATICLIB)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# 链接 pthread
target_link_libraries(${PROJECT_NAME} PRIVATE pthread)
# 静态链接 libgcc 和 libstdc++
target_link_libraries(${PROJECT_NAME} PRIVATE -static-libgcc -static-libstdc++)
endif()
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
include (CPack)