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)
72 ${GEN}/cataloglexer.cpp
74 ${GEN}/catalogue.tab.cpp
96 # ${GEN}/mngparser.tab.cpp
120 # all in the main openc2e listing
121 # XXX: non-sdl-based backends?
126 qtgui/openc2eview.cpp
127 qtgui/AgentInjector.cpp
128 qtgui/BrainViewer.cpp
129 qtgui/imagepreview.cpp
132 qtgui/GraphWidget.cpp
133 qtgui/CreatureGrapher.cpp
134 tools/braininavat/brainview.cpp)
136 SET(OPENC2E_QT_MOC_HDRS
139 qtgui/AgentInjector.h
143 qtgui/CreatureGrapher.h
144 tools/braininavat/brainview.h)
151 cmake_minimum_required(VERSION 2.4.0)
152 INCLUDE(TestBigEndian)
153 INCLUDE(CheckIncludeFile)
154 TEST_BIG_ENDIAN(BIG_ENDIAN)
156 ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=1")
157 CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
159 ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=1")
160 ELSE(HAVE_BYTESWAP_H)
161 ADD_DEFINITIONS("-DHAVE_BYTESWAP_H=0")
162 ENDIF(HAVE_BYTESWAP_H)
164 ADD_DEFINITIONS("-DOC2E_BIG_ENDIAN=0")
166 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
168 ADD_DEFINITIONS("-DHAVE_STDINT_H=1")
172 FIND_PACKAGE(SDL REQUIRED)
173 #FIND_PACKAGE(SDL_mixer REQUIRED)
174 FIND_PACKAGE(SDL_net REQUIRED)
175 FIND_PACKAGE(SDL_gfx REQUIRED)
176 FIND_PACKAGE(SDL_ttf REQUIRED)
177 IF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
179 ELSE(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
180 SET(OPENAL_FOUND "NO")
181 ENDIF(OPENC2E_USE_OPENAL MATCHES "^(YES|AUTO)$")
183 FIND_PACKAGE(Boost REQUIRED)
185 find_package(Qt4 REQUIRED)
186 ENDIF(OPENC2E_USE_QT)
190 IF(OPENAL_FOUND STREQUAL "YES")
191 IF(ALUT_FOUND STREQUAL "YES")
192 SET(USE_OPENAL "YES")
193 ENDIF(ALUT_FOUND STREQUAL "YES")
194 ENDIF(OPENAL_FOUND STREQUAL "YES")
196 IF(USE_OPENAL STREQUAL "NO")
197 IF (OPENC2E_USE_OPENAL MATCHES "^YES")
198 MESSAGE(FATAL_ERROR "OpenAL not found.")
199 ENDIF (OPENC2E_USE_OPENAL MATCHES "^YES")
201 SET(ALUT_INCLUDE_DIR "")
202 SET(OPENAL_INCLUDE_DIR "")
204 SET(OPENAL_LIBRARY "")
207 ELSE(OPENAL_SRC STREQUAL "")
208 SET(OPENAL_SRC "OpenALBackend.cpp")
209 SET(OPENAL_DEF "-DOPENAL_SUPPORT")
210 ENDIF(OPENAL_SRC STREQUAL "")
213 include(${QT_USE_FILE})
214 SET(SAVED_CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_BINARY_DIR)
215 SET(CMAKE_CURRENT_BINARY_DIR ${GEN})
216 QT4_WRAP_UI(OPENC2E_QT_UIS_H ${OPENC2E_QT_UIS})
217 QT4_WRAP_CPP(OPENC2E_QT_MOC_SRCS ${OPENC2E_QT_MOC_HDRS})
218 SET(CMAKE_CURRENT_BINARY_DIR SAVED_CMAKE_CURRENT_BINARY_DIR)
219 SET(QT_DEF "-DQT_SUPPORT")
220 ENDIF(OPENC2E_USE_QT)
222 # Pass flags to the compiler
223 ADD_DEFINITIONS("-W -Wall -Wno-conversion -Wno-unused -pthread -D_REENTRANT -DYYERROR_VERBOSE ${OPENAL_DEF} ${QT_DEF}")
226 SET(FRONTEND_SRCS ${OPENC2E_QT} ${OPENC2E_QT_UIS_H} ${OPENC2E_QT_MOC_SRCS})
227 SET(FRONTEND_LIBS ${QT_LIBRARIES})
229 SET(FRONTEND_SRCS ${OPENC2E_SDL})
231 ENDIF(OPENC2E_USE_QT)
232 ADD_EXECUTABLE(openc2e ${OPENC2E_CORE} ${FRONTEND_SRCS} ${OPENAL_SRC} ${SER_SRCS})
234 TARGET_LINK_LIBRARIES(openc2e z m pthread
236 # ${SDLMIXER_LIBRARY}
243 boost_program_options-mt
244 boost_serialization-mt
250 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
252 INCLUDE_DIRECTORIES(BEFORE
256 # ${SDLMIXER_INCLUDE_DIR}
257 ${SDLNET_INCLUDE_DIR}
258 ${SDLTTF_INCLUDE_DIR}
259 ${SDLGFX_INCLUDE_DIR}
260 ${OPENAL_INCLUDE_DIR}
265 FILE(GLOB CAOSVM_FILES ${SRC}/caosVM_*.cpp)
267 OUTPUT ${GEN}/commandinfo.yml
268 COMMAND perl parsedocs.pl ${CAOSVM_FILES} > ${GEN}/commandinfo.yml
269 DEPENDS parsedocs.pl ${CAOSVM_FILES}
270 WORKING_DIRECTORY ${SRC})
273 OUTPUT ${BIN}/caosdocs.html
274 COMMAND perl writehtml.pl ${GEN}/commandinfo.yml > ${BIN}/caosdocs.html
275 DEPENDS writehtml.pl ${GEN}/commandinfo.yml
276 WORKING_DIRECTORY ${SRC})
278 OUTPUT ${BIN}/docs.css
279 COMMAND cp docs.css ${BIN}/docs.css
281 WORKING_DIRECTORY ${SRC})
283 OUTPUT ${BIN}/openc2e.6
284 COMMAND pod2man --center="Openc2e Documentation" --section=6 ${SRC}/openc2e.pod ${BIN}/openc2e.6
287 # it seems these ADD_CUSTOM_COMMANDS for flex and bison could be made
288 # into a macro... e.g. FLEX(file1) FLEX(file2) etc...
290 OUTPUT ${GEN}/cataloglexer.cpp
291 COMMAND re2c -o ${GEN}/cataloglexer.cpp ${SRC}/cataloglexer.re2c
292 DEPENDS ${SRC}/cataloglexer.re2c
293 WORKING_DIRECTORY ${SRC})
296 OUTPUT ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
297 COMMAND bison -d --name-prefix=cata --file-prefix="${GEN}/catalogue" catalogue.ypp
298 DEPENDS catalogue.ypp
299 WORKING_DIRECTORY ${SRC})
302 OUTPUT ${GEN}/cmddata.cpp
303 COMMAND perl writecmds.pl ${GEN}/commandinfo.yml > ${GEN}/cmddata.cpp
304 DEPENDS ${GEN}/commandinfo.yml writecmds.pl
305 WORKING_DIRECTORY ${SRC})
308 OUTPUT ${GEN}/caoslexer.cpp
309 COMMAND re2c -o ${GEN}/caoslexer.cpp ${SRC}/caoslexer.re2c
310 DEPENDS ${SRC}/caoslexer.re2c
311 WORKING_DIRECTORY ${SRC})
314 # OUTPUT ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
315 # COMMAND flex -+ --prefix=mng -d -o ${GEN}/lex.mng.cpp --header-file=${GEN}/lex.mng.h mng.l
317 # WORKING_DIRECTORY ${SRC})
320 # OUTPUT ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp
321 # COMMAND bison -d --name-prefix=mng --file-prefix="${GEN}/mngparser" mngparser.ypp
322 # DEPENDS mngparser.ypp
323 # WORKING_DIRECTORY ${SRC})
325 ADD_CUSTOM_TARGET(docs ALL DEPENDS ${BIN}/caosdocs.html ${BIN}/docs.css ${BIN}/openc2e.6)
326 ADD_CUSTOM_TARGET(generated DEPENDS
327 ${GEN}/catalogue.tab.cpp ${GEN}/catalogue.tab.hpp
329 ${GEN}/cataloglexer.cpp
331 # ${GEN}/lex.mng.cpp ${GEN}/lex.mng.h
332 # ${GEN}/mngparser.tab.cpp ${GEN}/mngparser.tab.hpp