add unfinished bmpImage implementation
[openc2e.git] / CMakeLists.txt
blob44dc2facf276ad4482126f34ffd6339377b7ea72
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}/catalogue.lex.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.c2.cpp
90         ${GEN}/lex.mng.cpp
91         lexutil.cpp
92         ${GEN}/lex.yy.cpp
93         Lift.cpp
94         Map.cpp
95         MetaRoom.cpp
96         mmapifstream.cpp
97         mngfile.cpp
98         ${GEN}/mngparser.tab.cpp
99         oldBrain.cpp
100         PathResolver.cpp
101         physics.cpp
102         PointerAgent.cpp
103         pray.cpp
104         prayManager.cpp
105         renderable.cpp
106         Room.cpp
107         Scriptorium.cpp
108         SDLBackend.cpp
109         SFCFile.cpp
110         SimpleAgent.cpp
111         SkeletalCreature.cpp
112         sprImage.cpp
113         streamutils.cpp
114         Vehicle.cpp
115         World.cpp
116         main.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         tools/braininavat/brainview.cpp)
136 SET(OPENC2E_QT_MOC_HDRS
137         qtgui/qtopenc2e.h
138         qtgui/openc2eview.h
139         qtgui/AgentInjector.h
140         qtgui/BrainViewer.h
141         qtgui/imagepreview.h
142         qtgui/GraphWidget.h
143         qtgui/CreatureGrapher.h
144         tools/braininavat/brainview.h)
146 SET(OPENC2E_QT_UIS
147         qtgui/agents.ui)
151 cmake_minimum_required(VERSION 2.4.0)
153 FIND_PACKAGE(SDL REQUIRED)
154 FIND_PACKAGE(SDL_mixer REQUIRED)
155 FIND_PACKAGE(SDL_net REQUIRED)
156 FIND_PACKAGE(SDL_gfx REQUIRED)
157 IF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
158         FIND_PACKAGE(OpenAL)
159 ELSE(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
160         SET(OPENAL_FOUND "NO")
161 ENDIF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
162 FIND_PACKAGE(ALUT)
163 FIND_PACKAGE(Boost REQUIRED)
164 IF(OPENC2E_USE_QT)
165         find_package(Qt4 REQUIRED)
166 ENDIF(OPENC2E_USE_QT)
168 SET(USE_OPENAL "NO")
170 IF(OPENAL_FOUND STREQUAL "YES")
171     IF(ALUT_FOUND STREQUAL "YES")
172         SET(USE_OPENAL "YES")
173     ENDIF(ALUT_FOUND STREQUAL "YES")
174 ENDIF(OPENAL_FOUND STREQUAL "YES")
175      
176 IF(USE_OPENAL STREQUAL "NO")
177         IF (OPENC2E_USE_OPENAL MATCHES "^YES")
178                 MESSAGE(FATAL_ERROR "OpenAL not found.")
179         ENDIF (OPENC2E_USE_OPENAL MATCHES "^YES")
180         
181     SET(ALUT_INCLUDE_DIR "")
182     SET(OPENAL_INCLUDE_DIR "")
183     SET(ALUT_LIBRARY "")
184     SET(OPENAL_LIBRARY "")
185     SET(OPENAL_SRC "")
186     SET(OPENAL_DEF "")
187 ELSE(OPENAL_SRC STREQUAL "")
188     SET(OPENAL_SRC "OpenALBackend.cpp")
189     SET(OPENAL_DEF "-DOPENAL_SUPPORT")
190 ENDIF(OPENAL_SRC STREQUAL "")
192 IF(OPENC2E_USE_QT)
193         include(${QT_USE_FILE})
194         SET(SAVED_CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_BINARY_DIR)
195         SET(CMAKE_CURRENT_BINARY_DIR ${GEN})
196         QT4_WRAP_UI(OPENC2E_QT_UIS_H ${OPENC2E_QT_UIS})
197         QT4_WRAP_CPP(OPENC2E_QT_MOC_SRCS ${OPENC2E_QT_MOC_HDRS})
198         SET(CMAKE_CURRENT_BINARY_DIR SAVED_CMAKE_CURRENT_BINARY_DIR)
199         SET(QT_DEF "-DQT_SUPPORT")
200 ENDIF(OPENC2E_USE_QT)
202 # Pass flags to the compiler
203 ADD_DEFINITIONS("-W -Wall -Wno-conversion -Wno-unused -pthread -D_REENTRANT -DYYERROR_VERBOSE ${OPENAL_DEF} ${QT_DEF}")
205 IF(OPENC2E_USE_QT)
206         SET(FRONTEND_SRCS ${OPENC2E_QT} ${OPENC2E_QT_UIS_H} ${OPENC2E_QT_MOC_SRCS})
207         SET(FRONTEND_LIBS ${QT_LIBRARIES})
208 ELSE(OPENC2E_USE_QT)
209         SET(FRONTEND_SRCS ${OPENC2E_SDL})
210         SET(FRONTEND_LIBS)
211 ENDIF(OPENC2E_USE_QT)
212 ADD_EXECUTABLE(openc2e ${OPENC2E_CORE} ${FRONTEND_SRCS} ${OPENAL_SRC} ${SER_SRCS})
214 TARGET_LINK_LIBRARIES(openc2e z m pthread 
215         ${SDL_LIBRARY}
216         ${SDLMIXER_LIBRARY} 
217         ${SDLNET_LIBRARY}
218         ${SDLGFX_LIBRARY}
219         ${OPENAL_LIBRARY}
220         ${ALUT_LIBRARY}
221         ${FRONTEND_LIBS}
222         boost_program_options-mt
223         boost_serialization-mt
224         boost_filesystem-mt
225         boost_thread-mt
226         boost_regex-mt
227         )
229 INCLUDE_DIRECTORIES(BEFORE
230         ${GEN}
231         ${SRC}
232         ${SDL_INCLUDE_DIR}
233         ${SDLMIXER_INCLUDE_DIR}
234         ${SDLNET_INCLUDE_DIR}
235         ${SDLGFX_INCLUDE_DIR}
236         ${OPENAL_INCLUDE_DIR}
237         ${ALUT_INCLUDE_DIR}
238         )
240 FILE(GLOB CAOSVM_FILES ${SRC}/caosVM_*.cpp)
241 ADD_CUSTOM_COMMAND(
242         OUTPUT ${GEN}/commandinfo.yml
243         COMMAND perl parsedocs.pl ${CAOSVM_FILES} > ${GEN}/commandinfo.yml
244         DEPENDS parsedocs.pl ${CAOSVM_FILES}
245         WORKING_DIRECTORY ${SRC})
247 ADD_CUSTOM_COMMAND(
248         OUTPUT ${BIN}/caosdocs.html
249         COMMAND perl writehtml.pl ${GEN}/commandinfo.yml > ${BIN}/caosdocs.html
250         DEPENDS writehtml.pl ${GEN}/commandinfo.yml
251         WORKING_DIRECTORY ${SRC})
252 ADD_CUSTOM_COMMAND(
253         OUTPUT ${BIN}/docs.css
254         COMMAND cp docs.css ${BIN}/docs.css -f
255         DEPENDS docs.css
256         WORKING_DIRECTORY ${SRC})
257 ADD_CUSTOM_COMMAND(
258         OUTPUT ${BIN}/openc2e.6
259         COMMAND pod2man --center="Openc2e Documentation" --section=6 ${SRC}/openc2e.pod ${BIN}/openc2e.6
260         DEPENDS openc2e.pod
261         )
262 # it seems these ADD_CUSTOM_COMMANDS for flex and bison could be made
263 # into a macro... e.g. FLEX(file1) FLEX(file2) etc...
264 ADD_CUSTOM_COMMAND(
265         OUTPUT ${GEN}/catalogue.lex.cpp ${GEN}/catalogue.lex.h
266         COMMAND flex -+ --prefix=catalogue -d -o ${GEN}/catalogue.lex.cpp --header-file=${GEN}/catalogue.lex.h catalogue.l 
267         DEPENDS catalogue.l ${GEN}/catalogue.tab.hpp
268         WORKING_DIRECTORY ${SRC})
270 ADD_CUSTOM_COMMAND(
271         OUTPUT ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
272         COMMAND bison -d --name-prefix=cata --file-prefix="${GEN}/catalogue" catalogue.ypp
273         DEPENDS catalogue.ypp
274         WORKING_DIRECTORY ${SRC})
276 ADD_CUSTOM_COMMAND(
277         OUTPUT ${GEN}/cmddata.cpp
278         COMMAND perl writecmds.pl ${GEN}/commandinfo.yml > ${GEN}/cmddata.cpp
279         DEPENDS ${GEN}/commandinfo.yml writecmds.pl
280         WORKING_DIRECTORY ${SRC})
282 ADD_CUSTOM_COMMAND(
283         OUTPUT ${GEN}/lex.c2.cpp ${GEN}/lex.c2.h
284         COMMAND flex -+ -d -o ${GEN}/lex.c2.cpp --header-file=${GEN}/lex.c2.h --prefix=c2 c2caos.l
285         DEPENDS c2caos.l
286         WORKING_DIRECTORY ${SRC})
288 ADD_CUSTOM_COMMAND(
289         OUTPUT ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
290         COMMAND flex -+ --prefix=mng -d -o ${GEN}/lex.mng.cpp --header-file=${GEN}/lex.mng.h mng.l
291         DEPENDS mng.l
292         WORKING_DIRECTORY ${SRC})
294 ADD_CUSTOM_COMMAND(
295         OUTPUT ${GEN}/lex.yy.cpp ${GEN}/lex.yy.h
296         COMMAND flex -+ -d -o ${GEN}/lex.yy.cpp --header-file=${GEN}/lex.yy.h --prefix=c2e caos.l
297         DEPENDS caos.l
298         WORKING_DIRECTORY ${SRC})
300 ADD_CUSTOM_COMMAND(
301         OUTPUT ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp
302         COMMAND bison -d --name-prefix=mng --file-prefix="${GEN}/mngparser" mngparser.ypp
303         DEPENDS mngparser.ypp
304         WORKING_DIRECTORY ${SRC})
306 ADD_CUSTOM_TARGET(docs ALL DEPENDS ${BIN}/caosdocs.html ${BIN}/docs.css ${BIN}/openc2e.6)
307 ADD_CUSTOM_TARGET(generated DEPENDS
308         ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
309         ${GEN}/catalogue.lex.cpp ${GEN}/catalogue.lex.h
310         ${GEN}/cmddata.cpp
311         ${GEN}/lex.c2.cpp ${GEN}/lex.c2.h
312         ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
313         ${GEN}/lex.yy.cpp ${GEN}/lex.yy.h
314         ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp