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 ## (Optional) Generate noisy Makefile
43 #SET(CMAKE_VERBOSE_MAKEFILE on)
45 ## Project name to use as command prefix
49 ## Some default settings
51 set(DEBUG 0 CACHE BOOL "Build with debugging options")
52 set(ENABLE_BINRELOC 0 CACHE BOOL "Enable autopackage's BINRELOC features")
53 set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "APPDATADIR for autopackage's BINRELOC features")
54 set(ENABLE_SQDBG 0 CACHE BOOL "Build squirrel script interpreter with debugging options")
55 set(ENABLE_OPENGL 1 CACHE BOOL "Enable OpenGL support")
57 ## Search here for additional cmake modules (for finding deps)
59 set(CMAKE_MODULE_PATH ${SUPERTUX_SOURCE_DIR}/mk/cmake ${CMAKE_MODULE_PATH})
61 ## Add lots of dependencies to compiler switches
63 FIND_PACKAGE(SDL REQUIRED)
64 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
65 LINK_LIBRARIES(${SDL_LIBRARY})
67 FIND_PACKAGE(SDL_image REQUIRED)
68 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
69 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
73 IF(${OPENGL_FOUND} STREQUAL "YES")
74 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
75 LINK_LIBRARIES(${OPENGL_LIBRARY})
77 ENDIF(${OPENGL_FOUND} STREQUAL "YES")
80 FIND_PACKAGE(OpenAL REQUIRED)
81 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
82 LINK_LIBRARIES(${OPENAL_LIBRARY})
84 FIND_PACKAGE(OggVorbis REQUIRED)
85 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
86 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
88 FIND_PACKAGE(PhysFS REQUIRED)
89 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
90 LINK_LIBRARIES(${PHYSFS_LIBRARY})
92 #FIND_PACKAGE(ICONV REQUIRED)
93 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
94 #LINK_LIBRARIES(${ICONV_LIBRARY})
96 ## Check platform-dependent build options
98 INCLUDE(ConfigureChecks)
102 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
103 include_directories (${CMAKE_BINARY_DIR}/)
105 ## Also execute instructions in tools/miniswig/CMakeLists.txt
106 ADD_SUBDIRECTORY(tools/miniswig)
108 ## Also execute instructions in src/squirrel/CMakeLists.txt
110 ADD_SUBDIRECTORY(src/squirrel)
112 ## Add squirrel lib dir to search path
114 LINK_DIRECTORIES(src/squirrel)
116 ## Some additional include paths
118 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
119 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/)
120 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
122 ## Build list of sources for supertux binary
124 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)
126 ## Generate miniswig wrapper
129 OUTPUT ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp
130 COMMAND cd ${SUPERTUX_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
131 ARGS -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o ${SUPERTUX_BINARY_DIR}/miniswig.tmp
132 COMMAND tools/miniswig/miniswig
133 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
134 DEPENDS src/scripting/wrapper.interface.hpp tools/miniswig/miniswig
137 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCES})
139 ## If xgettext is available, generate messages.pot for sources
146 #IF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
147 # MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
148 #ELSE(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
149 # MESSAGE(STATUS "Found xgettext: ${XGETTEXT}")
150 # SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
152 # supertux-messages.pot ALL
153 # COMMAND "/usr/bin/xgettext" -k_ -C -o ${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
154 # DEPENDS ${SUPERTUX_SOURCES}
155 # WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
157 #ENDIF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
159 ## Some additional compiler switches
161 ADD_DEFINITIONS(-O2 -fno-strict-aliasing)
163 ## Add target for supertux binary
165 ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES})
167 ## Link supertux binary with squirrel
169 TARGET_LINK_LIBRARIES(supertux2 squirrel)
171 ## After building, copy binary to source root
176 COMMAND ${CMAKE_COMMAND}
177 ARGS -E copy supertux2 ${SUPERTUX_SOURCE_DIR}/supertux2
182 INSTALL(TARGETS supertux2 DESTINATION bin)
184 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION share/pixmaps)
186 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/supertux2.desktop DESTINATION share/applications)
188 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)
190 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/credits.txt ${SUPERTUX_SOURCE_DIR}/data/camera.cfg DESTINATION share/supertux2)
191 INSTALL(DIRECTORY data/images DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
192 INSTALL(DIRECTORY data/levels DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
193 INSTALL(DIRECTORY data/music DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
194 INSTALL(DIRECTORY data/scripts DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
195 INSTALL(DIRECTORY data/speech DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
196 INSTALL(DIRECTORY data/sounds DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)
197 INSTALL(DIRECTORY data/locale DESTINATION share/supertux2 PATTERN ".svn" EXCLUDE)