Lucas-Bot/CMakeLists.txt

56 lines
1.7 KiB
CMake
Raw Normal View History

2022-10-08 22:47:18 +08:00
# 最低cmake版本
cmake_minimum_required(VERSION 3.10)
# MSVC设置: 以utf8编译
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# C++ 标准17+
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 声明C++项目
project(MiraiCPPlugin LANGUAGES CXX)
# 寻找库的头文件
set(SOURCE_HEADER_PATH
${CMAKE_CURRENT_SOURCE_DIR}/single_include/3rd_include
${CMAKE_CURRENT_SOURCE_DIR}/single_include/3rd_include/curl
${CMAKE_CURRENT_SOURCE_DIR}/single_include/3rd_include/utf8
${CMAKE_CURRENT_SOURCE_DIR}/single_include/3rd_include/utf8/utf8
${CMAKE_CURRENT_SOURCE_DIR}/single_include/MiraiCP
)
# 添加src目录下所有源文件每次新增文件不要修改cmake只需重新执行cmake命令
file(GLOB PLUGIN_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
2022-10-20 13:15:42 +08:00
if (MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
endif (MSVC)
2022-10-08 22:47:18 +08:00
# 添加动态库编译目标
add_library(
MiraiCPPlugin
SHARED
single_include/MiraiCP/MiraiCP.cpp # MiraiCP 源文件
${PLUGIN_SOURCE_PATH})
# 引入全部头文件路径
target_include_directories(MiraiCPPlugin PUBLIC ${SOURCE_HEADER_PATH})
# 插件移植性
if (WIN32)
2022-10-20 13:15:42 +08:00
if (MINGW)
target_link_libraries(MiraiCPPlugin -static
2022-10-08 22:47:18 +08:00
${CMAKE_CURRENT_SOURCE_DIR}/lib/libHttp.dll.a
${CMAKE_CURRENT_SOURCE_DIR}/lib/libPerson.dll.a)
2022-10-20 13:15:42 +08:00
else (MSVC)
target_link_libraries(MiraiCPPlugin -static
${CMAKE_CURRENT_SOURCE_DIR}/lib/Http.lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/Person.lib)
endif()
2022-10-08 22:47:18 +08:00
endif (WIN32)
if (UNIX)
target_link_libraries(MiraiCPPlugin -static-libstdc++ -static-libgcc)
endif (UNIX)