Icecrusher: Use Sector::get_nearest_player().
[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 ## Project name to use as command prefix.
36
37 PROJECT(SUPERTUX)
38
39 ## Version, for display in title bar.
40 ## Will add r<revision number> to the end if svnversion is available.
41 SET(SUPERTUX_VERSION "0.3.3-SVN")
42
43 ### CMake configuration
44
45 # allow building with CMake 2.6. Set compatibility options. Use some bundled modules as a fallback
46 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
47 IF(COMMAND cmake_policy)
48         CMAKE_POLICY(SET CMP0003 NEW)
49 ENDIF(COMMAND cmake_policy)
50
51 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/mk/cmake)
52
53 ## For autopackage
54 OPTION(ENABLE_BINRELOC "Enable autopackage's BINRELOC features" OFF)
55 SET(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/games/supertux2")
56
57 ## Check endianess
58
59 INCLUDE(TestBigEndian)
60 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
61
62 ## Add lots of dependencies to compiler switches
63
64 SET(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0")
65 FIND_PACKAGE(Boost REQUIRED)
66 INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
67 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
68
69 FIND_PACKAGE(SDL REQUIRED)
70 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
71 SET(HAVE_SDL TRUE)
72
73 FIND_PACKAGE(SDL_image REQUIRED)
74 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
75
76 OPTION(ENABLE_OPENGL "Enable OpenGL support" ON)
77 IF(ENABLE_OPENGL)
78   FIND_PACKAGE(OpenGL)
79   IF(OPENGL_FOUND)
80     INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
81     SET(HAVE_OPENGL TRUE)
82   ENDIF(OPENGL_FOUND)
83
84   FIND_PACKAGE(GLEW)
85   IF(GLEW_FOUND)
86     INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
87   ENDIF(GLEW_FOUND)
88 ENDIF(ENABLE_OPENGL)
89
90 FIND_PACKAGE(OpenAL REQUIRED)
91 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
92
93 FIND_PACKAGE(OggVorbis REQUIRED)
94 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
95
96 FIND_PACKAGE(PhysFS REQUIRED)
97 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
98
99 FIND_PACKAGE(CURL)
100 IF(CURL_FOUND)
101   INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
102   SET(HAVE_LIBCURL TRUE)
103 ENDIF(CURL_FOUND)
104
105 #FIND_PACKAGE(ICONV REQUIRED)
106 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
107 #LINK_LIBRARIES(${ICONV_LIBRARY})
108
109 ## Find revision of WC
110 MARK_AS_ADVANCED(SVNVERSION_EXECUTABLE)
111 FIND_PROGRAM(SVNVERSION_EXECUTABLE svnversion)
112 IF(SVNVERSION_EXECUTABLE)
113   ADD_CUSTOM_TARGET(svnversion ALL
114                     cmake -E echo "#ifndef VERSION_H" > "${CMAKE_BINARY_DIR}/version.h.tmp"
115                     COMMAND cmake -E echo "#define VERSION_H" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
116                     COMMAND cmake -E echo_append "#define PACKAGE_VERSION \"${SUPERTUX_VERSION} r" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
117                     COMMAND svnversion -n ${CMAKE_CURRENT_SOURCE_DIR} >> "${CMAKE_BINARY_DIR}/version.h.tmp"
118                     COMMAND cmake -E echo "\"" >>  "${CMAKE_BINARY_DIR}/version.h.tmp"
119                     COMMAND cmake -E echo "#endif" >>  "${CMAKE_BINARY_DIR}/version.h.tmp"
120                     COMMAND cmake -E copy_if_different "${CMAKE_BINARY_DIR}/version.h.tmp" "${CMAKE_BINARY_DIR}/version.h"
121                     COMMAND cmake -E remove "${CMAKE_BINARY_DIR}/version.h.tmp"
122                     WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
123                     COMMENT "Updating ${CMAKE_BINARY_DIR}/version.h..."
124                     VERBATIM)
125 ELSE(SVNVERSION_EXECUTABLE)
126   ADD_CUSTOM_TARGET(svnversion ALL
127                     cmake -E echo "#ifndef VERSION_H" > "${CMAKE_BINARY_DIR}/version.h.tmp"
128                     COMMAND cmake -E echo "#define VERSION_H" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
129                     COMMAND cmake -E echo "#define PACKAGE_VERSION \"${SUPERTUX_VERSION}\"" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
130                     COMMAND cmake -E echo "#endif" >>  "${CMAKE_BINARY_DIR}/version.h.tmp"
131                     COMMAND cmake -E copy_if_different "${CMAKE_BINARY_DIR}/version.h.tmp" "${CMAKE_BINARY_DIR}/version.h"
132                     COMMAND cmake -E remove "${CMAKE_BINARY_DIR}/version.h.tmp"
133                     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
134                     COMMENT "Updating ${CMAKE_BINARY_DIR}/version.h..."
135                     VERBATIM)
136 ENDIF(SVNVERSION_EXECUTABLE)
137
138 SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/version.h
139                             PROPERTIES GENERATED true)
140 SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/main.cpp
141                             PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
142 SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/title_screen.cpp
143                             PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
144 SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/addon/addon_manager.cpp
145                             PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
146 ## Check platform-dependent build options
147
148 INCLUDE(ConfigureChecks)
149
150 ## Also execute instructions in src/squirrel/CMakeLists.txt
151
152 ADD_SUBDIRECTORY(external/squirrel)
153
154 ## Add squirrel lib dir to search path
155
156 LINK_DIRECTORIES(external/squirrel)
157
158 ## Some additional include paths
159
160 include_directories (${CMAKE_BINARY_DIR}/)
161 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src/)
162 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/include/)
163 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/)
164 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/findlocale/)
165 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/obstack/)
166 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/binreloc/)
167
168 ## Build list of sources for supertux binary
169
170 FILE(GLOB SUPERTUX_SOURCES_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/obstack/*.c external/findlocale/findlocale.c)
171
172 FILE(GLOB SUPERTUX_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/main.cpp src/*/*.cpp src/supertux/menu/*.cpp src/video/sdl/*.cpp)
173
174 FILE(GLOB TINYGETTEXT_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/tinygettext/tinygettext/*.cpp)
175 SET_SOURCE_FILES_PROPERTIES(${TINYGETTEXT_SOURCES_CXX} PROPERTIES COMPILE_DEFINITIONS HAVE_SDL)
176
177 IF(HAVE_OPENGL)
178   FILE(GLOB SUPERTUX_OPENGL_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/video/gl/*.cpp)
179   SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_OPENGL_SOURCES})
180 ENDIF(HAVE_OPENGL)
181
182 ## Build miniswig and generate miniswig wrapper
183
184 OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" ${DEBUG})
185 IF(GENERATE_WRAPPER)
186   ADD_SUBDIRECTORY(tools/miniswig)
187   ADD_CUSTOM_COMMAND(
188     OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp
189     COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
190     ARGS -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o ${CMAKE_CURRENT_BINARY_DIR}/miniswig.tmp -I${CMAKE_CURRENT_SOURCE_DIR}/src
191     COMMAND tools/miniswig/miniswig
192     ARGS --input miniswig.tmp --output-cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp --output-hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp --module supertux --select-namespace scripting
193     DEPENDS tools/miniswig/miniswig
194     IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.interface.hpp
195   )
196 ENDIF(GENERATE_WRAPPER)
197
198 IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
199   SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
200 ENDIF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
201
202 ## Compile everything at once (roughly equivalent to cat *.cpp | gcc)
203
204 OPTION(COMPILE_AMALGATION "Compile all the files together at once (experimental)" OFF)
205 IF(COMPILE_AMALGATION)
206   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "// Includes all source files of the project\n")
207   FOREACH(ST_FILE ${SUPERTUX_SOURCES_CXX})
208     FILE(RELATIVE_PATH CXX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src "${CMAKE_CURRENT_SOURCE_DIR}/${ST_FILE}")
209     FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "#include \"${CXX_FILE}\"\n")
210   ENDFOREACH(ST_FILE)
211   ## Build instead of CXX sources
212   SET(SUPERTUX_SOURCES_CXX ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
213 ELSE(COMPILE_AMALGATION)
214   IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
215     FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
216   ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
217 ENDIF(COMPILE_AMALGATION)
218
219 ## Debug options
220
221 OPTION(WERROR "Stop on first compiler warning" OFF)
222 OPTION(WARNINGS "Enable long list of warnings for compiler to check" ${DEBUG})
223 IF(CMAKE_COMPILER_IS_GNUCC)
224   SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
225   SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
226   SET(CMAKE_CXX_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
227   SET(CMAKE_C_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
228   SET(CMAKE_LD_FLAGS_PROFILE "-lgmon" CACHE STRING "Profile flags")
229   ADD_DEFINITIONS(-Wall -Wextra -funit-at-a-time)
230   IF(WERROR)
231     ADD_DEFINITIONS(-Werror)
232   ELSE(WERROR)
233     REMOVE_DEFINITIONS(-Werror)
234   ENDIF(WERROR)
235   IF(WARNINGS)
236     ADD_DEFINITIONS(-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wconversion -Wundef -Wsign-conversion -Wshadow -Winline -Wunsafe-loop-optimizations -Wfloat-equal -Wswitch-default -Wswitch-enum -Wcast-qual -Wsign-promo -Woverloaded-virtual -Wmissing-format-attribute -Wstrict-overflow=5 -Wformat=2-Weffc++ -Wabi -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter)
237     # -ansi fails in MinGW
238     # still left:  -Wold-style-cast -Wpadded
239   ENDIF(WARNINGS)
240 ENDIF(CMAKE_COMPILER_IS_GNUCC)
241
242 ## If xgettext is available, generate messages.pot for sources
243
244 OPTION(GENERATE_MESSAGESPOT "Generate messages.pot files" ${DEBUG})
245 IF(GENERATE_MESSAGESPOT)
246   MARK_AS_ADVANCED(
247     XGETTEXT_EXECUTABLE
248   )
249   FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
250   IF(NOT XGETTEXT_EXECUTABLE)
251     MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
252   ELSE(NOT XGETTEXT_EXECUTABLE)
253     MESSAGE(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
254
255     SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/data/locale/messages.pot)
256     ADD_CUSTOM_COMMAND(
257       OUTPUT ${MESSAGES_POT_FILE}
258       COMMAND ${XGETTEXT_EXECUTABLE}
259       ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES_CXX}
260       DEPENDS ${SUPERTUX_SOURCES_CXX}
261       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
262       COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
263     )
264     LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
265
266     FILE(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} data/levels/*)
267     LIST(REMOVE_ITEM SUPERTUX_LEVEL_DIRS "data/levels/.svn")
268     FOREACH(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
269       FILE(GLOB SUPERTUX_LEVELS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
270
271       ## Do not add target if SUPERTUX_LEVELS is empty. This is needed for cmake <=2.4
272       IF(SUPERTUX_LEVELS)
273       SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
274       ADD_CUSTOM_COMMAND(
275         OUTPUT ${MESSAGES_POT_FILE}
276         COMMAND ${XGETTEXT_EXECUTABLE}
277         ARGS --keyword="_:1" --language=Lisp --force-po --sort-by-file "--output=${MESSAGES_POT_FILE}" ${SUPERTUX_LEVELS}
278         DEPENDS ${SUPERTUX_LEVELS}
279         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
280         COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
281       )
282       LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
283       ENDIF(SUPERTUX_LEVELS)
284
285     ENDFOREACH(SUPERTUX_LEVEL_DIR)
286
287     ADD_CUSTOM_TARGET(
288       supertux2-messages ALL 
289       DEPENDS ${MESSAGES_POT_FILES}
290     )
291
292   ENDIF(NOT XGETTEXT_EXECUTABLE)
293 ENDIF(GENERATE_MESSAGESPOT)
294
295 ## Some additional compiler switches
296 IF(CMAKE_COMPILER_IS_GNUCC)
297   ADD_DEFINITIONS(-fno-strict-aliasing)
298 ENDIF(CMAKE_COMPILER_IS_GNUCC)
299
300 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
301   ADD_DEFINITIONS(-DMACOSX)
302 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
303
304
305 ## On Windows, add an icon
306
307 IF(WIN32)
308   SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
309   IF(MINGW)
310     ADD_CUSTOM_COMMAND(
311     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
312     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)
313     SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
314   ELSE(MINGW)
315     SET(SUPERTUX_EXE_SRCS ${SUPERTUX_EXE_SRCS} supertux.rc)
316   ENDIF(MINGW)
317 ENDIF(WIN32)
318
319 ## Add binreloc.c if enabled
320 IF(ENABLE_BINRELOC)
321   SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_SOURCE_DIR}/external/binreloc/binreloc.c)
322 ENDIF(ENABLE_BINRELOC)
323
324
325 ## Generate supertux executable in the right place
326
327 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
328
329 ## Add target for supertux binary
330
331 ADD_EXECUTABLE(supertux2 ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_C} ${SUPERTUX_SOURCES_CXX} ${TINYGETTEXT_SOURCES_CXX})
332 ADD_DEPENDENCIES(supertux2 svnversion)
333
334 ## Link supertux binary with squirrel and other libraries
335
336 TARGET_LINK_LIBRARIES(supertux2 squirrel)
337 TARGET_LINK_LIBRARIES(supertux2 ${SDL_LIBRARY})
338 TARGET_LINK_LIBRARIES(supertux2 ${SDLIMAGE_LIBRARY})
339 TARGET_LINK_LIBRARIES(supertux2 ${OPENAL_LIBRARY})
340 TARGET_LINK_LIBRARIES(supertux2 ${OGGVORBIS_LIBRARIES})
341 TARGET_LINK_LIBRARIES(supertux2 ${PHYSFS_LIBRARY})
342 IF(HAVE_OPENGL)
343     TARGET_LINK_LIBRARIES(supertux2 ${OPENGL_LIBRARY})
344     TARGET_LINK_LIBRARIES(supertux2 ${GLEW_LIBRARY})
345 ENDIF(HAVE_OPENGL)
346 IF(HAVE_LIBCURL)
347   TARGET_LINK_LIBRARIES(supertux2 ${CURL_LIBRARY})
348 ENDIF(HAVE_LIBCURL)
349
350 ## Install stuff
351
352 IF(WIN32 AND NOT UNIX)
353
354   SET(INSTALL_SUBDIR_BIN "." CACHE STRING "Installation subdir for binaries")
355   SET(INSTALL_SUBDIR_SHARE "data" CACHE STRING "Installation subdir for data")
356   SET(INSTALL_SUBDIR_DOC "." CACHE STRING "Installation subdir for docs")
357
358   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SDL.dll
359                 ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image.dll
360                 ${CMAKE_CURRENT_SOURCE_DIR}/iconv.dll
361                 ${CMAKE_CURRENT_SOURCE_DIR}/libogg-0.dll
362                 ${CMAKE_CURRENT_SOURCE_DIR}/libphysfs-1-0-0.dll
363                 ${CMAKE_CURRENT_SOURCE_DIR}/OpenAl32.dll
364                 ${CMAKE_CURRENT_SOURCE_DIR}/wrap_oal.dll
365                 ${CMAKE_CURRENT_SOURCE_DIR}/libcurl-4.dll DESTINATION ${INSTALL_SUBDIR_BIN})
366
367   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
368
369 ELSE(WIN32 AND NOT UNIX)
370 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
371
372   SET(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS" CACHE STRING "Installation subdir for binaries")
373   SET(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data" CACHE STRING "Installation subdir for data")
374   SET(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources" CACHE STRING "Installation subdir for docs")
375
376   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
377
378   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.icns DESTINATION "SuperTux.app/Contents/Resources/")
379
380 ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
381
382   SET(INSTALL_SUBDIR_BIN "games" CACHE STRING "Installation subdir for binaries")
383   SET(INSTALL_SUBDIR_SHARE "share/games/supertux2" CACHE STRING "Installation subdir for data")
384   SET(INSTALL_SUBDIR_DOC "share/doc/supertux2" CACHE STRING "Installation subdir for docs")
385
386   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.desktop DESTINATION "share/applications")
387
388   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION "share/pixmaps/")
389
390 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
391 ENDIF(WIN32 AND NOT UNIX)
392
393 INSTALL(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
394
395 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_SOURCE_DIR}/COPYING ${CMAKE_CURRENT_SOURCE_DIR}/WHATSNEW.txt DESTINATION ${INSTALL_SUBDIR_DOC})
396
397 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/credits.txt DESTINATION ${INSTALL_SUBDIR_SHARE})
398
399 INSTALL(DIRECTORY data/images
400                   data/fonts
401                   data/levels
402                   data/music
403                   data/scripts
404                   data/speech
405                   data/sounds
406                   data/locale
407                                DESTINATION ${INSTALL_SUBDIR_SHARE} PATTERN ".svn" EXCLUDE)
408
409 ## Create config.h now that INSTALL_SUBDIR_* have been set.
410
411 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
412
413
414 ## CPack/Installation-specific stuff
415
416 INCLUDE(InstallRequiredSystemLibraries)
417 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Jump'n'Run Game featuring Tux")
418 SET(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
419 SET(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
420 SET(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
421 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), libcurl3 (>= 7.16)")
422 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 completely 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/")
423 SET(CPACK_DEBIAN_PACKAGE_SECTION "games")
424 SET(CPACK_RPM_PACKAGE_NAME "supertux2")
425 SET(CPACK_RPM_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 completely 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/")
426 SET(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
427 SET(CPACK_RPM_PACKAGE_GROUP "Amusements/Games/Action/Arcade")
428 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
429   # The OS X PackageMaker doesn't seem to like files with no extension
430 ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
431   SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
432   SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
433 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
434 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
435 SET(CPACK_PACKAGE_VERSION_MINOR "3")
436 SET(CPACK_PACKAGE_VERSION_PATCH "2-SVN")
437 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
438 SET(CPACK_PACKAGE_EXECUTABLES "..\\\\supertux2" "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
439 IF(WIN32 AND NOT UNIX)
440   SET(CPACK_NSIS_INSTALLED_ICON_NAME "..\\\\supertux2")
441   SET(CPACK_NSIS_DISPLAY_NAME "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
442 ELSE(WIN32 AND NOT UNIX)
443 ENDIF(WIN32 AND NOT UNIX)
444 INCLUDE(CPack)
445
446 # move some config clutter to the advanced section
447 MARK_AS_ADVANCED(
448   INSTALL_SUBDIR_BIN
449   INSTALL_SUBDIR_SHARE
450   INSTALL_SUBDIR_DOC
451 )
452
453 MARK_AS_ADVANCED(
454         CMAKE_BACKWARDS_COMPATIBILITY
455         CMAKE_BUILD_TYPE
456         CMAKE_INSTALL_PREFIX
457         EXECUTABLE_OUTPUT_PATH
458         LIBRARY_OUTPUT_PATH
459         CMAKE_OSX_ARCHITECTURES
460         CMAKE_OSX_SYSROOT
461 )
462
463 MARK_AS_ADVANCED(
464         ENABLE_BINRELOC
465         APPDATADIR
466 )
467
468 MARK_AS_ADVANCED(
469         Boost_INCLUDE_DIR
470         Boost_LIBRARIES
471 )
472
473 MARK_AS_ADVANCED(
474         SDLMAIN_LIBRARY
475         SDL_INCLUDE_DIR
476         SDL_LIBRARY
477 )
478
479 MARK_AS_ADVANCED(
480         SDLIMAGE_INCLUDE_DIR
481         SDLIMAGE_LIBRARY
482 )
483
484 MARK_AS_ADVANCED(
485         OPENAL_INCLUDE_DIR
486         OPENAL_LIBRARY
487 )
488
489 MARK_AS_ADVANCED(
490         OGG_LIBRARY
491         VORBISENC_LIBRARY
492         VORBISFILE_LIBRARY
493         VORBIS_INCLUDE_DIR
494         VORBIS_LIBRARY
495 )
496
497 MARK_AS_ADVANCED(
498         PHYSFS_INCLUDE_DIR
499         PHYSFS_LIBRARY
500 )