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
35 ## Project name to use as command prefix
40 ### CMake configuration
42 # allow building with old CMake. Use some bundled modules as a fallback
43 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
44 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SUPERTUX_SOURCE_DIR}/mk/cmake)
46 # move some config clutter to the advanced section
48 CMAKE_BACKWARDS_COMPATIBILITY
51 EXECUTABLE_OUTPUT_PATH
53 CMAKE_OSX_ARCHITECTURES
62 OPTION(ENABLE_BINRELOC "Enable autopackage's BINRELOC features" OFF)
63 SET(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/games/supertux2" CACHE STRING "APPDATADIR where data files reside")
67 INCLUDE(TestBigEndian)
68 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
70 ## Add lots of dependencies to compiler switches
72 FIND_PACKAGE(SDL REQUIRED)
78 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
79 LINK_LIBRARIES(${SDL_LIBRARY})
81 FIND_PACKAGE(SDL_image REQUIRED)
86 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
87 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
89 OPTION(ENABLE_OPENGL "Enable OpenGL support" ON)
92 IF(${OPENGL_FOUND} STREQUAL "YES")
93 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
94 LINK_LIBRARIES(${OPENGL_LIBRARY})
96 ENDIF(${OPENGL_FOUND} STREQUAL "YES")
99 FIND_PACKAGE(OpenAL REQUIRED)
104 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
105 LINK_LIBRARIES(${OPENAL_LIBRARY})
107 FIND_PACKAGE(OggVorbis REQUIRED)
115 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
116 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
118 FIND_PACKAGE(PhysFS REQUIRED)
123 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
124 LINK_LIBRARIES(${PHYSFS_LIBRARY})
128 INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
129 LINK_LIBRARIES(${CURL_LIBRARY})
130 SET(HAVE_LIBCURL TRUE)
133 #FIND_PACKAGE(ICONV REQUIRED)
134 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
135 #LINK_LIBRARIES(${ICONV_LIBRARY})
137 ## Check platform-dependent build options
139 INCLUDE(ConfigureChecks)
143 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
144 include_directories (${CMAKE_BINARY_DIR}/)
146 ## Also execute instructions in src/squirrel/CMakeLists.txt
148 ADD_SUBDIRECTORY(src/squirrel)
150 ## Add squirrel lib dir to search path
152 LINK_DIRECTORIES(src/squirrel)
154 ## Some additional include paths
156 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
157 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
159 ## Build list of sources for supertux binary
161 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 src/obstack/*.c)
165 OPTION(DEBUG "Build with debugging options" OFF)
166 OPTION(PROFILE "Build with profiling information" OFF)
167 IF(CMAKE_COMPILER_IS_GNUCC)
169 REMOVE_DEFINITIONS(-O2)
170 ADD_DEFINITIONS(-O0 -g -Wall -Werror)
173 REMOVE_DEFINITIONS(-O0 -g -Wall -Werror)
178 REMOVE_DEFINITIONS(-pg)
180 ENDIF(CMAKE_COMPILER_IS_GNUCC)
182 ## Add in squirrel debug stuff
184 OPTION(ENABLE_SQDBG "Build squirrel script interpreter with debugging options" OFF)
186 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/)
187 FILE(GLOB SQDBG_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/squirrel/sqdbg/*.cpp)
188 SET(SUPERTUX_SOURCES ${SQDBG_SOURCES} ${SUPERTUX_SOURCES})
191 ## Build miniswig and generate miniswig wrapper
193 OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" ${DEBUG})
195 ADD_SUBDIRECTORY(tools/miniswig)
197 OUTPUT ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp
198 COMMAND cd ${SUPERTUX_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
199 ARGS -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o ${SUPERTUX_BINARY_DIR}/miniswig.tmp
200 COMMAND tools/miniswig/miniswig
201 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
202 DEPENDS src/scripting/wrapper.interface.hpp tools/miniswig/miniswig
204 ENDIF(GENERATE_WRAPPER)
206 IF(NOT EXISTS ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
207 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES} ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
208 ENDIF(NOT EXISTS ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
210 ## If xgettext is available, generate messages.pot for sources
212 OPTION(GENERATE_MESSAGESPOT "Generate messages.pot files" ${DEBUG})
213 IF(GENERATE_MESSAGESPOT)
217 FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
218 IF(NOT XGETTEXT_EXECUTABLE)
219 MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
220 ELSE(NOT XGETTEXT_EXECUTABLE)
221 MESSAGE(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
223 SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
225 OUTPUT ${MESSAGES_POT_FILE}
226 COMMAND ${XGETTEXT_EXECUTABLE}
227 ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
228 DEPENDS ${SUPERTUX_SOURCES}
229 WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
230 COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
232 LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
234 FILE(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${SUPERTUX_SOURCE_DIR} data/levels/*)
235 LIST(REMOVE_ITEM SUPERTUX_LEVEL_DIRS "data/levels/.svn")
236 FOREACH(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
237 FILE(GLOB SUPERTUX_LEVELS RELATIVE ${SUPERTUX_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
239 ## Do not add target if SUPERTUX_LEVELS is empty. This is needed for cmake <=2.4
241 SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
243 OUTPUT ${MESSAGES_POT_FILE}
244 COMMAND ${XGETTEXT_EXECUTABLE}
245 ARGS --keyword="_:1" --language=Lisp --sort-by-file --output=${MESSAGES_POT_FILE} ${SUPERTUX_LEVELS}
246 DEPENDS ${SUPERTUX_LEVELS}
247 WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
248 COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
250 LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
251 ENDIF(SUPERTUX_LEVELS)
253 ENDFOREACH(SUPERTUX_LEVEL_DIR)
256 supertux2-messages ALL
257 DEPENDS ${MESSAGES_POT_FILES}
260 ENDIF(NOT XGETTEXT_EXECUTABLE)
261 ENDIF(GENERATE_MESSAGESPOT)
263 ## Some additional compiler switches
264 IF(CMAKE_COMPILER_IS_GNUCC)
265 ADD_DEFINITIONS(-fno-strict-aliasing)
266 ENDIF(CMAKE_COMPILER_IS_GNUCC)
268 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
269 ADD_DEFINITIONS(-DMACOSX)
270 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
273 ## On Windows, add an icon
276 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES} ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
279 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
280 COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons -i${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc -o ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
281 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
283 SET(SUPERTUX_EXE_SRCS ${SUPERTUX_EXE_SRCS} supertux.rc)
288 ## Generate supertux executable in the right place
290 SET(EXECUTABLE_OUTPUT_PATH ${SUPERTUX_SOURCE_DIR})
292 ## Add target for supertux binary
294 ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES})
296 ## Link supertux binary with squirrel
298 TARGET_LINK_LIBRARIES(supertux2 squirrel)
303 IF(WIN32 AND NOT UNIX)
305 SET(INSTALL_SUBDIR_BIN ".")
306 SET(INSTALL_SUBDIR_SHARE "data/")
307 SET(INSTALL_SUBDIR_DOC ".")
309 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/SDL.dll DESTINATION ${INSTALL_SUBDIR_BIN})
310 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/SDL_image.dll DESTINATION ${INSTALL_SUBDIR_BIN})
311 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/iconv.dll DESTINATION ${INSTALL_SUBDIR_BIN})
312 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/libogg-0.dll DESTINATION ${INSTALL_SUBDIR_BIN})
313 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/libphysfs-1-0-0.dll DESTINATION ${INSTALL_SUBDIR_BIN})
314 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/OpenAl32.dll DESTINATION ${INSTALL_SUBDIR_BIN})
315 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/wrap_oal.dll DESTINATION ${INSTALL_SUBDIR_BIN})
316 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/libcurl-4.dll DESTINATION ${INSTALL_SUBDIR_BIN})
318 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
320 ELSE(WIN32 AND NOT UNIX)
321 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
323 SET(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS/")
324 SET(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data/")
325 SET(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources/")
327 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
329 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.icns DESTINATION "SuperTux.app/Contents/Resources/")
331 ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
333 SET(INSTALL_SUBDIR_BIN "games/")
334 SET(INSTALL_SUBDIR_SHARE "share/games/supertux2/")
335 SET(INSTALL_SUBDIR_DOC "share/doc/supertux2/")
337 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/supertux2.desktop DESTINATION "share/applications")
339 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION "share/pixmaps/")
341 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
342 ENDIF(WIN32 AND NOT UNIX)
344 INSTALL(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
346 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/INSTALL ${SUPERTUX_SOURCE_DIR}/README ${SUPERTUX_SOURCE_DIR}/COPYING ${SUPERTUX_SOURCE_DIR}/WHATSNEW.txt DESTINATION ${INSTALL_SUBDIR_DOC})
348 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/credits.txt ${SUPERTUX_SOURCE_DIR}/data/camera.cfg DESTINATION ${INSTALL_SUBDIR_SHARE})
349 INSTALL(DIRECTORY data/images DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
350 INSTALL(DIRECTORY data/levels DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
351 INSTALL(DIRECTORY data/music DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
352 INSTALL(DIRECTORY data/scripts DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
353 INSTALL(DIRECTORY data/speech DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
354 INSTALL(DIRECTORY data/sounds DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
355 INSTALL(DIRECTORY data/locale DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
358 ## CPack/Installation-specific stuff
360 INCLUDE(InstallRequiredSystemLibraries)
361 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SuperTux")
362 SET(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
363 SET(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
364 SET(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
365 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.5), libgcc1 (>= 1:4.1), libgl1-mesa-glx | libgl1, libogg0 (>= 1.1.3), libopenal0a, libphysfs-1.0-0, libsdl-image1.2 (>= 1.2.5), libsdl1.2debian (>= 1.2.10-1), libstdc++6 (>= 4.1.2), libvorbis0a (>= 1.1.2), libvorbisfile3 (>= 1.1.2)")
366 SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Classic 2D jump 'n run sidescroller with Tux\n SuperTux is a classic 2D jump 'n run sidescroller game in a similar\n style like the original SuperMario games. This release of SuperTux\n features 9 enemies, 26 playable levels, software and OpenGL rendering\n modes, configurable joystick and keyboard input, new music and\n completly redone graphics.\n .\n This is a development snapshot of SuperTux. It may suffer from\n critical bugs and has not been fully tested. \n .\n Homepage: http://supertux.lethargik.org/")
367 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
368 # The OS X PackageMaker doesn't seem to like files with no extension
369 ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
370 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${SUPERTUX_SOURCE_DIR}/README")
371 SET(CPACK_RESOURCE_FILE_LICENSE "${SUPERTUX_SOURCE_DIR}/COPYING")
372 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
373 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
374 SET(CPACK_PACKAGE_VERSION_MINOR "3")
375 SET(CPACK_PACKAGE_VERSION_PATCH "2-SVN")
376 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
377 SET(CPACK_PACKAGE_EXECUTABLES "..\\\\supertux2" "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
378 IF(WIN32 AND NOT UNIX)
379 SET(CPACK_NSIS_INSTALLED_ICON_NAME "..\\\\supertux2")
380 SET(CPACK_NSIS_DISPLAY_NAME "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
381 ELSE(WIN32 AND NOT UNIX)
382 ENDIF(WIN32 AND NOT UNIX)