summaryrefslogtreecommitdiffstats
path: root/src/CMakeLists.txt
blob: 0897a3275c5d837dac3390c93ee24ec0c9a94dc0 (plain) (blame)
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
target_sources(
	${CMAKE_PROJECT_NAME} PRIVATE

	Resources/Cuberite.rc

	BiomeDef.cpp
	BlockArea.cpp
	BlockInfo.cpp
	BlockType.cpp
	BrewingRecipes.cpp
	Broadcaster.cpp
	BoundingBox.cpp
	ByteBuffer.cpp
	ChatColor.cpp
	Chunk.cpp
	ChunkData.cpp
	ChunkGeneratorThread.cpp
	ChunkMap.cpp
	ChunkSender.cpp
	ChunkStay.cpp
	CircularBufferCompressor.cpp
	ClientHandle.cpp
	Color.cpp
	CommandOutput.cpp
	CompositeChat.cpp
	CraftingRecipes.cpp
	Cuboid.cpp
	DeadlockDetect.cpp
	Defines.cpp
	Enchantments.cpp
	FastRandom.cpp
	FurnaceRecipe.cpp
	Globals.cpp
	IniFile.cpp
	Inventory.cpp
	Item.cpp
	ItemGrid.cpp
	JsonUtils.cpp
	LightingThread.cpp
	LinearInterpolation.cpp
	LoggerListeners.cpp
	Logger.cpp
	Map.cpp
	MapManager.cpp
	MemorySettingsRepository.cpp
	MobCensus.cpp
	MobFamilyCollecter.cpp
	MobProximityCounter.cpp
	MobSpawner.cpp
	MonsterConfig.cpp
	NetherPortalScanner.cpp
	OverridesSettingsRepository.cpp
	ProbabDistrib.cpp
	RankManager.cpp
	RCONServer.cpp
	Root.cpp
	Scoreboard.cpp
	Server.cpp
	SpawnPrepare.cpp
	StatisticsManager.cpp
	StringCompression.cpp
	StringUtils.cpp
	UUID.cpp
	VoronoiMap.cpp
	WebAdmin.cpp
	World.cpp
	main.cpp

	BiomeDef.h
	BlockArea.h
	BlockInServerPluginInterface.h
	BlockInfo.h
	BlockState.h
	BlockType.h
	BrewingRecipes.h
	BoundingBox.h
	BuildInfo.h.cmake
	ByteBuffer.h
	ChatColor.h
	Chunk.h
	ChunkData.h
	ChunkDataCallback.h
	ChunkDef.h
	ChunkGeneratorThread.h
	ChunkMap.h
	ChunkSender.h
	ChunkStay.h
	CircularBufferCompressor.h
	ClientHandle.h
	Color.h
	CommandOutput.h
	CompositeChat.h
	CraftingRecipes.h
	Cuboid.h
	DeadlockDetect.h
	Defines.h
	EffectID.h
	Enchantments.h
	Endianness.h
	FastRandom.h
	ForEachChunkProvider.h
	FurnaceRecipe.h
	FunctionRef.h
	Globals.h
	IniFile.h
	Inventory.h
	Item.h
	ItemGrid.h
	LazyArray.h
	JsonUtils.h
	LightingThread.h
	LinearInterpolation.h
	LinearUpscale.h
	Logger.h
	LoggerListeners.h
	LoggerSimple.h
	Map.h
	MapManager.h
	Matrix4.h
	MemorySettingsRepository.h
	MobCensus.h
	MobFamilyCollecter.h
	MobProximityCounter.h
	MobSpawner.h
	MonsterConfig.h
	NetherPortalScanner.h
	OpaqueWorld.h
	OverridesSettingsRepository.h
	ProbabDistrib.h
	RankManager.h
	RCONServer.h
	Root.h
	Scoreboard.h
	Server.h
	SetChunkData.h
	SettingsRepositoryInterface.h
	SpawnPrepare.h
	StatisticsManager.h
	StringCompression.h
	StringUtils.h
	UUID.h
	Vector3.h
	VoronoiMap.h
	WebAdmin.h
	World.h
	XMLParser.h
	main.h
)

set(FOLDERS
	Bindings BlockEntities Blocks Entities
	Generating HTTP Items mbedTLS++ Mobs Noise
	OSSupport Physics Physics/Tracers Protocol Registries
	Simulator Simulator/IncrementalRedstoneSimulator UI WorldStorage
)

# Add all child source directories:
foreach(folder ${FOLDERS})
	add_subdirectory(${folder})
