Lucas-Bot/CMakeLists.txt

56 lines
1.7 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 最低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)
if (MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
endif (MSVC)
# 添加动态库编译目标
add_library(
MiraiCPPlugin
SHARED
single_include/MiraiCP/MiraiCP.cpp # MiraiCP 源文件
${PLUGIN_SOURCE_PATH})
# 引入全部头文件路径
target_include_directories(MiraiCPPlugin PUBLIC ${SOURCE_HEADER_PATH})
# 插件移植性
if (WIN32)
if (MINGW)
target_link_libraries(MiraiCPPlugin -static
${CMAKE_CURRENT_SOURCE_DIR}/lib/libHttp.dll.a
${CMAKE_CURRENT_SOURCE_DIR}/lib/libPerson.dll.a)
else (MSVC)
target_link_libraries(MiraiCPPlugin -static
${CMAKE_CURRENT_SOURCE_DIR}/lib/Http.lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/Person.lib)
endif()
endif (WIN32)
if (UNIX)
target_link_libraries(MiraiCPPlugin -static-libstdc++ -static-libgcc)
endif (UNIX)