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)
73 ${GEN}/cataloglexer.cpp
75 ${GEN}/catalogue.tab.cpp
97 # ${GEN}/mngparser.tab.cpp
121 # all in the main openc2e listing
122 # XXX: non-sdl-based backends?
127 qtgui/openc2eview.cpp
128 qtgui/AgentInjector.cpp
129 qtgui/BrainViewer.cpp
130 qtgui/imagepreview.cpp
133 qtgui/GraphWidget.cpp
134 qtgui/CreatureGrapher.cpp
136 tools/braininavat/brainview.cpp)
138 SET(OPENC2E_QT_MOC_HDRS
141 qtgui/AgentInjector.h
145 qtgui/CreatureGrapher.h
147 tools/braininavat/brainview.h)
154 cmake_minimum_required(VERSION 2.4.0)
155 INCLUDE(TestBigEndian)
156 INCLUDE(CheckIncludeFile)
157 TEST_BIG_ENDIAN(BIG_ENDIAN)
159 ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=1")
160 CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
162 ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=1")
163 ELSE(HAVE_BYTESWAP_H)
164 ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=0")
165 ENDIF(HAVE_BYTESWAP_H)
167 ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=0")
169 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
171 ADD_DEFINITIONS("-DHAVE_STDINT_H=1")
175 FIND_PACKAGE(SDL REQUIRED)
176 #FIND_PACKAGE(SDL_mixer REQUIRED)
177 FIND_PACKAGE(SDL_net REQUIRED)
178 FIND_PACKAGE(SDL_gfx REQUIRED)
179 FIND_PACKAGE(SDL_ttf REQUIRED)
180 IF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
182 ELSE(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
183 SET(OPENAL_FOUND "NO")
184 ENDIF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
186 FIND_PACKAGE(Boost REQUIRED)
188 find_package(Qt4 REQUIRED)
189 ENDIF(OPENC2E_USE_QT)
193 IF(OPENAL_FOUND STREQUAL "YES")
194 IF(ALUT_FOUND STREQUAL "YES")
195 SET(USE_OPENAL "YES")
196 ENDIF(ALUT_FOUND STREQUAL "YES")
197 ENDIF(OPENAL_FOUND STREQUAL "YES")
199 IF(USE_OPENAL STREQUAL "NO")
200 IF (OPENC2E_USE_OPENAL MATCHES "^YES")
201 MESSAGE(FATAL_ERROR "OpenAL not found.")
202 ENDIF (OPENC2E_USE_OPENAL MATCHES "^YES")
204 SET(ALUT_INCLUDE_DIR "")
205 SET(OPENAL_INCLUDE_DIR "")
207 SET(OPENAL_LIBRARY "")
210 ELSE(OPENAL_SRC STREQUAL "")
211 SET(OPENAL_SRC "OpenALBackend.cpp")
212 SET(OPENAL_DEF "-DOPENAL_SUPPORT")
213 ENDIF(OPENAL_SRC STREQUAL "")
216 include(${QT_USE_FILE})
217 SET(SAVED_CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_BINARY_DIR)
218 SET(CMAKE_CURRENT_BINARY_DIR ${GEN})
219 QT4_WRAP_UI(OPENC2E_QT_UIS_H ${OPENC2E_QT_UIS})
220 QT4_WRAP_CPP(OPENC2E_QT_MOC_SRCS ${OPENC2E_QT_MOC_HDRS})
221 SET(CMAKE_CURRENT_BINARY_DIR SAVED_CMAKE_CURRENT_BINARY_DIR)
222 SET(QT_DEF "-DQT_SUPPORT")
223 ENDIF(OPENC2E_USE_QT)
225 # Pass flags to the compiler
226 ADD_DEFINITIONS("-W -Wall -Wno-conversion -Wno-unused -pthread -D_REENTRANT -DYYERROR_VERBOSE ${OPENAL_DEF} ${QT_DEF}")
229 SET(FRONTEND_SRCS ${OPENC2E_QT} ${OPENC2E_QT_UIS_H} ${OPENC2E_QT_MOC_SRCS})
230 SET(FRONTEND_LIBS ${QT_LIBRARIES})
232 SET(FRONTEND_SRCS ${OPENC2E_SDL})
234 ENDIF(OPENC2E_USE_QT)
235 ADD_EXECUTABLE(openc2e ${OPENC2E_CORE} ${FRONTEND_SRCS} ${OPENAL_SRC} ${SER_SRCS})
237 TARGET_LINK_LIBRARIES(openc2e z m pthread
239 # ${SDLMIXER_LIBRARY}
246 boost_program_options-mt
247 boost_serialization-mt
253 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
255 INCLUDE_DIRECTORIES(BEFORE
259 # ${SDLMIXER_INCLUDE_DIR}
260 ${SDLNET_INCLUDE_DIR}
261 ${SDLTTF_INCLUDE_DIR}
262 ${SDLGFX_INCLUDE_DIR}
263 ${OPENAL_INCLUDE_DIR}
268 FILE(GLOB CAOSVM_FILES ${SRC}/caosVM_*.cpp)
270 OUTPUT ${GEN}/commandinfo.yml
271 COMMAND perl parsedocs.pl ${CAOSVM_FILES} > ${GEN}/commandinfo.yml
272 DEPENDS parsedocs.pl ${CAOSVM_FILES}
273 WORKING_DIRECTORY ${SRC})
276 OUTPUT ${BIN}/caosdocs.html
277 COMMAND perl writehtml.pl ${GEN}/commandinfo.yml > ${BIN}/caosdocs.html
278 DEPENDS writehtml.pl ${GEN}/commandinfo.yml
279 WORKING_DIRECTORY ${SRC})
281 OUTPUT ${BIN}/docs.css
282 COMMAND cp docs.css ${BIN}/docs.css
284 WORKING_DIRECTORY ${SRC})
286 OUTPUT ${BIN}/openc2e.6
287 COMMAND pod2man --center="Openc2e Documentation" --section=6 ${SRC}/openc2e.pod ${BIN}/openc2e.6
290 # it seems these ADD_CUSTOM_COMMANDS for flex and bison could be made
291 # into a macro... e.g. FLEX(file1) FLEX(file2) etc...
293 OUTPUT ${GEN}/cataloglexer.cpp
294 COMMAND re2c -o ${GEN}/cataloglexer.cpp ${SRC}/cataloglexer.re2c
295 DEPENDS ${SRC}/cataloglexer.re2c
296 WORKING_DIRECTORY ${SRC})
299 OUTPUT ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
300 COMMAND bison -d --name-prefix=cata --file-prefix="${GEN}/catalogue" catalogue.ypp
301 DEPENDS catalogue.ypp
302 WORKING_DIRECTORY ${SRC})
305 OUTPUT ${GEN}/cmddata.cpp
306 COMMAND perl writecmds.pl ${GEN}/commandinfo.yml > ${GEN}/cmddata.cpp
307 DEPENDS ${GEN}/commandinfo.yml writecmds.pl
308 WORKING_DIRECTORY ${SRC})
311 OUTPUT ${GEN}/caoslexer.cpp
312 COMMAND re2c -o ${GEN}/caoslexer.cpp ${SRC}/caoslexer.re2c
313 DEPENDS ${SRC}/caoslexer.re2c
314 WORKING_DIRECTORY ${SRC})
317 # OUTPUT ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
318 # COMMAND flex -+ --prefix=mng -d -o ${GEN}/lex.mng.cpp --header-file=${GEN}/lex.mng.h mng.l
320 # WORKING_DIRECTORY ${SRC})
323 # OUTPUT ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp
324 # COMMAND bison -d --name-prefix=mng --file-prefix="${GEN}/mngparser" mngparser.ypp
325 # DEPENDS mngparser.ypp
326 # WORKING_DIRECTORY ${SRC})
328 ADD_CUSTOM_TARGET(docs ALL DEPENDS ${BIN}/caosdocs.html ${BIN}/docs.css ${BIN}/openc2e.6)
329 ADD_CUSTOM_TARGET(generated DEPENDS
330 ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
332 ${GEN}/cataloglexer.cpp
334 # ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
335 # ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp