-
Notifications
You must be signed in to change notification settings - Fork 54
/
CMakeLists.txt
288 lines (273 loc) · 11 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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
PROJECT (stonesense)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
include_directories (${CMAKE_SOURCE_DIR})
SET(PROJECT_SRCS
TrackingModes.cpp
#Overlay.cpp
Tile.cpp
TileCondition.cpp
TileTree.cpp
BuildingConfiguration.cpp
ColorConfiguration.cpp
ConditionalSprite.cpp
Config.cpp
Constructions.cpp
ContentBuildingReader.cpp
ContentLoader.cpp
CreatureConfiguration.cpp
Creatures.cpp
DumpInfo.cpp
FluidConfiguration.cpp
GUI.cpp
GameBuildings.cpp
GroundMaterialConfiguration.cpp
ItemConfiguration.cpp
MapLoading.cpp
SegmentProcessing.cpp
OcclusionTest.cpp
SpriteColors.cpp
SpriteMaps.cpp
SpriteObjects.cpp
TreeGrowthConfiguration.cpp
UserInput.cpp
WorldSegment.cpp
VegetationConfiguration.cpp
Keybinds.cpp
EnumToString.cpp
MaterialMatcher.cpp
TiletypeMatcher.cpp
ConnectionState.cpp
main.cpp
)
#proto files to include.
SET(PROJECT_HDRS
BuildingConfiguration.h
ColorConfiguration.h
common.h
commonTypes.h
ConditionalSprite.h
Config.h
ConnectionState.h
Constructions.h
ContentBuildingReader.h
ContentLoader.h
CreatureConfiguration.h
Creatures.h
DumpInfo.h
EnumToString.h
FluidConfiguration.h
GameBuildings.h
GroundMaterialConfiguration.h
GUI.h
ItemConfiguration.h
MapLoading.h
MaterialMatcher.h
OcclusionTest.h
#Overlay.h
SegmentProcessing.h
SpriteColors.h
SpriteMaps.h
SpriteObjects.h
Tile.h
TileCondition.h
TileDirection.h
TileTree.h
TiletypeMatcher.h
TrackingModes.h
TreeGrowthConfiguration.h
UserInput.h
VegetationConfiguration.h
WorldSegment.h
)
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
# mash them together (headers are marked as headers and nothing will try to compile them)
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
IF(UNIX)
IF(APPLE)
# Mac OS X
OPTION(STONESENSE_INTERNAL_DYLIB "Link with prebuilt internal allegro libs and headers." ON)
IF(STONESENSE_INTERNAL_DYLIB)
set(ALLEGRO_DOWNLOAD_DIR ${stonesense_SOURCE_DIR}/allegro/osx${DFHACK_BUILD_ARCH})
if("${DFHACK_BUILD_ARCH}" STREQUAL "64")
set(ALLEGRO_DOWNLOAD_FILE "osx64-allegro-5.2.2.tar.bz2")
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/osx64-allegro-5.2.2.tar.bz2"
"${ALLEGRO_DOWNLOAD_DIR}/${ALLEGRO_DOWNLOAD_FILE}"
"306e8981bf67cf8b3f9ac0b26003869e")
else()
set(ALLEGRO_DOWNLOAD_FILE "osx32-allegro-5.0.11.tar.bz2")
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/osx32-allegro-5.0.11.tar.bz2"
"${ALLEGRO_DOWNLOAD_DIR}/${ALLEGRO_DOWNLOAD_FILE}"
"c531eb16f2530e1168116fcbce7644df")
endif()
execute_process(COMMAND tar xjf "${ALLEGRO_DOWNLOAD_DIR}/${ALLEGRO_DOWNLOAD_FILE}" --strip-components=1
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR})
# Download freetype only on x64
if("${DFHACK_BUILD_ARCH}" STREQUAL "64")
download_file_unzip("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/osx64-libfreetype.6.dylib.gz"
"gz"
${ALLEGRO_DOWNLOAD_DIR}/lib/libfreetype.6.dylib.gz
"f4c4005a53a353802492ab1a76f188b6"
${ALLEGRO_DOWNLOAD_DIR}/lib/libfreetype.6.dylib
"f593477141d6f10c510dca7dbc10dab8")
endif()
SET(PROJECT_LIBS
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro.dylib
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_primitives.dylib
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_font.dylib
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_color.dylib
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_image.dylib
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_ttf.dylib
${PROJECT_LIBS}
)
include_directories (
${include_directories}
${ALLEGRO_DOWNLOAD_DIR}/include
${ALLEGRO_DOWNLOAD_DIR}/lib/Headers
)
if(BUILD_PLUGINS)
install(DIRECTORY ${ALLEGRO_DOWNLOAD_DIR}/lib/
DESTINATION ${DFHACK_LIBRARY_DESTINATION})
endif()
ELSE()
SET(PROJECT_LIBS
allegro
allegro_primitives
allegro_font
allegro_color
allegro_image
allegro_ttf
${PROJECT_LIBS}
)
ENDIF()
ELSE(APPLE)
#linux
OPTION(STONESENSE_INTERNAL_SO "Link with prebuilt internal allegro libs and headers." ON)
IF(STONESENSE_INTERNAL_SO)
set(ALLEGRO_DOWNLOAD_DIR ${stonesense_SOURCE_DIR}/allegro/linux${DFHACK_BUILD_ARCH})
if("${DFHACK_BUILD_ARCH}" STREQUAL "64")
set(ALLEGRO_DOWNLOAD_FILE "linux64-allegro5010.tar.gz")
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/linux64-allegro5010.tar.gz"
"${ALLEGRO_DOWNLOAD_DIR}/${ALLEGRO_DOWNLOAD_FILE}"
"343f44224ee61508b89b11adb35a4dd9")
else()
set(ALLEGRO_DOWNLOAD_FILE "linux32-allegro509b.tar.bz2")
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/linux32-allegro509b.tar.bz2"
"${ALLEGRO_DOWNLOAD_DIR}/${ALLEGRO_DOWNLOAD_FILE}"
"74ead5d95a83a03a301cdc76fa0a3df8")
endif()
execute_process(COMMAND tar xf "${ALLEGRO_DOWNLOAD_DIR}/${ALLEGRO_DOWNLOAD_FILE}" --strip-components=1
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR})
execute_process(COMMAND patchelf --force-rpath --set-rpath hack liballegro_image.so.5.0.10
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR}/lib)
SET(PROJECT_LIBS
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro.so.5.0
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_primitives.so.5.0
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_font.so.5.0
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_image.so.5.0
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_ttf.so.5.0
${ALLEGRO_DOWNLOAD_DIR}/lib/liballegro_color.so.5.0
${PROJECT_LIBS}
)
include_directories (
${include_directories}
${ALLEGRO_DOWNLOAD_DIR}/include
)
if(BUILD_PLUGINS)
install(DIRECTORY ${ALLEGRO_DOWNLOAD_DIR}/lib/
DESTINATION ${DFHACK_LIBRARY_DESTINATION})
endif()
ELSE()
SET(PROJECT_LIBS
allegro
allegro_primitives
allegro_font
allegro_image
allegro_ttf
allegro_color
${PROJECT_LIBS}
)
ENDIF()
ENDIF()
# windows
ELSE(UNIX)
SET(ALLEGRO_DOWNLOAD_DIR ${stonesense_SOURCE_DIR}/win${DFHACK_BUILD_ARCH})
IF(DFHACK_BUILD_64)
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-allegro-msvc2015-x64-5.1.12.zip"
${ALLEGRO_DOWNLOAD_DIR}/allegro-msvc2015-x64-5.1.12.zip
"3abb0bd88251efde001a8b65fdf17683")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ALLEGRO_DOWNLOAD_DIR}/allegro-msvc2015-x64-5.1.12.zip
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR})
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-allegro_deps-msvc2015-x64-1.2.0.zip"
${ALLEGRO_DOWNLOAD_DIR}/allegro_deps-msvc2015-x64-1.2.0.zip
"eb8d0f4569b84c36bef3733b40b00c72")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ALLEGRO_DOWNLOAD_DIR}/allegro_deps-msvc2015-x64-1.2.0.zip
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR})
ELSE()
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win32-allegro-msvc2015-x86-5.1.12.zip"
${ALLEGRO_DOWNLOAD_DIR}/allegro-msvc2015-x86-5.1.12.zip
"86e6aeea828743107dc1f3a3d562e53d")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ALLEGRO_DOWNLOAD_DIR}/allegro-msvc2015-x86-5.1.12.zip
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR})
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win32-allegro_deps-msvc2015-x86-1.2.0.zip"
${ALLEGRO_DOWNLOAD_DIR}/allegro_deps-msvc2015-x86-1.2.0.zip
"be096bfef256cb113e25dbb2eb7fd410")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ALLEGRO_DOWNLOAD_DIR}/allegro_deps-msvc2015-x86-1.2.0.zip
WORKING_DIRECTORY ${ALLEGRO_DOWNLOAD_DIR})
ENDIF()
ADD_DEFINITIONS("-DALLEGRO_STATICLINK")
SET(PROJECT_LIBS
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
allegro-static.lib
allegro_primitives-static.lib
allegro_font-static.lib
allegro_image-static.lib
allegro_ttf-static.lib
allegro_color-static.lib
freetype.lib
libpng16.lib
jpeg.lib
zlib.lib
winmm.lib
psapi.lib
opengl32.lib
glu32.lib
gdiplus.lib
shlwapi.lib
)
include_directories (
${include_directories}
${stonesense_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/allegro/include
${stonesense_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/allegro_deps/include
)
LINK_DIRECTORIES(
${LINK_DIRECTORIES}
${stonesense_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/allegro/lib
${stonesense_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/allegro_deps/lib
)
ENDIF(UNIX)
set(STONESENSE_GCC_FLAGS "")
if(UNIX AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER 6.0)
set(STONESENSE_GCC_FLAGS "${STONESENSE_GCC_FLAGS} -Wno-misleading-indentation")
endif()
DFHACK_PLUGIN(stonesense ${PROJECT_SRCS} LINK_LIBRARIES ${DFHACK_TINYXML} ${PROJECT_LIBS} COMPILE_FLAGS_MSVC "/FI\"Export.h\" /wd4312 /wd4996 /wd4251" COMPILE_FLAGS_GCC "-include Export.h ${STONESENSE_GCC_FLAGS}")
IF(MSVC)
# Ignore unhelpful warnings about debug symbols being missing.
SET_TARGET_PROPERTIES(stonesense PROPERTIES LINK_FLAGS "/ignore:4098 /ignore:4099")
ENDIF(MSVC)
IF(APPLE)
add_custom_command(TARGET stonesense POST_BUILD COMMAND ${stonesense_SOURCE_DIR}/fix-libs-stonesense.sh WORKING_DIRECTORY . COMMENT "Fixing Stonesense library dependencies...")
ENDIF(APPLE)
if(INSTALL_DATA_FILES)
#install resources and readme into DF/stonesense
install(DIRECTORY resources/ DESTINATION stonesense)
install(FILES README.md DESTINATION stonesense)
endif()