fix squirrel debug building for cmake
[supertux.git] / CMakeLists.txt
1 #
2 # SuperTux - root build script
3 # Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
4 #
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.
9
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.
14
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
18 #
19
20
21 #
22 # INSTRUCTIONS:
23 # -------------
24 #
25 # Create a directory build/ and change to it. Run
26 #
27 #   cmake ..
28 #
29 # This creates a set of Makefiles to build the project. Run
30 #
31 #   make
32 #
33
34
35 #
36 # FIXME: create config.h from config.h.in
37 # FIXME: create messages.pot for levels
38 #
39
40
41 ## (Optional) Generate noisy Makefile
42
43 #SET(CMAKE_VERBOSE_MAKEFILE on)
44
45 ## Project name to use as command prefix
46
47 PROJECT(SUPERTUX)
48
49 ## Some default settings
50
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")
56
57 ## Search here for additional cmake modules (for finding deps)
58
59 set(CMAKE_MODULE_PATH ${SUPERTUX_SOURCE_DIR}/mk/cmake ${CMAKE_MODULE_PATH})
60
61 ## Add lots of dependencies to compiler switches
62
63 FIND_PACKAGE(SDL REQUIRED)
64 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
65 LINK_LIBRARIES(${SDL_LIBRARY})
66
67 FIND_PACKAGE(SDL_image REQUIRED)
68 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
69 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
70
71 IF(ENABLE_OPENGL)
72   FIND_PACKAGE(OpenGL)
73   IF(${OPENGL_FOUND} STREQUAL "YES")
74     INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
75     LINK_LIBRARIES(${OPENGL_LIBRARY})
76     SET(HAVE_OPENGL TRUE)
77   ENDIF(${OPENGL_FOUND} STREQUAL "YES")
78 ENDIF(ENABLE_OPENGL)
79
80 FIND_PACKAGE(OpenAL REQUIRED)
81 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
82 LINK_LIBRARIES(${OPENAL_LIBRARY})
83
84 FIND_PACKAGE(OggVorbis REQUIRED)
85 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
86 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
87
88 FIND_PACKAGE(PhysFS REQUIRED)
89 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
90 LINK_LIBRARIES(${PHYSFS_LIBRARY})
91
92 #FIND_PACKAGE(ICONV REQUIRED)
93 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
94 #LINK_LIBRARIES(${ICONV_LIBRARY})
95
96 ## Check platform-dependent build options
97
98 INCLUDE(ConfigureChecks)
99
100 ## Create config.h
101
102 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
103 include_directories (${CMAKE_BINARY_DIR}/)
104
105 ## Also execute instructions in tools/miniswig/CMakeLists.txt
106 ADD_SUBDIRECTORY(tools/miniswig)
107
108 ## Also execute instructions in src/squirrel/CMakeLists.txt
109
110 ADD_SUBDIRECTORY(src/squirrel)
111
112 ## Add squirrel lib dir to search path
113
114 LINK_DIRECTORIES(src/squirrel)
115
116 ## Some additional include paths
117
118 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
119 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/)
120 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
121
122 ## Build list of sources for supertux binary
123
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)
125
126 ## Generate miniswig wrapper
127
128 ADD_CUSTOM_COMMAND(
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
135 )
136
137 SET(SUPERTUX_SOURCES ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCES})
138
139 ## If xgettext is available, generate messages.pot for sources
140
141 #FIND_PROGRAM(
142 #  XGETTEXT 
143 #  NAMES "xgettext"
144 #  PATHS "/usr/bin"
145 #)
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)
151 #  ADD_CUSTOM_TARGET(
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}
156 #  )
157 #ENDIF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
158
159 ## Some additional compiler switches
160
161 ADD_DEFINITIONS(-O2 -fno-strict-aliasing)
162
163 ## Add target for supertux binary
164
165 ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES})
166
167 ## Link supertux binary with squirrel
168
169 TARGET_LINK_LIBRARIES(supertux2 squirrel)
170
171 ## After building, copy binary to source root
172
173 ADD_CUSTOM_COMMAND(
174   TARGET supertux2
175   POST_BUILD
176   COMMAND ${CMAKE_COMMAND}
177   ARGS -E copy supertux2 ${SUPERTUX_SOURCE_DIR}/supertux2
178 )
179
180 ## Install stuff
181
182 INSTALL(TARGETS supertux2 DESTINATION bin)
183
184 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.png ${SUPERTUX_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION share/pixmaps)
185
186 INSTALL(FILES ${SUPERTUX_SOURCE_DIR}/supertux2.desktop DESTINATION share/applications)
187
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)
189
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)