forked from ccdevnet/openc2e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
363 lines (328 loc) · 10.4 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
PROJECT (OPENC2E CXX C)
SET(SRC "${OPENC2E_SOURCE_DIR}")
SET(BIN "${OPENC2E_BINARY_DIR}")
SET(GEN "${BIN}/generated")
EXECUTE_PROCESS(COMMAND mkdir -p "${GEN}")
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1)
SET(CMAKE_MODULE_PATH "${SRC}/cmake")
SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "The type of build to perform. Valid values are: RelWithDebInfo (default), Debug, Release, MinSizeRel")
IF (CMAKE_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "The type of build to perform. Valid values are: RelWithDebInfo (default), Debug, Release, MinSizeRel" FORCE)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "")
SET(OPENC2E_USE_QT "TRUE" CACHE BOOL "Build the qt GUI")
SET(OPENC2E_USE_OPENAL "AUTO" CACHE STRING "Use OpenAL (YES/NO/AUTO)")
IF (OPENC2E_USE_OPENAL MATCHES "^(YES|NO|AUTO)$")
ELSE (OPENC2E_USE_OPENAL MATCHES "^(YES|NO|AUTO)$")
MESSAGE(SEND_ERROR "The value of OPENC2E_USE_OPENAL must be YES, NO, or AUTO.")
ENDIF (OPENC2E_USE_OPENAL MATCHES "^(YES|NO|AUTO)$")
SET(OPENC2E_USE_SERIALIZATION "FALSE" CACHE BOOL "Build the experimental serialization code")
MARK_AS_ADVANCED(FORCE OPENC2E_USE_SERIALIZATION)
IF (OPENC2E_USE_SERIALIZATION)
SET(SER_SRCS src/caos/caosVM_ser_real.cpp)
ELSE (OPENC2E_USE_SERIALIZATION)
SET(SER_SRCS src/caos/caosVM_ser_stub.cpp)
ENDIF (OPENC2E_USE_SERIALIZATION)
SET(OPENC2E_PROFILE_ALLOCATION "FALSE" CACHE BOOL "Collect allocation profile stats for DBG: SIZO")
MARK_AS_ADVANCED(FORCE OPENC2E_PROFILE_ALLOCATION)
IF (OPENC2E_PROFILE_ALLOCATION)
ADD_DEFINITIONS("-DPROFILE_ALLOCATION_COUNT -DPROFILE_ALLOCATION_THREAD_SAFE")
ENDIF (OPENC2E_PROFILE_ALLOCATION)
SET(OPENC2E_CORE
src/Agent.cpp
src/AgentHelpers.cpp
src/AgentRef.cpp
src/alloc_count.cpp
src/attFile.cpp
src/Backend.cpp
src/Blackboard.cpp
src/images/blkImage.cpp
src/images/bmpImage.cpp
src/Bubble.cpp
src/bytecode.cpp
src/images/c16Image.cpp
src/c2eBrain.cpp
src/CallButton.cpp
src/Camera.cpp
src/caosScript.cpp
src/caosVar.cpp
src/caos/caosVM_agent.cpp
src/caos/caosVM_camera.cpp
src/caos/caosVM_compound.cpp
src/caos/caosVM_core.cpp
src/caos/caosVM_creatures.cpp
src/caos/caosVM_debug.cpp
src/caos/caosVM_files.cpp
src/caos/caosVM_flow.cpp
src/caos/caosVM_genetics.cpp
src/caos/caosVM_history.cpp
src/caos/caosVM_input.cpp
src/caos/caosVM_map.cpp
src/caos/caosVM_motion.cpp
src/caos/caosVM_net.cpp
src/caosVM.cpp
src/caos/caosVM_ports.cpp
src/caos/caosVM_resources.cpp
src/caos/caosVM_scripts.cpp
src/caos/caosVM_sounds.cpp
src/caos/caosVM_time.cpp
src/caos/caosVM_variables.cpp
src/caos/caosVM_vectors.cpp
src/caos/caosVM_vehicles.cpp
src/caos/caosVM_world.cpp
${GEN}/cataloglexer.cpp
src/Catalogue.cpp
${GEN}/catalogue.tab.cpp
${GEN}/cmddata.cpp
src/cobFile.cpp
src/CompoundAgent.cpp
src/CompoundCreature.cpp
src/CompoundPart.cpp
src/Creature.cpp
src/CreatureAgent.cpp
src/creaturesImage.cpp
src/dialect.cpp
src/Engine.cpp
src/exceptions.cpp
src/fileSwapper.cpp
src/genomeFile.cpp
src/historyManager.cpp
src/imageManager.cpp
${GEN}/mnglexer.cpp
${GEN}/caoslexer.cpp
src/Lift.cpp
src/Map.cpp
src/MetaRoom.cpp
src/mmapifstream.cpp
src/music/mngfile.cpp
${GEN}/mngparser.tab.cpp
src/MusicManager.cpp
src/oldBrain.cpp
src/PathResolver.cpp
src/peFile.cpp
src/physics.cpp
src/PointerAgent.cpp
src/Port.cpp
src/pray.cpp
src/prayManager.cpp
src/renderable.cpp
src/Room.cpp
src/Scriptorium.cpp
src/SFCFile.cpp
src/SimpleAgent.cpp
src/SkeletalCreature.cpp
src/images/sprImage.cpp
src/streamutils.cpp
src/Vehicle.cpp
src/World.cpp
src/main.cpp
src/util.cpp
)
SET(OPENC2E_SDL
src/backends/SDLBackend.cpp
)
SET(OPENC2E_QT
src/backends/qtgui/qtopenc2e.cpp
src/backends/qtgui/openc2eview.cpp
src/backends/qtgui/AgentInjector.cpp
src/backends/qtgui/BrainViewer.cpp
src/backends/qtgui/imagepreview.cpp
src/backends/qtgui/c1cobfile.cpp
src/backends/qtgui/QtBackend.cpp
src/backends/qtgui/GraphWidget.cpp
src/backends/qtgui/CreatureGrapher.cpp
src/backends/qtgui/ChemicalSelector.cpp
src/backends/qtgui/Hatchery.cpp
src/tools/braininavat/brainview.cpp)
SET(OPENC2E_QT_MOC_HDRS
src/backends/qtgui/qtopenc2e.h
src/backends/qtgui/openc2eview.h
src/backends/qtgui/AgentInjector.h
src/backends/qtgui/BrainViewer.h
src/backends/qtgui/imagepreview.h
src/backends/qtgui/GraphWidget.h
src/backends/qtgui/CreatureGrapher.h
src/backends/qtgui/ChemicalSelector.h
src/backends/qtgui/Hatchery.h
src/tools/braininavat/brainview.h)
SET(OPENC2E_QT_UIS
src/backends/qtgui/agents.ui)
#
cmake_minimum_required(VERSION 2.4.0)
INCLUDE(TestBigEndian)
INCLUDE(CheckIncludeFile)
TEST_BIG_ENDIAN(BIG_ENDIAN)
IF(BIG_ENDIAN)
ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=1")
CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
IF(HAVE_BYTESWAP_H)
ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=1")
ELSE(HAVE_BYTESWAP_H)
ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=0")
ENDIF(HAVE_BYTESWAP_H)
ELSE(BIG_ENDIAN)
ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=0")
ENDIF(BIG_ENDIAN)
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
IF(HAVE_STDINT_H)
ADD_DEFINITIONS("-DHAVE_STDINT_H=1")
ELSE(HAVE_STDINT_H)
ENDIF(HAVE_STDINT_H)
FIND_PACKAGE(SDL REQUIRED)
FIND_PACKAGE(SDL_mixer)
FIND_PACKAGE(SDL_net REQUIRED)
FIND_PACKAGE(SDL_gfx REQUIRED)
FIND_PACKAGE(SDL_ttf REQUIRED)
IF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
FIND_PACKAGE(OpenAL)
ELSE(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
SET(OPENAL_FOUND "NO")
ENDIF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
FIND_PACKAGE(ALUT)
FIND_PACKAGE(Boost 1.34.0 COMPONENTS program_options filesystem thread regex serialization REQUIRED)
FIND_LIBRARY(BOOST_SYSTEM_LIBRARY NAMES boost_system-mt)
IF(OPENC2E_USE_QT)
find_package(Qt4 REQUIRED)
ENDIF(OPENC2E_USE_QT)
SET(USE_OPENAL "NO")
IF(OPENAL_FOUND STREQUAL "YES")
IF(ALUT_FOUND STREQUAL "YES")
SET(USE_OPENAL "YES")
ENDIF(ALUT_FOUND STREQUAL "YES")
ENDIF(OPENAL_FOUND STREQUAL "YES")
IF(USE_OPENAL STREQUAL "NO")
IF (OPENC2E_USE_OPENAL MATCHES "^YES")
MESSAGE(FATAL_ERROR "OpenAL not found.")
ENDIF (OPENC2E_USE_OPENAL MATCHES "^YES")
SET(ALUT_INCLUDE_DIR "")
SET(OPENAL_INCLUDE_DIR "")
SET(ALUT_LIBRARY "")
SET(OPENAL_LIBRARY "")
SET(OPENAL_SRC "")
SET(OPENAL_DEF "")
ELSE(USE_OPENAL STREQUAL "NO")
SET(OPENAL_SRC "src/backends/OpenALBackend.cpp")
SET(OPENAL_DEF "-DOPENAL_SUPPORT")
ENDIF(USE_OPENAL STREQUAL "NO")
IF(SDLMIXER_FOUND)
SET(SDLMIXER_SRC "src/backends/SDLMixerBackend.cpp")
SET(SDLMIXER_DEF "-DSDLMIXER_SUPPORT")
ELSE(SDLMIXER_FOUND)
SET(SDLMIXER_INCLUDE_DIR "")
SET(SDLMIXER_LIBRARY "")
SET(SDLMIXER_SRC "")
SET(SDLMIXER_DEF "")
ENDIF(SDLMIXER_FOUND)
IF(OPENC2E_USE_QT)
include(${QT_USE_FILE})
SET(SAVED_CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_BINARY_DIR)
SET(CMAKE_CURRENT_BINARY_DIR ${GEN})
QT4_WRAP_UI(OPENC2E_QT_UIS_H ${OPENC2E_QT_UIS})
QT4_WRAP_CPP(OPENC2E_QT_MOC_SRCS ${OPENC2E_QT_MOC_HDRS})
SET(CMAKE_CURRENT_BINARY_DIR SAVED_CMAKE_CURRENT_BINARY_DIR)
SET(QT_DEF "-DQT_SUPPORT")
ENDIF(OPENC2E_USE_QT)
# Pass flags to the compiler
ADD_DEFINITIONS("-W -Wall -Wno-conversion -Wno-unused -D_REENTRANT -DYYERROR_VERBOSE ${OPENAL_DEF} ${QT_DEF} ${SDLMIXER_DEF}")
IF(OPENC2E_USE_QT)
SET(FRONTEND_SRCS ${OPENC2E_SDL} ${OPENC2E_QT} ${OPENC2E_QT_UIS_H} ${OPENC2E_QT_MOC_SRCS})
SET(FRONTEND_LIBS ${QT_LIBRARIES})
ELSE(OPENC2E_USE_QT)
SET(FRONTEND_SRCS ${OPENC2E_SDL})
SET(FRONTEND_LIBS)
ENDIF(OPENC2E_USE_QT)
ADD_EXECUTABLE(openc2e ${OPENC2E_CORE} ${FRONTEND_SRCS} ${OPENAL_SRC} ${SDLMIXER_SRC} ${SER_SRCS})
TARGET_LINK_LIBRARIES(openc2e z m pthread
${SDL_LIBRARY}
${SDLNET_LIBRARY}
${SDLTTF_LIBRARY}
${SDLGFX_LIBRARY}
${SDLMIXER_LIBRARY}
${OPENAL_LIBRARY}
${ALUT_LIBRARY}
${FRONTEND_LIBS}
boost_program_options-mt
boost_serialization-mt
boost_filesystem-mt
boost_thread-mt
boost_regex-mt
)
IF(BOOST_SYSTEM_LIBRARY)
TARGET_LINK_LIBRARIES(openc2e boost_system-mt)
ENDIF(BOOST_SYSTEM_LIBRARY)
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(BEFORE
${GEN}
${SRC}/src
${SDL_INCLUDE_DIR}
${SDLNET_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${SDLGFX_INCLUDE_DIR}
${SDLMIXER_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${ALUT_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
)
FILE(GLOB CAOSVM_FILES ${SRC}/src/caos/caosVM_*.cpp)
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/commandinfo.yml
COMMAND perl parsedocs.pl ${CAOSVM_FILES} > ${GEN}/commandinfo.yml
DEPENDS parsedocs.pl ${CAOSVM_FILES}
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${BIN}/caosdocs.html
COMMAND perl docs/writehtml.pl ${GEN}/commandinfo.yml > ${BIN}/caosdocs.html
DEPENDS docs/writehtml.pl ${GEN}/commandinfo.yml
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${BIN}/docs.css
COMMAND cp docs/docs.css ${BIN}/docs.css
DEPENDS docs/docs.css
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${BIN}/openc2e.6
COMMAND pod2man --center="Openc2e Documentation" --section=6 ${SRC}/docs/openc2e.pod ${BIN}/openc2e.6
DEPENDS docs/openc2e.pod
)
# it seems these ADD_CUSTOM_COMMANDS for flex and bison could be made
# into a macro... e.g. FLEX(file1) FLEX(file2) etc...
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/cataloglexer.cpp
COMMAND re2c -o ${GEN}/cataloglexer.cpp ${SRC}/src/cataloglexer.re2c
DEPENDS ${SRC}/src/cataloglexer.re2c
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
COMMAND bison -d --name-prefix=cata --file-prefix="${GEN}/catalogue" src/catalogue.ypp
DEPENDS src/catalogue.ypp
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/cmddata.cpp
COMMAND perl writecmds.pl ${GEN}/commandinfo.yml > ${GEN}/cmddata.cpp
DEPENDS ${GEN}/commandinfo.yml writecmds.pl
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/caoslexer.cpp
COMMAND re2c -o ${GEN}/caoslexer.cpp ${SRC}/src/caoslexer.re2c
DEPENDS ${SRC}/src/caoslexer.re2c
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/mnglexer.cpp
COMMAND re2c -o ${GEN}/mnglexer.cpp ${SRC}/src/music/mnglexer.re2c
DEPENDS ${SRC}/src/music/mnglexer.re2c
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_COMMAND(
OUTPUT ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp
COMMAND bison -d --name-prefix=mng --file-prefix="${GEN}/mngparser" src/music/mngparser.ypp
DEPENDS src/music/mngparser.ypp
WORKING_DIRECTORY ${SRC})
ADD_CUSTOM_TARGET(test DEPENDS openc2e
COMMAND perl ${SRC}/runtests.pl ${SRC}/tests)
ADD_CUSTOM_TARGET(docs ALL DEPENDS ${BIN}/caosdocs.html ${BIN}/docs.css ${BIN}/openc2e.6)
ADD_CUSTOM_TARGET(generated DEPENDS
${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
${GEN}/caoslexer.cpp
${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp
${GEN}/mnglexer.cpp
${GEN}/cataloglexer.cpp
${GEN}/cmddata.cpp
)