-
Notifications
You must be signed in to change notification settings - Fork 275
/
build.cmake
330 lines (287 loc) · 12.3 KB
/
build.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
if (CMAKE_SIZEOF_VOID_P MATCHES 8)
MESSAGE( "Yes" )
else (CMAKE_SIZEOF_VOID_P MATCHES 8)
MESSAGE( "No" )
endif (CMAKE_SIZEOF_VOID_P MATCHES 8)
OPTION(DEBUG "enable debug build" No)
OPTION(SDL "SDL support (will not work without)" Yes)
OPTION(OPENGL "OpenGL support" Yes)
OPTION(OGG "Ogg/Vorbis support" Yes)
OPTION(TREMOR "Tremor support" No)
IF (DEBUG)
SET(CMAKE_BUILD_TYPE Debug)
ELSE (DEBUG)
SET(CMAKE_BUILD_TYPE Release)
ENDIF (DEBUG)
# Platform specific things can be put here
# Compilers and other specific variables can be found here:
# http://www.cmake.org/Wiki/CMake_Useful_Variables
SET(USRDIR /usr)
set(CMAKE_INCLUDE_PATH ${USRDIR})
# Compilation Flags and executables
IF (BUILD_TYPE STREQUAL GP2X OR
BUILD_TYPE STREQUAL WIZ OR
BUILD_TYPE STREQUAL CAANOO OR
BUILD_TYPE STREQUAL DINGOO OR
BUILD_TYPE STREQUAL PANDORA OR
BUILD_TYPE STREQUAL NANONOTE)
IF (BUILD_TYPE STREQUAL GP2X)
SET(USRDIR /mythtv/media/devel/toolchains/open2x/gcc-4.1.1-glibc-2.3.6)
SET(CMAKE_C_COMPILER ${USRDIR}/bin/arm-open2x-linux-gcc)
SET(CMAKE_CXX_COMPILER ${USRDIR}/bin/arm-open2x-linux-g++)
ADD_DEFINITIONS(-DGP2X)
ADD_DEFINITIONS(-DNOKEYBOARD)
SET(OGG Yes)
ELSEIF(BUILD_TYPE STREQUAL WIZ)
SET(USRDIR /mythtv/media/devel/toolchains/openwiz/arm-openwiz-linux-gnu)
SET(CMAKE_C_COMPILER ${USRDIR}/bin/arm-openwiz-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER ${USRDIR}/bin/arm-openwiz-linux-gnu-g++)
ADD_DEFINITIONS(-DWIZ)
ADD_DEFINITIONS(-DNOKEYBOARD)
SET(OGG Yes)
ELSEIF(BUILD_TYPE STREQUAL CAANOO)
SET(USRDIR /mythtv/media/devel/toolchains/caanoo/GPH_SDK)
SET(CMAKE_C_COMPILER ${USRDIR}/tools/gcc-4.2.4-glibc-2.7-eabi/bin/arm-gph-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER ${USRDIR}/tools/gcc-4.2.4-glibc-2.7-eabi/bin/arm-gph-linux-gnueabi-g++)
ADD_DEFINITIONS(-DCAANOO)
SET(OGG Yes)
include_directories(${USRDIR}/DGE/include)
include_directories(${USRDIR}/DGE/include/SDL)
include_directories(${USRDIR}/DGE/include/vorbis)
link_directories(${USRDIR}/DGE/lib/target)
ADD_DEFINITIONS(-DCAANOO)
ADD_DEFINITIONS(-DNOKEYBOARD)
SET(OGG Yes)
ELSEIF(BUILD_TYPE STREQUAL DINGOO)
SET(USRDIR /opt/mipsel-linux-uclibc/usr)
SET(CMAKE_C_COMPILER ${USRDIR}/bin/mipsel-linux-uclibc-gcc)
SET(CMAKE_CXX_COMPILER ${USRDIR}/bin/mipsel-linux-uclibc-g++)
include_directories(${USRDIR}/DGE/include/tremor)
ADD_DEFINITIONS(-DDINGOO)
ADD_DEFINITIONS(-DNOKEYBOARD)
SET(OGG No)
SET(TREMOR Yes)
ELSEIF(BUILD_TYPE STREQUAL PANDORA)
SET(USRDIR /mythtv/media/devel/toolchains/pandora/arm-2007q3)
SET(CMAKE_C_COMPILER ${USRDIR}/bin/arm-none-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER ${USRDIR}/bin/arm-none-linux-gnueabi-g++)
ADD_DEFINITIONS(-DPANDORA)
ADD_DEFINITIONS(-mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a)
ADD_DEFINITIONS(-mfloat-abi=softfp -mfpu=neon -ftree-vectorize -fno-strict-aliasing -fsingle-precision-constant)
SET(OGG Yes)
ELSEIF(BUILD_TYPE STREQUAL NANONOTE)
SET(USRDIR /usr/local/jlime/mipsel-toolchain/usr)
SET(CMAKE_C_COMPILER ${USRDIR}/bin/mipsel-linux-gcc)
SET(CMAKE_CXX_COMPILER ${USRDIR}/bin/mipsel-linux-g++)
ADD_DEFINITIONS(-DNANONOTE)
SET(OGG No)
SET(TREMOR No)
ENDIF(BUILD_TYPE STREQUAL GP2X)
SET(BUILD_TYPE LINUX32)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_FIND_ROOT_PATH ${USRDIR})
SET(CMAKE_INSTALL_USRDIR ${USRDIR})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_LIBRARY_USRDIRES lib)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
SET(OPENGL No)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_DEFINITIONS(-fsigned-char)
ADD_DEFINITIONS(-ffast-math)
ADD_DEFINITIONS(-fomit-frame-pointer)
IF (NOT BUILD_TYPE STREQUAL CAANOO)
include_directories(${USRDIR}/include)
include_directories(${USRDIR}/include/vorbis)
link_directories(${USRDIR}/lib)
ENDIF (NOT BUILD_TYPE STREQUAL CAANOO)
ENDIF (BUILD_TYPE STREQUAL GP2X OR
BUILD_TYPE STREQUAL WIZ OR
BUILD_TYPE STREQUAL CAANOO OR
BUILD_TYPE STREQUAL DINGOO OR
BUILD_TYPE STREQUAL PANDORA OR
BUILD_TYPE STREQUAL NANONOTE)
# Check wether in what system it is configured
IF(NOT HAVE_64_BIT AND BUILD_TYPE STREQUAL LINUX64)
MESSAGE( "Warning: Building 64-bit Version on 32-bit machine is not supported!" )
ENDIF(NOT HAVE_64_BIT AND BUILD_TYPE STREQUAL LINUX64)
# Directory creation of all the builds
EXEC_PROGRAM(mkdir ARGS -p ${CMAKE_CURRENT_SOURCE_DIR}/build OUTPUT_VARIABLE NULL)
EXEC_PROGRAM(mkdir ARGS -p ${CMAKE_CURRENT_SOURCE_DIR}/build/Linux32 OUTPUT_VARIABLE NULL)
EXEC_PROGRAM(mkdir ARGS -p ${CMAKE_CURRENT_SOURCE_DIR}/build/Linux64 OUTPUT_VARIABLE NULL)
EXEC_PROGRAM(mkdir ARGS -p ${CMAKE_CURRENT_SOURCE_DIR}/build/Win32 OUTPUT_VARIABLE NULL)
EXEC_PROGRAM(mkdir ARGS -p ${CMAKE_CURRENT_SOURCE_DIR}/build/Wiz OUTPUT_VARIABLE NULL)
EXEC_PROGRAM(mkdir ARGS -p ${CMAKE_CURRENT_SOURCE_DIR}/build/Xcode OUTPUT_VARIABLE NULL)
PROJECT(commandergenius)
# Generate the readme.txt file
configure_file(readme.txt.in readme.txt)
# main includes
INCLUDE_DIRECTORIES(optional-includes/generated)
INCLUDE_DIRECTORIES(src)
AUX_SOURCE_DIRECTORY(src ROOT_S)
AUX_SOURCE_DIRECTORY(src/core CORE_S)
AUX_SOURCE_DIRECTORY(src/common COMMON_S)
AUX_SOURCE_DIRECTORY(src/common/Menu MENU_S)
AUX_SOURCE_DIRECTORY(src/dialog DIALOG_S)
AUX_SOURCE_DIRECTORY(src/engine ENGINE_S)
AUX_SOURCE_DIRECTORY(src/engine/galaxy GALAXY_S)
AUX_SOURCE_DIRECTORY(src/engine/galaxy/ai GALAXY_AI_S)
AUX_SOURCE_DIRECTORY(src/engine/galaxy/ai/platform GALAXY_AI_PLATFORMS_S)
AUX_SOURCE_DIRECTORY(src/engine/galaxy/dialog GALAXY_DIALOG_S)
AUX_SOURCE_DIRECTORY(src/engine/infoscenes INFOSCENES_S)
AUX_SOURCE_DIRECTORY(src/engine/playgame PLAYGAME_S)
AUX_SOURCE_DIRECTORY(src/engine/vorticon VORTICON_S)
AUX_SOURCE_DIRECTORY(src/engine/vorticon/ai AI_S)
AUX_SOURCE_DIRECTORY(src/engine/vorticon/dialog VORT_DIALOG_S)
AUX_SOURCE_DIRECTORY(src/engine/vorticon/finale FINALE_S)
AUX_SOURCE_DIRECTORY(src/engine/vorticon/playgame VPLAYGAME_S)
AUX_SOURCE_DIRECTORY(src/fileio FILEIO_S)
AUX_SOURCE_DIRECTORY(src/fileio/compression COMPRESSION_S)
AUX_SOURCE_DIRECTORY(src/graphics GRAPHICS_S)
AUX_SOURCE_DIRECTORY(src/graphics/effects EFFECTS_S)
AUX_SOURCE_DIRECTORY(src/scale2x SCALE2X_S)
AUX_SOURCE_DIRECTORY(src/sdl SDL_S)
AUX_SOURCE_DIRECTORY(src/sdl/sound SDLSOUND_S)
AUX_SOURCE_DIRECTORY(src/sdl/music SDLMUSIC_S)
AUX_SOURCE_DIRECTORY(src/sdl/sys SDLSYS_S)
AUX_SOURCE_DIRECTORY(src/sdl/video SDLVIDEO_S)
AUX_SOURCE_DIRECTORY(src/hardware HARDWARE_S)
SET(ALL_SRCS ${COMMON_S} ${CORE_S} ${MENU_S} ${DIALOG_S} ${ENGINE_S}
${AI_S} ${GALAXY_S} ${GALAXY_AI_S} ${GALAXY_AI_PLATFORMS_S} ${GALAXY_DIALOG_S} ${INFOSCENES_S} ${PLAYGAME_S}
${VORTICON_S} ${VORT_DIALOG_S} ${FINALE_S} ${VPLAYGAME_S} ${FILEIO_S}
${COMPRESSION_S} ${GRAPHICS_S} ${EFFECTS_S} ${HARDWARE_S} ${SCALE2X_S} ${SDL_S} ${SDLSOUND_S} ${SDLMUSIC_S} ${SDLSYS_S}
${SDLVIDEO_S} ${ROOT_S})
IF(UNIX)
# Compilation under Linux
ADD_DEFINITIONS("-c -fmessage-length=0")
IF(BUILD_TYPE STREQUAL WIN32)
set(USRDIR /usr/i586-mingw32msvc)
set(CMAKE_INCLUDE_PATH ${USRDIR})
set(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
set(CMAKE_FIND_ROOT_PATH ${USRDIR})
set(CMAKE_INSTALL_USRDIR ${USRDIR})
SET(BUILD_DIR Win32)
ADD_DEFINITIONS(-DWIN32)
ADD_DEFINITIONS(-DTARGET_WIN32)
ELSEIF(BUILD_TYPE STREQUAL LINUX32)
ADD_DEFINITIONS("-DTARGET_LNX")
IF(HAVE_64_BIT)
ADD_DEFINITIONS(-D__i386__)
ADD_DEFINITIONS(-m32)
set(CMAKE_LIBRARY_PATH ${USRDIR}/lib32)
ELSE(HAVE_64_BIT)
ENDIF(HAVE_64_BIT)
SET(BUILD_DIR Linux32)
ELSEIF(BUILD_TYPE STREQUAL LINUX64)
ADD_DEFINITIONS("-DTARGET_LNX")
SET(BUILD_DIR Linux64)
ELSE(BUILD_TYPE STREQUAL WIN32)
ENDIF(BUILD_TYPE STREQUAL WIN32)
SET(OPTIMIZE_COMPILER_FLAG -O3)
ENDIF(UNIX)
# Extra Flags for the compilation
IF (OGG)
INCLUDE_DIRECTORIES(${CMAKE_INCLUDE_PATH}/include/vorbis)
ADD_DEFINITIONS(-DOGG)
ENDIF (OGG)
IF (TREMOR)
IF(BUILD_TYPE STREQUAL DINGOO)
INCLUDE_DIRECTORIES(${USRDIR}/include/tremor)
ELSE (BUILD_TYPE STREQUAL DINGOO)
INCLUDE_DIRECTORIES(/usr/include/tremor)
ENDIF (BUILD_TYPE STREQUAL DINGOO)
ADD_DEFINITIONS(-DTREMOR)
ENDIF (TREMOR)
IF (SDL)
IF(BUILD_TYPE STREQUAL WIN32)
INCLUDE_DIRECTORIES(/usr/i586-mingw32msvc/include/SDL)
ELSE(BUILD_TYPE STREQUAL WIN32)
INCLUDE_DIRECTORIES(${USRDIR}/include/SDL)
ENDIF(BUILD_TYPE STREQUAL WIN32)
ENDIF (SDL)
IF (OPENGL)
ADD_DEFINITIONS(-DGL)
ADD_DEFINITIONS(-DUSE_OPENGL)
ENDIF (OPENGL)
IF(DEBUG)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(DEBUG)
# Executable definition
ADD_EXECUTABLE(commandergenius ${ALL_SRCS})
# Linking part under Linux
IF(SDL)
IF(BUILD_TYPE STREQUAL WIN32)
TARGET_LINK_LIBRARIES(commandergenius mingw32)
TARGET_LINK_LIBRARIES(commandergenius SDLmain)
TARGET_LINK_LIBRARIES(commandergenius SDL)
TARGET_LINK_LIBRARIES(commandergenius glu32)
TARGET_LINK_LIBRARIES(commandergenius opengl32)
ELSEIF(BUILD_TYPE STREQUAL LINUX32)
IF(HAVE_64_BIT)
TARGET_LINK_LIBRARIES(commandergenius SDL-1.2)
ELSE(HAVE_64_BIT)
TARGET_LINK_LIBRARIES(commandergenius SDL)
ENDIF(HAVE_64_BIT)
ELSE(BUILD_TYPE STREQUAL LINUX32)
TARGET_LINK_LIBRARIES(commandergenius SDL)
ENDIF(BUILD_TYPE STREQUAL WIN32)
ENDIF(SDL)
IF(BUILD_TYPE STREQUAL LINUX32)
IF(HAVE_64_BIT)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES LINK_FLAGS -L/usr/lib32)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES LINK_FLAGS -m32)
ENDIF(HAVE_64_BIT)
ENDIF(BUILD_TYPE STREQUAL LINUX32)
IF(BUILD_TYPE STREQUAL WIN32)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES LINK_FLAGS -L/usr/i586-mingw32msvc/lib)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES LINK_FLAGS -mwindows)
ENDIF(BUILD_TYPE STREQUAL WIN32)
IF(OPENGL)
IF(BUILD_TYPE STREQUAL WIN32)
TARGET_LINK_LIBRARIES(commandergenius glu32)
TARGET_LINK_LIBRARIES(commandergenius opengl32)
ELSE(BUILD_TYPE STREQUAL WIN32)
TARGET_LINK_LIBRARIES(commandergenius GL)
ENDIF(BUILD_TYPE STREQUAL WIN32)
ENDIF(OPENGL)
IF(OGG)
TARGET_LINK_LIBRARIES(commandergenius vorbisfile vorbis)
IF(BUILD_TYPE STREQUAL WIN32)
TARGET_LINK_LIBRARIES(commandergenius ogg)
ENDIF(BUILD_TYPE STREQUAL WIN32)
ENDIF(OGG)
IF(TREMOR)
TARGET_LINK_LIBRARIES(commandergenius vorbisidec)
ENDIF(TREMOR)
# Set binary(executable) file name. In Windows this filename needs the exe extension
# The Windows Version has an icon in the executable
IF(BUILD_TYPE STREQUAL WIN32)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES OUTPUT_NAME "build/${BUILD_DIR}/CGenius.exe")
ADD_CUSTOM_COMMAND(TARGET commandergenius PRE_LINK COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/src/CGLogo.rc ${CMAKE_CURRENT_SOURCE_DIR}/CGLogo.rc )
ADD_CUSTOM_COMMAND(TARGET commandergenius PRE_LINK COMMAND icotool -c -o ${CMAKE_CURRENT_SOURCE_DIR}/CGLogo.ico ${CMAKE_CURRENT_SOURCE_DIR}/vfsroot/cglogo512.png )
ADD_CUSTOM_COMMAND(TARGET commandergenius PRE_LINK COMMAND i586-mingw32msvc-windres ${CMAKE_CURRENT_SOURCE_DIR}/CGLogo.rc ${CMAKE_CURRENT_SOURCE_DIR}/CGLogo.o)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES LINK_FLAGS "${CMAKE_CURRENT_SOURCE_DIR}/CGLogo.o")
MESSAGE( "Will build with the CG-Icon for Windows." )
ELSE(BUILD_TYPE STREQUAL WIN32)
SET_TARGET_PROPERTIES(commandergenius PROPERTIES OUTPUT_NAME "build/${BUILD_DIR}/CGenius")
ENDIF(BUILD_TYPE STREQUAL WIN32)
IF(NOT DEFINED BUILD_TYPE)
SET(BUILD_TYPE LINUX32)
MESSAGE( "WARNING: You did not specify the build type with the -DBUILD_TYPE= Parameter. LINUX32 has been choosen" )
MESSAGE( "Available Builds are: WIN32, LINUX32, LINUX64, GP2X. WIZ, CAANOO, DINGOO, NANONOTE For 64-bit Linux use 'cmake . -DBUILD_TYPE=LINUX64'" )
ENDIF(NOT DEFINED BUILD_TYPE)
MESSAGE( "BUILD_TYPE = ${BUILD_TYPE}" )
MESSAGE( "BUILD_DIR = ${BUILD_DIR}" )
MESSAGE( "DEBUG = ${DEBUG}" )
MESSAGE( "CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}" )
MESSAGE( "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}" )
MESSAGE( "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}" )
MESSAGE( "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}" )
MESSAGE( "Compile it with OpenGL : OPENGL = ${OPENGL}" )
MESSAGE( "We use OGG Vorbis : OGG = ${OGG}" )
MESSAGE( "We use Tremor : TREMOR = ${TREMOR}" )
MESSAGE( "You are on 64-bit System : HAVE_64_BIT = ${HAVE_64_BIT}" )
MESSAGE( "USRDIR = ${USRDIR}" )
MESSAGE( "Commander Genius Version : CG_VERSION = ${CG_VERSION}" )