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
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
59 CMAKE_OSX_ARCHITECTURES
68 OPTION(ENABLE_BINRELOC "Enable autopackage's BINRELOC features" OFF)
69 SET(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/games" CACHE STRING "APPDATADIR for autopackage's BINRELOC features")
73 INCLUDE(TestBigEndian)
74 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
76 ## Add lots of dependencies to compiler switches
78 FIND_PACKAGE(SDL REQUIRED)
84 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
85 LINK_LIBRARIES(${SDL_LIBRARY})
87 FIND_PACKAGE(SDL_image REQUIRED)
92 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
93 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
95 OPTION(ENABLE_OPENGL "Enable OpenGL support" ON)
98 IF(${OPENGL_FOUND} STREQUAL "YES")
99 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
100 LINK_LIBRARIES(${OPENGL_LIBRARY})
101 SET(HAVE_OPENGL TRUE)
102 ENDIF(${OPENGL_FOUND} STREQUAL "YES")
105 FIND_PACKAGE(OpenAL REQUIRED)
110 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
111 LINK_LIBRARIES(${OPENAL_LIBRARY})
113 FIND_PACKAGE(OggVorbis REQUIRED)
121 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
122 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
124 FIND_PACKAGE(PhysFS REQUIRED)
129 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
130 LINK_LIBRARIES(${PHYSFS_LIBRARY})
134 INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
135 LINK_LIBRARIES(${CURL_LIBRARY})
136 SET(HAVE_LIBCURL TRUE)
139 #FIND_PACKAGE(ICONV REQUIRED)
140 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
141 #LINK_LIBRARIES(${ICONV_LIBRARY})
143 ## Check platform-dependent build options
145 INCLUDE(ConfigureChecks)
149 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
150 include_directories (${CMAKE_BINARY_DIR}/)
152 ## Also execute instructions in src/squirrel/CMakeLists.txt
154 ADD_SUBDIRECTORY(src/squirrel)
156 ## Add squirrel lib dir to search path
158 LINK_DIRECTORIES(src/squirrel)
160 ## Some additional include paths
162 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
163 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
165 ## Build list of sources for supertux binary
167 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)
171 OPTION(DEBUG "Build with debugging options" OFF)
172 OPTION(PROFILE "Build with profiling information" OFF)
173 IF(CMAKE_COMPILER_IS_GNUCC)
175 REMOVE_DEFINITIONS(-O2)
176 ADD_DEFINITIONS(-O0 -g -Wall -Werror)
179 REMOVE_DEFINITIONS(-O0 -g -Wall -Werror)
184 REMOVE_DEFINITIONS(-pg)
186 ENDIF(CMAKE_COMPILER_IS_GNUCC)
188 ## Add in squirrel debug stuff
190 OPTION(ENABLE_SQDBG "Build squirrel script interpreter with debugging options" OFF)
192 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/)
193 FILE(GLOB SQDBG_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/squirrel/sqdbg/*.cpp)
194 SET(SUPERTUX_SOURCES ${SQDBG_SOURCES} ${SUPERTUX_SOURCES})
197 ## Build miniswig and generate miniswig wrapper
199 OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" ${DEBUG})
201 ADD_SUBDIRECTORY(tools/miniswig)
203 OUTPUT ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp
204 COMMAND cd ${SUPERTUX_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
205 ARGS -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o ${SUPERTUX_BINARY_DIR}/miniswig.tmp
206 COMMAND tools/miniswig/miniswig
207 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
208 DEPENDS src/scripting/wrapper.interface.hpp tools/miniswig/miniswig
210 ENDIF(GENERATE_WRAPPER)
212 IF(NOT EXISTS ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
213 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES} ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
214 ENDIF(NOT EXISTS ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp)
216 ## If xgettext is available, generate messages.pot for sources
218 OPTION(GENERATE_MESSAGESPOT "Generate messages.pot files" ${DEBUG})
219 IF(GENERATE_MESSAGESPOT)
223 FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
224 IF(NOT XGETTEXT_EXECUTABLE)
225 MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
226 ELSE(NOT XGETTEXT_EXECUTABLE)
227 MESSAGE(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
229 SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
231 OUTPUT ${MESSAGES_POT_FILE}
232 COMMAND ${XGETTEXT_EXECUTABLE}
233 ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
234 DEPENDS ${SUPERTUX_SOURCES}
235 WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
236 COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
238 LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
240 FILE(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${SUPERTUX_SOURCE_DIR} data/levels/*)
241 LIST(REMOVE_ITEM SUPERTUX_LEVEL_DIRS "data/levels/.svn")
242 FOREACH(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
243 FILE(GLOB SUPERTUX_LEVELS RELATIVE ${SUPERTUX_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
245 SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
247 OUTPUT ${MESSAGES_POT_FILE}
248 COMMAND ${XGETTEXT_EXECUTABLE}
249 ARGS --keyword="_:1" --language=Lisp --sort-by-file --output=${MESSAGES_POT_FILE} ${SUPERTUX_LEVELS}
250 DEPENDS ${SUPERTUX_LEVELS}
251 WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
252 COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
254 LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
256 ENDFOREACH(SUPERTUX_LEVEL_DIR)
259 supertux2-messages ALL
260 DEPENDS ${MESSAGES_POT_FILES}
263 ENDIF(NOT XGETTEXT_EXECUTABLE)
264 ENDIF(GENERATE_MESSAGESPOT)
266 ## Some additional compiler switches
267 IF(CMAKE_COMPILER_IS_GNUCC)
268 ADD_DEFINITIONS(-fno-strict-aliasing)
269 ENDIF(CMAKE_COMPILER_IS_GNUCC)
271 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
272 ADD_DEFINITIONS(-DMACOSX)
273 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
276 ## On Windows, add an icon
279 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES} ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
282 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
283 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)
284 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
286 SET(SUPERTUX_EXE_SRCS ${SUPERTUX_EXE_SRCS} supertux.rc)
291 ## Generate supertux executable in the right place
293 SET(EXECUTABLE_OUTPUT_PATH ${SUPERTUX_SOURCE_DIR})
295 ## Add target for supertux binary
297 ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES})
299 ## Link supertux binary with squirrel
301 TARGET_LINK_LIBRARIES(supertux2 squirrel)
306 IF(WIN32 AND NOT UNIX)
308 SET(INSTALL_SUBDIR_BIN ".")
309 SET(INSTALL_SUBDIR_SHARE "data/")
310 SET(INSTALL_SUBDIR_DOC ".")
312 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/SDL.dll DESTINATION ${INSTALL_SUBDIR_BIN})
313 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/SDL_image.dll DESTINATION ${INSTALL_SUBDIR_BIN})
314 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/iconv.dll DESTINATION ${INSTALL_SUBDIR_BIN})
315 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/libogg-0.dll DESTINATION ${INSTALL_SUBDIR_BIN})
316 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/libphysfs-1-0-0.dll DESTINATION ${INSTALL_SUBDIR_BIN})
317 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/OpenAl32.dll DESTINATION ${INSTALL_SUBDIR_BIN})
318 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/wrap_oal.dll DESTINATION ${INSTALL_SUBDIR_BIN})
319 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/libcurl-4.dll DESTINATION ${INSTALL_SUBDIR_BIN})
321 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
323 ELSE(WIN32 AND NOT UNIX)
324 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
326 SET(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS/")
327 SET(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data/")
328 SET(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources/")
330 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
332 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/")
334 ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
336 SET(INSTALL_SUBDIR_BIN "games/")
337 SET(INSTALL_SUBDIR_SHARE "share/games/supertux2/")
338 SET(INSTALL_SUBDIR_DOC "share/doc/supertux2/")
340 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/supertux2.desktop DESTINATION "share/applications")
342 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION "share/pixmaps/")
344 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
345 ENDIF(WIN32 AND NOT UNIX)
347 INSTALL(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
349 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/INSTALL ${SUPERTUX_SOURCE_DIR}/README ${SUPERTUX_SOURCE_DIR}/COPYING ${SUPERTUX_SOURCE_DIR}/WHATSNEW.txt DESTINATION ${INSTALL_SUBDIR_DOC})
351 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/credits.txt ${SUPERTUX_SOURCE_DIR}/data/camera.cfg DESTINATION ${INSTALL_SUBDIR_SHARE})
352 INSTALL(DIRECTORY data/images DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
353 INSTALL(DIRECTORY data/levels DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
354 INSTALL(DIRECTORY data/music DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
355 INSTALL(DIRECTORY data/scripts DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
356 INSTALL(DIRECTORY data/speech DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
357 INSTALL(DIRECTORY data/sounds DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
358 INSTALL(DIRECTORY data/locale DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
361 ## CPack/Installation-specific stuff
363 INCLUDE(InstallRequiredSystemLibraries)
364 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SuperTux")
365 SET(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
366 SET(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
367 SET(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
368 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)")
369 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/")
370 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
371 # The OS X PackageMaker doesn't seem to like files with no extension
372 ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
373 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${SUPERTUX_SOURCE_DIR}/README")
374 SET(CPACK_RESOURCE_FILE_LICENSE "${SUPERTUX_SOURCE_DIR}/COPYING")
375 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
376 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
377 SET(CPACK_PACKAGE_VERSION_MINOR "3")
378 SET(CPACK_PACKAGE_VERSION_PATCH "1-SVN")
379 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
380 SET(CPACK_PACKAGE_EXECUTABLES "..\\\\supertux2" "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
381 IF(WIN32 AND NOT UNIX)
382 SET(CPACK_NSIS_INSTALLED_ICON_NAME "..\\\\supertux2")
383 SET(CPACK_NSIS_DISPLAY_NAME "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
384 ELSE(WIN32 AND NOT UNIX)
385 ENDIF(WIN32 AND NOT UNIX)