-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (108 loc) · 3 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
cmake_minimum_required(VERSION 3.12)
# Define project.
project( "" # Mod name (required)
VERSION "0.1.0" # Mod version (required)
DESCRIPTION "" # Mod description (optional)
HOMEPAGE_URL "" # Mod homepage (optional)
LANGUAGES C
)
set(PROJECT_MINIMUM_MRE_VERSION # Mod minimum MRE version (optional)
""
)
set(PROJECT_AUTHORS # List of mod authors (optional)
""
)
# Update this as you add new source files.
set(SRC
src/moddef.c
)
# Prepare mod information for inclusion in ModInfo.json.
list(JOIN PROJECT_AUTHORS "\",\"" PROJECT_AUTHORS_JSON)
# Set cmake defaults.
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "lib${PROJECT_NAME}-${PROJECT_VERSION}"
CACHE PATH "..." FORCE
)
endif()
# Include CPack.
set(CPACK_GENERATOR "TXZ")
set(CPACK_PACKAGE_FILE_NAME "lib${PROJECT_NAME}-${PROJECT_VERSION}")
include(CPack)
# Include GenerateExportHeader.
include(GenerateExportHeader)
# Include AERMRE.
set(AERMRE_SCRIPT_REL "aer/mre/lib/cmake/AERMRETargets.cmake")
include("$ENV{AER_GAMEDIR}/${AERMRE_SCRIPT_REL}")
# Instantiate ModInfo template.
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ModInfo.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/ModInfo.json"
@ONLY
)
# Add mod shared library target.
add_library(${PROJECT_NAME} SHARED ${SRC})
generate_export_header(${PROJECT_NAME}
BASE_NAME MOD
EXPORT_FILE_NAME include/export.h
)
set_target_properties(${PROJECT_NAME} PROPERTIES
C_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN TRUE
)
target_include_directories(${PROJECT_NAME}
PRIVATE include "${CMAKE_CURRENT_BINARY_DIR}/include"
)
target_compile_options(${PROJECT_NAME}
PRIVATE
-m32
-Wall
-Wextra
-Werror
-Wfatal-errors
-Wno-error=deprecated-declarations
-Wno-error=unused-but-set-parameter
-Wno-error=unused-but-set-variable
-Wno-error=unused-function
-Wno-error=unused-label
-Wno-error=unused-local-typedefs
-Wno-error=unused-parameter
-Wno-error=unused-result
-Wno-error=unused-variable
-Wno-error=unused-const-variable
-Wno-error=unused-value
)
target_link_options(${PROJECT_NAME}
PRIVATE -m32 -rdynamic
)
target_link_libraries(${PROJECT_NAME}
PRIVATE AERMRE::aermre
)
# Add installation target.
install(TARGETS
${PROJECT_NAME}
LIBRARY DESTINATION "lib"
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/ModInfo.json"
DESTINATION "."
)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt"
DESTINATION "."
)
endif()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/assets")
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
DESTINATION "."
)
endif()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ACKNOWLEDGMENTS")
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/ACKNOWLEDGMENTS"
DESTINATION "."
)
endif()