Make Tux run automatically. As before, if he is carrying something Tux
[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: compile miniswig
38 # FIXME: use miniswig to create squirrel wrappers
39 # FIXME: create messages.pot for levels
40 # FIXME: provide working install target
41 #
42
43
44 ## (Optional) Generate noisy Makefile
45
46 #SET(CMAKE_VERBOSE_MAKEFILE on)
47
48 ## Project name to use as command prefix
49
50 PROJECT(SUPERTUX)
51
52 ## Some default settings
53
54 set(DEBUG 0 CACHE BOOL "Build with debugging options")
55 set(ENABLE_BINRELOC 0 CACHE BOOL "Enable autopackage's BINRELOC features")
56 set(APPDATADIR "" CACHE STRING "APPDATADIR for autopackage's BINRELOC features")
57 set(ENABLE_SQDBG 0 CACHE BOOL "Build squirrel script interpreter with debugging options")
58
59 ## Search here for additional cmake modules (for finding deps)
60
61 set(CMAKE_MODULE_PATH ${SUPERTUX_SOURCE_DIR}/mk/cmake ${CMAKE_MODULE_PATH})
62
63 ## Add lots of dependencies to compiler switches
64
65 FIND_PACKAGE(SDL REQUIRED)
66 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
67 LINK_LIBRARIES(${SDL_LIBRARY})
68
69 FIND_PACKAGE(SDL_image REQUIRED)
70 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
71 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
72
73 FIND_PACKAGE(OpenGL REQUIRED)
74 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
75 LINK_LIBRARIES(${OPENGL_LIBRARY})
76
77 FIND_PACKAGE(OpenAL REQUIRED)
78 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
79 LINK_LIBRARIES(${OPENAL_LIBRARY})
80
81 FIND_PACKAGE(OggVorbis REQUIRED)
82 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
83 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
84
85 FIND_PACKAGE(PhysFS REQUIRED)
86 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
87 LINK_LIBRARIES(${PHYSFS_LIBRARY})
88
89 #FIND_PACKAGE(ICONV REQUIRED)
90 #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
91 #LINK_LIBRARIES(${ICONV_LIBRARY})
92
93 ## Check platform-dependent build options
94
95 INCLUDE(ConfigureChecks)
96
97 ## Create config.h
98
99 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
100 include_directories (${CMAKE_BINARY_DIR}/)
101
102 ## Also execute instructions in src/squirrel/CMakeLists.txt
103
104 ADD_SUBDIRECTORY(src/squirrel)
105
106 ## Add squirrel lib dir to search path
107
108 LINK_DIRECTORIES(src/squirrel)
109
110 ## Some additional include paths
111
112 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
113 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
114
115 ## Build list of sources for supertux binary
116
117 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)
118
119 ## If xgettext is available, generate messages.pot for sources
120
121 FIND_PROGRAM(
122   XGETTEXT 
123   NAMES "xgettext"
124   PATHS "/usr/bin"
125 )
126 IF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
127   MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
128 ELSE(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
129   MESSAGE(STATUS "Found xgettext: ${XGETTEXT}")
130   SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
131   ADD_CUSTOM_TARGET(
132     supertux-messages.pot ALL 
133     COMMAND "/usr/bin/xgettext" -k_ -C -o ${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
134     DEPENDS ${SUPERTUX_SOURCES}
135     WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
136   )
137 ENDIF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
138
139 ## Some additional compiler switches
140
141 ADD_DEFINITIONS(-O2 -fno-strict-aliasing)
142
143 ## Add target for supertux binary
144
145 ADD_EXECUTABLE(supertux ${SUPERTUX_SOURCES} )
146
147 ## Link supertux binary with squirrel
148
149 TARGET_LINK_LIBRARIES(supertux squirrel)
150
151 ## After building, copy binary to source root
152
153 ADD_CUSTOM_COMMAND(
154   TARGET supertux
155   POST_BUILD
156   COMMAND ${CMAKE_COMMAND}
157   ARGS -E copy supertux ${SUPERTUX_SOURCE_DIR}/supertux
158 )
159