endforeach(folder)

file(WRITE "${CMAKE_BINARY_DIR}/include/Globals.h"
	"/* This file allows Globals.h to be included with an absolute path */\n#include \"${PROJECT_SOURCE_DIR}/src/Globals.h\"\n")

configure_file("BuildInfo.h.cmake" "${CMAKE_BINARY_DIR}/include/BuildInfo.h")
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_BINARY_DIR}/include/" ".")

# Generate AllFiles.lst for CheckBasicStyle.lua
get_target_property(ALL_FILES ${CMAKE_PROJECT_NAME} SOURCES)
foreach(FILE ${ALL_FILES})
	# target_sources converts to absolute but CheckBasicStyle expects relative
	file(RELATIVE_PATH RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" ${FILE})

	# Convert CMake list into newline-delimited string
	set(ALL_FILES_AS_LINES "${ALL_FILES_AS_LINES}${RELATIVE}\n")
endforeach()
file(WRITE AllFiles.lst "${ALL_FILES_AS_LINES}")

# Output the executable into the $/Server folder, so that it has access to external resources:
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES
	RUNTIME_OUTPUT_DIRECTORY                ${CMAKE_BINARY_DIR}/Server
	RUNTIME_OUTPUT_DIRECTORY_DEBUG          ${CMAKE_BINARY_DIR}/Server
	RUNTIME_OUTPUT_DIRECTORY_RELEASE        ${CMAKE_BINARY_DIR}/Server
	RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/Server
	RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL     ${CMAKE_BINARY_DIR}/Server
	RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE   ${CMAKE_BINARY_DIR}/Server
	RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
)



MACRO(TO_NATIVE_PATH PATH OUT)
	FILE(TO_NATIVE_PATH "${PATH}" "${OUT}")
	IF(MINGW)
		STRING(REPLACE "/" "\\" "${OUT}" "${${OUT}}")
	ENDIF(MINGW)
ENDMACRO(TO_NATIVE_PATH)

# Create a symbolic link from ${orig} to ${link}
# If the orig and link point to the same thing, does nothing (-> in-source build)
# If ${link} already exists, does nothing.
function(make_symlink orig link)
	# If both are the same, or link already exists, bail out:
	if ("${orig}" STREQUAL "${link}")
		return()
	endif()
	if (EXISTS ${link})
		return()
	endif()

	# Create the symlink (platform-dependent):
	message(STATUS "Creating symlink, orig = ${orig}; link = ${link}")
	if (CMAKE_HOST_UNIX)
		set(command ln -s ${orig} ${link})
	else()
		TO_NATIVE_PATH("${orig}" orig)
		TO_NATIVE_PATH("${link}" link)
		if (IS_DIRECTORY ${orig})
			set(command cmd.exe /c mklink /j ${link} ${orig})
		else()
			set(command cmd.exe /c mklink /h ${link} ${orig})
		endif()
	endif()

	execute_process(
		COMMAND ${command}
		RESULT_VARIABLE result
		ERROR_VARIABLE stderr
		OUTPUT_VARIABLE stdout
	)

	if (NOT ${result} EQUAL 0)
		message(FATAL_ERROR "Could not create symbolic link for: ${link} --> ${orig}: ${stderr} ${stdout}")
	endif()
endfunction(make_symlink)





# Populate the output folder with symlinks to the Server folder's internals:
set(symlinks
	Install
	Plugins
	Prefabs
	Protocol
	webadmin
	brewing.txt
	crafting.txt
	favicon.png
	furnace.txt
	items.ini
	monsters.ini
	README.txt
)
message(STATUS "Creating output folder and symlinks...")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Server")
foreach (symlink ${symlinks})
	make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../Server/${symlink}" "${CMAKE_BINARY_DIR}/Server/${symlink}")
endforeach(symlink)
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../BACKERS"                           "${CMAKE_BINARY_DIR}/Server/BACKERS")
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../CONTRIBUTORS"                      "${CMAKE_BINARY_DIR}/Server/CONTRIBUTORS")
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE"                           "${CMAKE_BINARY_DIR}/Server/LICENSE")
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../Server/Install/ThirdPartyLicenses" "${CMAKE_BINARY_DIR}/Server/ThirdPartyLicenses")

# Create a folder for Bindings' documentation:
FILE(MAKE_DIRECTORY "Bindings/docs")
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/Bindings/docs" "${CMAKE_BINARY_DIR}/Server/BindingsDocs")