add non-functional c1 Hatchery
[openc2e.git] / CMakeLists.txt
blob03b29aed4ec27d8ccd70caae6deb802f222d1334
1 PROJECT (OPENC2E CXX C)
3 SET(SRC "${OPENC2E_SOURCE_DIR}")
4 SET(BIN "${OPENC2E_BINARY_DIR}")
5 SET(GEN "${BIN}/generated")
6 EXECUTE_PROCESS(COMMAND mkdir "${GEN}" -p)
8 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1)
9 SET(CMAKE_MODULE_PATH "${SRC}/cmake")
11 SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "The type of build to perform. Valid values are: RelWithDebInfo (default), Debug, Release, MinSizeRel")
12 IF (CMAKE_BUILD_TYPE STREQUAL "")
13         SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "The type of build to perform. Valid values are: RelWithDebInfo (default), Debug, Release, MinSizeRel" FORCE)
14 ENDIF (CMAKE_BUILD_TYPE STREQUAL "")
16 SET(OPENC2E_USE_QT "TRUE" CACHE BOOL "Build the qt GUI")
17 SET(OPENC2E_USE_OPENAL "AUTO" CACHE STRING "Use OpenAL (YES/NO/AUTO)")
18 IF (OPENC2E_USE_OPENAL MATCHES "^(YES|NO|AUTO)$")
19 ELSE (OPENC2E_USE_OPENAL MATCHES "^(YES|NO|AUTO)$")
20         MESSAGE(SEND_ERROR "The value of OPENC2E_USE_OPENAL must be YES, NO, or AUTO.")
21 ENDIF (OPENC2E_USE_OPENAL MATCHES "^(YES|NO|AUTO)$")
23 SET(OPENC2E_USE_SERIALIZATION "FALSE" CACHE BOOL "Build the experimental serialization code")
24 MARK_AS_ADVANCED(FORCE OPENC2E_USE_SERIALIZATION)
25 IF (OPENC2E_USE_SERIALIZATION)
26         SET(SER_SRCS caosVM_ser_real.cpp)
27 ELSE (OPENC2E_USE_SERIALIZATION)
28         SET(SER_SRCS caosVM_ser_stub.cpp)
29 ENDIF (OPENC2E_USE_SERIALIZATION)
32 SET(OPENC2E_CORE
33         Agent.cpp
34         AgentHelpers.cpp
35         AgentRef.cpp
36         attFile.cpp
37         Backend.cpp
38         Blackboard.cpp
39         blkImage.cpp
40         bmpImage.cpp
41         bytecode.cpp
42         c16Image.cpp
43         c2eBrain.cpp
44         CallButton.cpp
45         Camera.cpp
46         caosScript.cpp
47         caosVar.cpp
48         caosVM_agent.cpp
49         caosVM_camera.cpp
50         caosVM_compound.cpp
51         caosVM_core.cpp
52         caosVM_creatures.cpp
53         caosVM_debug.cpp
54         caosVM_files.cpp
55         caosVM_flow.cpp
56         caosVM_genetics.cpp
57         caosVM_history.cpp
58         caosVM_input.cpp
59         caosVM_map.cpp
60         caosVM_motion.cpp
61         caosVM_net.cpp
62         caosVM.cpp
63         caosVM_ports.cpp
64         caosVM_resources.cpp
65         caosVM_scripts.cpp
66         caosVM_sounds.cpp
67         caosVM_time.cpp
68         caosVM_variables.cpp
69         caosVM_vectors.cpp
70         caosVM_vehicles.cpp
71         caosVM_world.cpp
72         ${GEN}/cataloglexer.cpp
73         Catalogue.cpp
74         ${GEN}/catalogue.tab.cpp
75         ${GEN}/cmddata.cpp
76         cobFile.cpp
77         CompoundAgent.cpp
78         CompoundPart.cpp
79         Creature.cpp
80         CreatureAgent.cpp
81         creaturesImage.cpp
82         dialect.cpp
83         Engine.cpp
84         exceptions.cpp
85         fileSwapper.cpp
86         genomeFile.cpp
87         historyManager.cpp
88         imageManager.cpp
89         #       ${GEN}/lex.mng.cpp
90         ${GEN}/caoslexer.cpp
91         Lift.cpp
92         Map.cpp
93         MetaRoom.cpp
94         mmapifstream.cpp
95         #       mngfile.cpp
96         #       ${GEN}/mngparser.tab.cpp
97         oldBrain.cpp
98         PathResolver.cpp
99         physics.cpp
100         PointerAgent.cpp
101         Port.cpp
102         pray.cpp
103         prayManager.cpp
104         renderable.cpp
105         Room.cpp
106         Scriptorium.cpp
107         SDLBackend.cpp
108         SFCFile.cpp
109         SimpleAgent.cpp
110         SkeletalCreature.cpp
111         sprImage.cpp
112         streamutils.cpp
113         Vehicle.cpp
114         World.cpp
115         main.cpp
116         util.cpp
119 SET(OPENC2E_SDL
120         # all in the main openc2e listing
121         # XXX: non-sdl-based backends?
124 SET(OPENC2E_QT
125         qtgui/qtopenc2e.cpp
126         qtgui/openc2eview.cpp
127         qtgui/AgentInjector.cpp
128         qtgui/BrainViewer.cpp
129         qtgui/imagepreview.cpp
130         qtgui/c1cobfile.cpp
131         qtgui/QtBackend.cpp
132         qtgui/GraphWidget.cpp
133         qtgui/CreatureGrapher.cpp
134         qtgui/Hatchery.cpp
135         tools/braininavat/brainview.cpp)
137 SET(OPENC2E_QT_MOC_HDRS
138         qtgui/qtopenc2e.h
139         qtgui/openc2eview.h
140         qtgui/AgentInjector.h
141         qtgui/BrainViewer.h
142         qtgui/imagepreview.h
143         qtgui/GraphWidget.h
144         qtgui/CreatureGrapher.h
145         qtgui/Hatchery.h
146         tools/braininavat/brainview.h)
148 SET(OPENC2E_QT_UIS
149         qtgui/agents.ui)
153 cmake_minimum_required(VERSION 2.4.0)
154 INCLUDE(TestBigEndian)
155 INCLUDE(CheckIncludeFile)
156 TEST_BIG_ENDIAN(BIG_ENDIAN)
157 IF(BIG_ENDIAN)
158         ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=1")
159         CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
160         IF(HAVE_BYTESWAP_H)
161                 ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=1")
162         ELSE(HAVE_BYTESWAP_H)
163                 ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=0")
164         ENDIF(HAVE_BYTESWAP_H)
165 ELSE(BIG_ENDIAN)
166         ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=0")
167 ENDIF(BIG_ENDIAN)
168 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
169 IF(HAVE_STDINT_H)
170         ADD_DEFINITIONS("-DHAVE_STDINT_H=1")
171 ELSE(HAVE_STDINT_H)
172 ENDIF(HAVE_STDINT_H)
174 FIND_PACKAGE(SDL REQUIRED)
175 #FIND_PACKAGE(SDL_mixer REQUIRED)
176 FIND_PACKAGE(SDL_net REQUIRED)
177 FIND_PACKAGE(SDL_gfx REQUIRED)
178 FIND_PACKAGE(SDL_ttf REQUIRED)
179 IF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
180         FIND_PACKAGE(OpenAL)
181 ELSE(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
182         SET(OPENAL_FOUND "NO")
183 ENDIF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
184 FIND_PACKAGE(ALUT)
185 FIND_PACKAGE(Boost REQUIRED)
186 IF(OPENC2E_USE_QT)
187         find_package(Qt4 REQUIRED)
188 ENDIF(OPENC2E_USE_QT)
190 SET(USE_OPENAL "NO")
192 IF(OPENAL_FOUND STREQUAL "YES")
193     IF(ALUT_FOUND STREQUAL "YES")
194         SET(USE_OPENAL "YES")
195     ENDIF(ALUT_FOUND STREQUAL "YES")
196 ENDIF(OPENAL_FOUND STREQUAL "YES")
197      
198 IF(USE_OPENAL STREQUAL "NO")
199         IF (OPENC2E_USE_OPENAL MATCHES "^YES")
200                 MESSAGE(FATAL_ERROR "OpenAL not found.")
201         ENDIF (OPENC2E_USE_OPENAL MATCHES "^YES")
202         
203     SET(ALUT_INCLUDE_DIR "")
204     SET(OPENAL_INCLUDE_DIR "")
205     SET(ALUT_LIBRARY "")
206     SET(OPENAL_LIBRARY "")
207     SET(OPENAL_SRC "")
208     SET(OPENAL_DEF "")
209 ELSE(OPENAL_SRC STREQUAL "")
210     SET(OPENAL_SRC "OpenALBackend.cpp")
211     SET(OPENAL_DEF "-DOPENAL_SUPPORT")
212 ENDIF(OPENAL_SRC STREQUAL "")
214 IF(OPENC2E_USE_QT)
215         include(${QT_USE_FILE})
216         SET(SAVED_CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_BINARY_DIR)
217         SET(CMAKE_CURRENT_BINARY_DIR ${GEN})
218         QT4_WRAP_UI(OPENC2E_QT_UIS_H ${OPENC2E_QT_UIS})
219         QT4_WRAP_CPP(OPENC2E_QT_MOC_SRCS ${OPENC2E_QT_MOC_HDRS})
220         SET(CMAKE_CURRENT_BINARY_DIR SAVED_CMAKE_CURRENT_BINARY_DIR)
221         SET(QT_DEF "-DQT_SUPPORT")
222 ENDIF(OPENC2E_USE_QT)
224 # Pass flags to the compiler
225 ADD_DEFINITIONS("-W -Wall -Wno-conversion -Wno-unused -pthread -D_REENTRANT -DYYERROR_VERBOSE ${OPENAL_DEF} ${QT_DEF}")
227 IF(OPENC2E_USE_QT)
228         SET(FRONTEND_SRCS ${OPENC2E_QT} ${OPENC2E_QT_UIS_H} ${OPENC2E_QT_MOC_SRCS})
229         SET(FRONTEND_LIBS ${QT_LIBRARIES})
230 ELSE(OPENC2E_USE_QT)
231         SET(FRONTEND_SRCS ${OPENC2E_SDL})
232         SET(FRONTEND_LIBS)
233 ENDIF(OPENC2E_USE_QT)
234 ADD_EXECUTABLE(openc2e ${OPENC2E_CORE} ${FRONTEND_SRCS} ${OPENAL_SRC} ${SER_SRCS})
236 TARGET_LINK_LIBRARIES(openc2e z m pthread 
237         ${SDL_LIBRARY}
238 #       ${SDLMIXER_LIBRARY} 
239         ${SDLNET_LIBRARY}
240         ${SDLTTF_LIBRARY}
241         ${SDLGFX_LIBRARY}
242         ${OPENAL_LIBRARY}
243         ${ALUT_LIBRARY}
244         ${FRONTEND_LIBS}
245         boost_program_options-mt
246         boost_serialization-mt
247         boost_filesystem-mt
248         boost_thread-mt
249         boost_regex-mt
250         )
252 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
254 INCLUDE_DIRECTORIES(BEFORE
255         ${GEN}
256         ${SRC}
257         ${SDL_INCLUDE_DIR}
258 #       ${SDLMIXER_INCLUDE_DIR}
259         ${SDLNET_INCLUDE_DIR}
260         ${SDLTTF_INCLUDE_DIR}
261         ${SDLGFX_INCLUDE_DIR}
262         ${OPENAL_INCLUDE_DIR}
263         ${ALUT_INCLUDE_DIR}
264         ${Boost_INCLUDE_DIR}
265         )
267 FILE(GLOB CAOSVM_FILES ${SRC}/caosVM_*.cpp)
268 ADD_CUSTOM_COMMAND(
269         OUTPUT ${GEN}/commandinfo.yml
270         COMMAND perl parsedocs.pl ${CAOSVM_FILES} > ${GEN}/commandinfo.yml
271         DEPENDS parsedocs.pl ${CAOSVM_FILES}
272         WORKING_DIRECTORY ${SRC})
274 ADD_CUSTOM_COMMAND(
275         OUTPUT ${BIN}/caosdocs.html
276         COMMAND perl writehtml.pl ${GEN}/commandinfo.yml > ${BIN}/caosdocs.html
277         DEPENDS writehtml.pl ${GEN}/commandinfo.yml
278         WORKING_DIRECTORY ${SRC})
279 ADD_CUSTOM_COMMAND(
280         OUTPUT ${BIN}/docs.css
281         COMMAND cp docs.css ${BIN}/docs.css
282         DEPENDS docs.css
283         WORKING_DIRECTORY ${SRC})
284 ADD_CUSTOM_COMMAND(
285         OUTPUT ${BIN}/openc2e.6
286         COMMAND pod2man --center="Openc2e Documentation" --section=6 ${SRC}/openc2e.pod ${BIN}/openc2e.6
287         DEPENDS openc2e.pod
288         )
289 # it seems these ADD_CUSTOM_COMMANDS for flex and bison could be made
290 # into a macro... e.g. FLEX(file1) FLEX(file2) etc...
291 ADD_CUSTOM_COMMAND(
292         OUTPUT ${GEN}/cataloglexer.cpp
293         COMMAND re2c -o ${GEN}/cataloglexer.cpp ${SRC}/cataloglexer.re2c
294         DEPENDS ${SRC}/cataloglexer.re2c
295         WORKING_DIRECTORY ${SRC})
297 ADD_CUSTOM_COMMAND(
298         OUTPUT ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
299         COMMAND bison -d --name-prefix=cata --file-prefix="${GEN}/catalogue" catalogue.ypp
300         DEPENDS catalogue.ypp
301         WORKING_DIRECTORY ${SRC})
303 ADD_CUSTOM_COMMAND(
304         OUTPUT ${GEN}/cmddata.cpp
305         COMMAND perl writecmds.pl ${GEN}/commandinfo.yml > ${GEN}/cmddata.cpp
306         DEPENDS ${GEN}/commandinfo.yml writecmds.pl
307         WORKING_DIRECTORY ${SRC})
309 ADD_CUSTOM_COMMAND(
310         OUTPUT ${GEN}/caoslexer.cpp
311         COMMAND re2c -o ${GEN}/caoslexer.cpp ${SRC}/caoslexer.re2c
312         DEPENDS ${SRC}/caoslexer.re2c
313         WORKING_DIRECTORY ${SRC})
315 #ADD_CUSTOM_COMMAND(
316 #       OUTPUT ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
317 #       COMMAND flex -+ --prefix=mng -d -o ${GEN}/lex.mng.cpp --header-file=${GEN}/lex.mng.h mng.l
318 #       DEPENDS mng.l
319 #       WORKING_DIRECTORY ${SRC})
321 #ADD_CUSTOM_COMMAND(
322 #       OUTPUT ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp
323 #       COMMAND bison -d --name-prefix=mng --file-prefix="${GEN}/mngparser" mngparser.ypp
324 #       DEPENDS mngparser.ypp
325 #       WORKING_DIRECTORY ${SRC})
327 ADD_CUSTOM_TARGET(docs ALL DEPENDS ${BIN}/caosdocs.html ${BIN}/docs.css ${BIN}/openc2e.6)
328 ADD_CUSTOM_TARGET(generated DEPENDS
329         ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
330         ${GEN}/caoslexer.cpp
331         ${GEN}/cataloglexer.cpp
332         ${GEN}/cmddata.cpp
333         #       ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
334         #       ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp