-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
192 lines (160 loc) · 6.69 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Copyright (C) 2023 VITALISED & Contributors
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.15)
project(
renms
LANGUAGES C CXX
VERSION 0.3
)
# find_package( Python3 COMPONENTS Development Interpreter REQUIRED )
# ==================================================================================================
# Includes
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# This is a horror
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/cppsharp-cmake"
${CMAKE_MODULE_PATH}
)
include(AddSubmoduleDependency)
include(ConfigParser)
include(PrefixSourceFile)
# ==================================================================================================
# Local features
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
# Set the output directory properly.
set(RENMS_METADATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/metadata)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
message(
STATUS "Binaries will be placed in: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
)
# Fix a problem with Ninja where it doesn't place a newline and the first
# cmake output is on the same line as Ninja's.
if(CMAKE_GENERATOR STREQUAL "Ninja")
message("")
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# ==============================================================================================
# Config Stuff
if(EXISTS "${CMAKE_SOURCE_DIR}/config.cmake")
include(${CMAKE_SOURCE_DIR}/config.cmake)
else()
file(COPY_FILE ${CMAKE_SOURCE_DIR}/config-template.cmake
${CMAKE_SOURCE_DIR}/config.cmake
)
message(
FATAL_ERROR
"A config.cmake was not found! One was made for you, but we need to know where your install of NMS 2.13 is.\n\
Look inside the config.cmake for the option, and set it's exact path. \
It must end with NMS.exe. See the BUILD.md for why it needs to know this."
)
endif()
parse_config_values_renms()
# ==============================================================================================
else()
if(NOT DEFINED RENMS_METADATA_DIR)
message(
FATAL_ERROR
"You don't have RENMS_METADATA_DIR set! You need a copy of ReNMS metadata, you can get it at https://github.com/VITALISED/metadata"
)
endif()
include(DefaultConfig)
endif()
# ==================================================================================================
# Dependencies. find_package(Python3 REQUIRED)
set(SPDLOG_FMT_EXTERNAL ON)
set(SPDLOG_BUILD_SHARED OFF)
set(POLYHOOK_BUILD_STATIC_RUNTIME OFF)
add_library(renms_submodule_dependencies INTERFACE)
invoke_adding_dependencies_renms()
# ==================================================================================================
# Targets.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
add_subdirectory(common)
add_subdirectory(skyscraper)
add_subdirectory(sdk)
add_subdirectory(renms)
add_subdirectory(tools)
add_subdirectory(docs)
file(
GLOB_RECURSE
SOURCES_TO_ADD_COMMENTS
${CMAKE_CURRENT_SOURCE_DIR}/skyscraper/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/skyscraper/*.h
${CMAKE_CURRENT_SOURCE_DIR}/renms/*.h
${CMAKE_CURRENT_SOURCE_DIR}/renms/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/heridium/*.h
${CMAKE_CURRENT_SOURCE_DIR}/tools/heridium/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sdk/*.h
${CMAKE_CURRENT_SOURCE_DIR}/sdk/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/*.h
${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp
)
foreach(SOURCE_ITEM ${SOURCES_TO_ADD_COMMENTS})
add_sources_prefix_renms(${SOURCE_ITEM})
endforeach()
# Make sure warnings about conversion from NULL to a pointer are disabled with
# non-MSVC compilers.
if(NOT DEFINED MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null")
endif()
# --------------------------------------------------------------------------------------------------
# uberclean - A completely thorough clean that removes EVERYTHING that isn't
# included in the repo, including submodules. Useful for debugging build issues.
add_custom_target(
uberclean
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_CURRENT_SOURCE_DIR}/metadata
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_SOURCE_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_CURRENT_SOURCE_DIR}/docs/doxygen/html
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_CURRENT_SOURCE_DIR}/docs/doxygen/latex
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_CURRENT_SOURCE_DIR}/docs/doxygen/xml
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_CURRENT_SOURCE_DIR}/build
)
# --------------------------------------------------------------------------------------------------
# metadata_generator - Generates the metadata classes for renms, giving it
# enough headers to make plugins for it.
make_directory(${CMAKE_CURRENT_SOURCE_DIR}/metadata)
add_custom_target(
metadata_generator DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/metadata/metadata.h
)
if(NOT ${SKIP_NMS_CHECK})
add_dependencies(metadata_generator heridium relauncher)
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/metadata/metadata.h
COMMAND "$<TARGET_FILE:relauncher>" "${NMS_EXE_PATH}"
"$<TARGET_FILE:heridium>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/metadata
DEPENDS heridium
)
# ==================================================================================================
# Launch target
get_filename_component(NMS_BIN_PATH "${NMS_EXE_PATH}" DIRECTORY)
# Make sure the past installer's leftovers are uninstalled first!
add_custom_target(
renms_launch
COMMAND $<TARGET_FILE:relauncher> ${NMS_EXE_PATH} $<TARGET_FILE:renms_core>
WORKING_DIRECTORY ${NMS_BIN_PATH}
DEPENDS renms_core relauncher
)