-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
84 lines (74 loc) · 3.34 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
82
83
84
cmake_minimum_required(VERSION 3.21)
project(
SpellLevelAutomaticAdjustedDescription
VERSION 0.7.5
LANGUAGES CXX
)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# ########################################################################################################################
# ## Build options
# ########################################################################################################################
message("Options:")
option(AUTO_PLUGIN_DEPLOYMENT "Copy the build output and addons to env:SamplePluginOutputDir." OFF)
option(ZIP_TO_DIST "Zip the base mod and addons to their own 7z file in dist." ON)
option(AIO_ZIP_TO_DIST "Zip the base mod and addons to a AIO 7z file in dist." OFF)
message("\tAuto plugin deployment: ${AUTO_PLUGIN_DEPLOYMENT}")
message("\tZip to dist: ${ZIP_TO_DIST}")
message("\tAIO Zip to dist: ${AIO_ZIP_TO_DIST}")
# #######################################################################################################################
# # Add CMake features
# #######################################################################################################################
include(XSEPlugin)
# #######################################################################################################################
# # Find dependencies
# #######################################################################################################################
find_package(magic_enum CONFIG REQUIRED)
find_package(xbyak CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_path(CLIB_UTIL_INCLUDE_DIRS "ClibUtil/utils.hpp")
target_include_directories(
${PROJECT_NAME}
PRIVATE
${CLIB_UTIL_INCLUDE_DIRS}
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
magic_enum::magic_enum
xbyak::xbyak
nlohmann_json::nlohmann_json
)
# https://gitlab.kitware.com/cmake/cmake/-/issues/24922#note_1371990
if(MSVC_VERSION GREATER_EQUAL 1936 AND MSVC_IDE) # 17.6+
# When using /std:c++latest, "Build ISO C++23 Standard Library Modules" defaults to "Yes".
# Default to "No" instead.
#
# As of CMake 3.26.4, there isn't a way to control this property
# (https://gitlab.kitware.com/cmake/cmake/-/issues/24922),
# We'll use the MSBuild project system instead
# (https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure)
file(CONFIGURE OUTPUT "${CMAKE_BINARY_DIR}/Directory.Build.props" CONTENT [==[
<Project>
<ItemDefinitionGroup>
<ClCompile>
<BuildStlModules>false</BuildStlModules>
</ClCompile>
</ItemDefinitionGroup>
</Project>
]==] @ONLY)
endif()
# #######################################################################################################################
# # Automatic deployment
# #######################################################################################################################
if(AUTO_PLUGIN_DEPLOYMENT)
foreach(DEPLOY_TARGET $ENV{SamplePluginOutputDir})
message("Copying AIO to ${DEPLOY_TARGET}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> "${DEPLOY_TARGET}/SKSE/Plugins/"
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> "${DEPLOY_TARGET}/SKSE/Plugins/"
)
endforeach()
if(NOT DEFINED ENV{SamplePluginOutputDir})
message("When using AUTO_PLUGIN_DEPLOYMENT option, you need to set environment variable 'SamplePluginOutputDir'")
endif()
endif()