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
38 # FIXME: provide working install target
42 ## (Optional) Generate noisy Makefile
44 #SET(CMAKE_VERBOSE_MAKEFILE on)
46 ## Project name to use as command prefix
50 ## Some default settings
52 set(DEBUG 0 CACHE BOOL "Build with debugging options")
53 set(ENABLE_BINRELOC 0 CACHE BOOL "Enable autopackage's BINRELOC features")
54 set(APPDATADIR "" CACHE STRING "APPDATADIR for autopackage's BINRELOC features")
55 set(ENABLE_SQDBG 0 CACHE BOOL "Build squirrel script interpreter with debugging options")
56 set(ENABLE_OPENGL 1 CACHE BOOL "Enable OpenGL support")
58 ## Search here for additional cmake modules (for finding deps)
60 set(CMAKE_MODULE_PATH ${SUPERTUX_SOURCE_DIR}/mk/cmake ${CMAKE_MODULE_PATH})
62 ## Add lots of dependencies to compiler switches
64 FIND_PACKAGE(SDL REQUIRED)
65 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
66 LINK_LIBRARIES(${SDL_LIBRARY})
68 FIND_PACKAGE(SDL_image REQUIRED)
69 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
70 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
74 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
75 LINK_LIBRARIES(${OPENGL_LIBRARY})
76 SET(HAVE_OPENGL OPENGL_FOUND)
79 FIND_PACKAGE(OpenAL REQUIRED)
80 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
81 LINK_LIBRARIES(${OPENAL_LIBRARY})
83 FIND_PACKAGE(OggVorbis REQUIRED)
84 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
85 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
87 FIND_PACKAGE(PhysFS REQUIRED)
88 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
89 LINK_LIBRARIES(${PHYSFS_LIBRARY})
91 #FIND_PACKAGE(ICONV REQUIRED)
92 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
93 #LINK_LIBRARIES(${ICONV_LIBRARY})
95 ## Check platform-dependent build options
97 INCLUDE(ConfigureChecks)
101 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
102 include_directories (${CMAKE_BINARY_DIR}/)
104 ## Also execute instructions in tools/miniswig/CMakeLists.txt
105 ADD_SUBDIRECTORY(tools/miniswig)
107 ## Also execute instructions in src/squirrel/CMakeLists.txt
109 ADD_SUBDIRECTORY(src/squirrel)
111 ## Add squirrel lib dir to search path
113 LINK_DIRECTORIES(src/squirrel)
115 ## Some additional include paths
117 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
118 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
120 ## Build list of sources for supertux binary
122 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)
124 ## Generate miniswig wrapper
127 OUTPUT ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp
128 COMMAND ${CMAKE_CXX_COMPILER}
129 ARGS -x "c++" -E -CC -DSCRIPTING_API -I${SUPERTUX_SOURCE_DIR}/src/ -I${SUPERTUX_SOURCE_DIR}/src/squirrel/include/ ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.interface.hpp -o miniswig.tmp
130 COMMAND tools/miniswig/miniswig
131 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
132 DEPENDS src/scripting/wrapper.interface.hpp tools/miniswig/miniswig
135 ## If xgettext is available, generate messages.pot for sources
142 IF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
143 MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
144 ELSE(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
145 MESSAGE(STATUS "Found xgettext: ${XGETTEXT}")
146 SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
148 supertux-messages.pot ALL
149 COMMAND "/usr/bin/xgettext" -k_ -C -o ${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
150 DEPENDS ${SUPERTUX_SOURCES}
151 WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
153 ENDIF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
155 ## Some additional compiler switches
157 ADD_DEFINITIONS(-O2 -fno-strict-aliasing)
159 ## Add target for supertux binary
161 ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES} )
163 ## Link supertux binary with squirrel
165 TARGET_LINK_LIBRARIES(supertux2 squirrel)
167 ## After building, copy binary to source root
172 COMMAND ${CMAKE_COMMAND}
173 ARGS -E copy supertux2 ${SUPERTUX_SOURCE_DIR}/supertux2