Added skeleton build scripts for use with cmake. Note that this is far from finished...
[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 ## Search here for additional cmake modules (for finding deps)
53
54 set(CMAKE_MODULE_PATH ${SUPERTUX_SOURCE_DIR}/mk/cmake ${CMAKE_MODULE_PATH})
55
56 ## Add lots of dependencies to compiler switches
57
58 FIND_PACKAGE(SDL REQUIRED)
59 INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
60 LINK_LIBRARIES(${SDL_LIBRARY})
61
62 FIND_PACKAGE(SDL_image REQUIRED)
63 INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
64 LINK_LIBRARIES(${SDLIMAGE_LIBRARY})
65
66 FIND_PACKAGE(OpenGL REQUIRED)
67 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
68 LINK_LIBRARIES(${OPENGL_LIBRARY})
69
70 FIND_PACKAGE(OpenAL REQUIRED)
71 INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
72 LINK_LIBRARIES(${OPENAL_LIBRARY})
73
74 FIND_PACKAGE(OggVorbis REQUIRED)
75 INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIR})
76 LINK_LIBRARIES(${OGGVORBIS_LIBRARIES})
77
78 FIND_PACKAGE(PhysFS REQUIRED)
79 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
80 LINK_LIBRARIES(${PHYSFS_LIBRARY})
81
82 ## Also execute instructions in src/squirrel/CMakeLists.txt
83
84 ADD_SUBDIRECTORY(src/squirrel)
85
86 ## Add squirrel lib dir to search path
87
88 LINK_DIRECTORIES(src/squirrel)
89
90 ## Some additional include paths
91
92 include_directories (${SUPERTUX_SOURCE_DIR}/)
93 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
94 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
95
96 ## Build list of sources for supertux binary
97
98 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)
99
100 ## If xgettext is available, generate messages.pot for sources
101
102 FIND_PROGRAM(
103   XGETTEXT 
104   NAMES "xgettext"
105   PATHS "/usr/bin"
106 )
107 IF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
108   MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
109 ELSE(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
110   MESSAGE(STATUS "Found xgettext: ${XGETTEXT}")
111   SET(MESSAGES_POT_FILE ${SUPERTUX_SOURCE_DIR}/data/locale/messages.pot)
112   ADD_CUSTOM_TARGET(
113     supertux-messages.pot ALL 
114     COMMAND "/usr/bin/xgettext" -k_ -C -o ${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES}
115     DEPENDS ${SUPERTUX_SOURCES}
116     WORKING_DIRECTORY ${SUPERTUX_SOURCE_DIR}
117   )
118 ENDIF(${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
119
120 ## Some additional compiler switches
121
122 ADD_DEFINITIONS(-O2 -fno-strict-aliasing)
123
124 ## Add target for supertux binary
125
126 ADD_EXECUTABLE(supertux ${SUPERTUX_SOURCES} )
127
128 ## Link supertux binary with squirrel
129
130 TARGET_LINK_LIBRARIES(supertux squirrel)
131
132 ## After building, copy binary to source root
133
134 ADD_CUSTOM_COMMAND(
135   TARGET supertux
136   POST_BUILD
137   COMMAND ${CMAKE_COMMAND}
138   ARGS -E copy supertux ${SUPERTUX_SOURCE_DIR}/supertux
139 )
140