-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
80 lines (65 loc) · 2.88 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
cmake_minimum_required(VERSION 3.26)
set(PROJECT_AUTHOR "FlayaN")
project(
commonlibsse-ng-submodule-template
VERSION 0.0.1
LANGUAGES CXX)
# ##############################################################################
# # Source build guard
# ##############################################################################
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
# ##############################################################################
# # Add CommonLibNG plugin
# ##############################################################################
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(CLIBNGPlugin)
add_simple_commonlibsse_ng_plugin(AUTHOR "${PROJECT_AUTHOR}" LICENSE
"MIT License")
# ##############################################################################
# # Build options
# ##############################################################################
message("Options:")
option(ZIP_TO_DIST "Zip the mod to 7z file in dist." ON)
message("\tZip to dist: ${ZIP_TO_DIST}")
# ##############################################################################
# # Find dependencies
# ##############################################################################
find_path(CLIB_UTIL_INCLUDE_DIRS "ClibUtil/detail/SimpleIni.h")
# ##############################################################################
# # Post target setup
# ##############################################################################
target_include_directories(${PROJECT_NAME} PRIVATE ${CLIB_UTIL_INCLUDE_DIRS})
# ##############################################################################
# # Generates a zip in /dist
# ##############################################################################
if(ZIP_TO_DIST)
set(ZIP_DIR "${CMAKE_CURRENT_BINARY_DIR}/zip")
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory "${ZIP_DIR}"
${CMAKE_SOURCE_DIR}/dist
COMMAND ${CMAKE_COMMAND} -E make_directory "${ZIP_DIR}/SKSE/Plugins"
${CMAKE_SOURCE_DIR}/dist)
message("Copying mod to ${ZIP_DIR}.")
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}>
"${ZIP_DIR}/SKSE/Plugins/"
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}>
"${ZIP_DIR}/SKSE/Plugins/")
set(TARGET_ZIP "${PROJECT_NAME}${PROJECT_VERSION}.7z")
message("Zipping ${ZIP_DIR} to ${CMAKE_SOURCE_DIR}/dist/${TARGET_ZIP}")
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_SOURCE_DIR}/dist/${TARGET_ZIP}
--format=7zip -- .
WORKING_DIRECTORY ${ZIP_DIR})
endif()