2 # SuperTux - root build script
3 # Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 # Create a directory build/ and change to it. Run
29 # This creates a set of Makefiles to build the project. Run
36 # FIXME: create config.h from config.h.in
37 # FIXME: create messages.pot for levels
41 ## Project name to use as command prefix
46 ### CMake configuration
48 # allow building with old CMake. Use some bundled modules as a fallback
49 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
50 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SUPERTUX_SOURCE_DIR}/mk/cmake)
52 # move some config clutter to the advanced section
54 CMAKE_BACKWARDS_COMPATIBILITY
57 EXECUTABLE_OUTPUT_PATH
62 ## Some default settings
64 OPTION(ENABLE_SQDBG "Build squirrel script interpreter with debugging options" FALSE)
65 OPTION(ENABLE_OPENGL "Enable OpenGL support" TRUE)
66 OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" ${DEBUG})
74 OPTION(ENABLE_BINRELOC "Enable autopackage's BINRELOC features" FALSE)
75 OPTION(APPDATADIR "APPDATADIR for autopackage's BINRELOC features" "${CMAKE_INSTALL_PREFIX}/share")
79 INCLUDE(TestBigEndian)
80 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
82 ## Add lots of dependencies to compiler switches
84 FIND_PACKAGE(SDL REQUIRED)
90 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
91 LINK_LIBRARIES(${SDL_LIBRARY})
93 FIND_PACKAGE(SDL_image REQUIRED)
98 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
99 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
103 IF(${OPENGL_FOUND} STREQUAL "YES")
104 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
105 LINK_LIBRARIES(${OPENGL_LIBRARY})
106 SET(HAVE_OPENGL TRUE)
107 ENDIF(${OPENGL_FOUND} STREQUAL "YES")
110 FIND_PACKAGE(OpenAL REQUIRED)
115 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
116 LINK_LIBRARIES(${OPENAL_LIBRARY})
118 FIND_PACKAGE(OggVorbis REQUIRED)
126 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
127 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
129 FIND_PACKAGE(PhysFS REQUIRED)
134 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
135 LINK_LIBRARIES(${PHYSFS_LIBRARY})
139 INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
140 LINK_LIBRARIES(${CURL_LIBRARY})
141 SET(HAVE_LIBCURL TRUE)
144 #FIND_PACKAGE(ICONV REQUIRED)
145 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
146 #LINK_LIBRARIES(${ICONV_LIBRARY})
148 ## Check platform-dependent build options
150 INCLUDE(ConfigureChecks)
154 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
155 include_directories (${CMAKE_BINARY_DIR}/)
157 ## Also execute instructions in src/squirrel/CMakeLists.txt
159 ADD_SUBDIRECTORY(src/squirrel)
161 ## Add squirrel lib dir to search path
163 LINK_DIRECTORIES(src/squirrel)
165 ## Some additional include paths
167 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
168 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
170 ## Build list of sources for supertux binary
172 FILE(GLOB SUPERTUX_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/*.cpp src/audio/*.cpp src/badguy/*.cpp src/binreloc/*.cpp src/control/*.cpp src/gui/*.cpp src/lisp/*.cpp src/math/*.cpp src/object/*.cpp src/physfs/*.cpp src/sprite/*.cpp src/tinygettext/*.cpp src/trigger/*.cpp src/video/*.cpp src/worldmap/*.cpp src/scripting/*.cpp)
174 ## Add in squirrel debug stuff
177 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/)
178 FILE(GLOB SQDBG_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/squirrel/sqdbg/*.cpp)
179 SET(SUPERTUX_SOURCES ${SQDBG_SOURCES} ${SUPERTUX_SOURCES})
182 ## Build miniswig and generate miniswig wrapper
185 ADD_SUBDIRECTORY(tools/miniswig)
187 OUTPUT ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp
188 COMMAND cd ${SUPERTUX_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
189 ARGS -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o ${SUPERTUX_BINARY_DIR}/miniswig.tmp
190 COMMAND tools/miniswig/miniswig
191 ARGS --input miniswig.tmp --output-cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp --output-hpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp --module supertux --select-namespace Scripting
192 DEPENDS src/scripting/wrapper.interface.hpp tools/miniswig/miniswig
194 ENDIF(GENERATE_WRAPPER)
196 IF(NOT EXISTS ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
197 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES})
198 ENDIF(NOT EXISTS ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
200 ## If xgettext is available, generate messages.pot for sources
207 #IF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
208 # MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
209 #ELSE(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
210 # MESSAGE(STATUS "Found xgettext: ${XGETTEXT}")
211 # SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
213 # supertux-messages.pot ALL
214 # COMMAND "/usr/bin/xgettext" -k_ -C -o ${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
215 # DEPENDS ${SUPERTUX_SOURCES}
216 # WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
218 #ENDIF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
223 OPTION(DEBUG "Build with debugging options" FALSE)
225 REMOVE_DEFINITIONS(-O2)
226 ADD_DEFINITIONS(-O0 -g -pg -Wall -Werror)
229 REMOVE_DEFINITIONS(-O0 -g -pg -Wall -Werror)
233 ## Some additional compiler switches
234 ADD_DEFINITIONS(-fno-strict-aliasing)
237 ## Generate supertux executable in the right place
239 SET(EXECUTABLE_OUTPUT_PATH ${SUPERTUX_SOURCE_DIR})
241 ## Add target for supertux binary
243 ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES})
245 ## Link supertux binary with squirrel
247 TARGET_LINK_LIBRARIES(supertux2 squirrel)
251 INSTALL(TARGETS supertux2 DESTINATION bin)
253 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION share/pixmaps)
255 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/supertux2.desktop DESTINATION share/applications)
257 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/INSTALL ${SUPERTUX_SOURCE_DIR}/README ${SUPERTUX_SOURCE_DIR}/COPYING ${SUPERTUX_SOURCE_DIR}/WHATSNEW.txt DESTINATION doc/supertux-0.3.x)
259 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/credits.txt ${SUPERTUX_SOURCE_DIR}/data/camera.cfg DESTINATION share/supertux2)
260 INSTALL(DIRECTORY data/images DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
261 INSTALL(DIRECTORY data/levels DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
262 INSTALL(DIRECTORY data/music DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
263 INSTALL(DIRECTORY data/scripts DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
264 INSTALL(DIRECTORY data/speech DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
265 INSTALL(DIRECTORY data/sounds DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
266 INSTALL(DIRECTORY data/locale DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)