[b5059c]: CMakeLists.txt Maximize Restore History

Download this file

CMakeLists.txt    311 lines (277 with data), 10.1 kB

  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
cmake_minimum_required(VERSION 2.4.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0005 NEW)
endif(COMMAND cmake_policy)
# If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition
# and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE
# to Release prior to calling PROJECT()
IF(DEFINED CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
ELSE(DEFINED CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
ENDIF(DEFINED CMAKE_BUILD_TYPE)
PROJECT(gemrb)
# try to extract the version from the source
execute_process(
COMMAND sed -n "s/\#define VERSION_GEMRB .\\([^\"]*\\).$/\\1/p" ${CMAKE_CURRENT_SOURCE_DIR}/gemrb/includes/globals.h
OUTPUT_VARIABLE GEMRB_VERSION
RESULT_VARIABLE RC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(${RC} GREATER 0) # lookup failed
set(GEMRB_VERSION "unknown")
endif(${RC} GREATER 0)
message("Detected version: ${GEMRB_VERSION}")
IF(PREFIX)
SET(PREFIX CACHE PATH "Abbreviation for CMAKE_INSTALL_PREFIX.")
SET(CMAKE_INSTALL_PREFIX ${PREFIX})
ENDIF(PREFIX)
if (NOT LAYOUT)
if (WIN32)
set(LAYOUT "home")
else (WIN32)
set(LAYOUT "fhs")
endif (WIN32)
endif (NOT LAYOUT)
SET(LAYOUT "${LAYOUT}" CACHE STRING "Directory layout.")
if (${LAYOUT} MATCHES "home")
IF( NOT PLUGIN_DIR )
SET( PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/plugins )
ENDIF( NOT PLUGIN_DIR )
IF( NOT DATA_DIR )
SET( DATA_DIR ${CMAKE_INSTALL_PREFIX} )
ENDIF( NOT DATA_DIR )
IF( NOT MAN_DIR )
SET( MAN_DIR ${CMAKE_INSTALL_PREFIX}/man/man6 )
ENDIF( NOT MAN_DIR )
IF( NOT BIN_DIR )
SET( BIN_DIR ${CMAKE_INSTALL_PREFIX} )
ENDIF( NOT BIN_DIR )
IF( NOT SYSCONF_DIR )
SET( SYSCONF_DIR ${CMAKE_INSTALL_PREFIX} )
ENDIF( NOT SYSCONF_DIR )
IF( NOT LIB_DIR )
SET( LIB_DIR ${CMAKE_INSTALL_PREFIX} )
ENDIF( NOT LIB_DIR )
IF( NOT DOC_DIR )
SET( DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc )
ENDIF( NOT DOC_DIR )
IF( NOT ICON_DIR )
SET( ICON_DIR ${CMAKE_INSTALL_PREFIX} )
ENDIF( NOT ICON_DIR )
IF( NOT MENU_DIR )
SET( MENU_DIR ${CMAKE_INSTALL_PREFIX} )
ENDIF( NOT MENU_DIR )
elseif (${LAYOUT} MATCHES "fhs")
IF( NOT LIB_DIR )
SET( LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/gemrb )
ENDIF( NOT LIB_DIR )
IF( NOT PLUGIN_DIR )
SET( PLUGIN_DIR ${LIB_DIR}/plugins )
ENDIF( NOT PLUGIN_DIR )
IF( NOT DATA_DIR )
SET( DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/gemrb )
ENDIF( NOT DATA_DIR )
IF( NOT MAN_DIR )
SET( MAN_DIR ${CMAKE_INSTALL_PREFIX}/share/man/man6 )
ENDIF( NOT MAN_DIR )
IF( NOT BIN_DIR )
SET( BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin )
ENDIF( NOT BIN_DIR )
IF( NOT SYSCONF_DIR )
if ( ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" )
SET( SYSCONF_DIR /etc/gemrb )
else ()
SET( SYSCONF_DIR ${CMAKE_INSTALL_PREFIX}/etc/gemrb )
endif ()
ENDIF( NOT SYSCONF_DIR )
IF( NOT DOC_DIR )
SET( DOC_DIR ${CMAKE_INSTALL_PREFIX}/share/doc/gemrb )
ENDIF( NOT DOC_DIR )
IF( NOT ICON_DIR )
SET( ICON_DIR ${CMAKE_INSTALL_PREFIX}/share/pixmaps )
ENDIF( NOT ICON_DIR )
IF( NOT MENU_DIR )
SET( MENU_DIR ${CMAKE_INSTALL_PREFIX}/share/applications )
ENDIF( NOT MENU_DIR )
else (${LAYOUT} MATCHES "opt")
IF( NOT LIB_DIR )
SET( LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib )
ENDIF( NOT LIB_DIR )
IF( NOT PLUGIN_DIR )
SET( PLUGIN_DIR ${LIB_DIR}/plugins )
ENDIF( NOT PLUGIN_DIR )
IF( NOT DATA_DIR )
SET( DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/ )
ENDIF( NOT DATA_DIR )
IF( NOT MAN_DIR )
SET( MAN_DIR ${CMAKE_INSTALL_PREFIX}/man/man6 )
ENDIF( NOT MAN_DIR )
IF( NOT BIN_DIR )
SET( BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin )
ENDIF( NOT BIN_DIR )
IF( NOT SYSCONF_DIR )
SET( SYSCONF_DIR ${CMAKE_INSTALL_PREFIX}/etc )
ENDIF( NOT SYSCONF_DIR )
IF( NOT DOC_DIR )
SET( DOC_DIR ${CMAKE_INSTALL_PREFIX}/share/doc/gemrb )
ENDIF( NOT DOC_DIR )
IF( NOT ICON_DIR )
SET( ICON_DIR ${CMAKE_INSTALL_PREFIX}/share/pixmaps )
ENDIF( NOT ICON_DIR )
IF( NOT MENU_DIR )
SET( MENU_DIR ${CMAKE_INSTALL_PREFIX}/share/applications )
ENDIF( NOT MENU_DIR )
endif (${LAYOUT} MATCHES "home")
IF(CMAKE_COMPILER_IS_GNUCXX)
if ( NOT DISABLE_WERROR )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif ( NOT DISABLE_WERROR )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -Wpointer-arith -Wcast-align")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-format-y2k -Wno-long-long -fno-strict-aliasing")
# only export symbols explicitly marked to be exported.
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" VISIBILITY_HIDDEN)
IF (VISIBILITY_HIDDEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
ENDIF (VISIBILITY_HIDDEN)
if (WIN32)
# GCC 4.5.0+ has shared libstdc++ without dllimport
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-auto-import")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--enable-auto-import")
endif (WIN32)
# Ensure all plugin symbols exist.
if (NOT APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
endif (NOT APPLE)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
MESSAGE(STATUS "Looking for Python libraries")
INCLUDE(FindPythonLibs)
IF(PYTHON_LIBRARY)
MESSAGE(STATUS "Python Libraries Found")
ELSE(PYTHON_LIBRARY)
MESSAGE(FATAL_ERROR "Unable to find Python development libraries. Please get it from www.python.org")
ENDIF(PYTHON_LIBRARY)
MESSAGE(STATUS "Looking for openAL libraries")
INCLUDE(FindOpenAL)
IF(OPENAL_FOUND)
MESSAGE(STATUS "openal found")
ELSE(OPENAL_FOUND)
MESSAGE(ERROR "unable to find openal. please set OPENALDIR environment variable or get it from www.openal.org")
ENDIF(OPENAL_FOUND)
MESSAGE(STATUS "Looking for SDL")
INCLUDE(FindSDL)
IF(SDL_FOUND)
MESSAGE(STATUS "SDL found")
ELSE(SDL_FOUND)
MESSAGE(FATAL_ERROR "unable to find SDL. please get it from www.libsdl.org")
ENDIF(SDL_FOUND)
MESSAGE( STATUS "Looking for Zlib" )
#SET(ZLIB_FIND_REQUIRED TRUE)
INCLUDE(FindZLIB)
MESSAGE( STATUS "Looking for libPNG" )
INCLUDE(FindPNG)
IF(PNG_FOUND)
MESSAGE( STATUS "libPNG found" )
ELSE(PNG_FOUND)
MESSAGE( STATUS "WARNING : GemRB will be built without any PNG support. Get it from www.libpng.org" )
ENDIF(PNG_FOUND)
IF(UNIX)
MESSAGE(STATUS "Looking for dl library")
FIND_LIBRARY(DLD_LIBRARY_PATH dl dld)
IF(DLD_LIBRARY_PATH)
MESSAGE(STATUS "dl library found")
ELSE(DLD_LIBRARY_PATH)
MESSAGE(FATAL_ERROR "dl library not found")
ENDIF(DLD_LIBRARY_PATH)
ENDIF(UNIX)
MESSAGE(STATUS "Looking for Ogg Vorbis support")
FIND_LIBRARY(VORBIS_LIBRARY vorbisfile)
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} gemrb/includes gemrb/core)
#Platform checks
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("int" SIZEOF_INT)
CHECK_TYPE_SIZE("long int" SIZEOF_LONG_INT)
INCLUDE (CheckFunctionExists)
CHECK_FUNCTION_EXISTS("snprintf" HAVE_SNPRINTF)
CHECK_FUNCTION_EXISTS("strndup" HAVE_STRNDUP)
#Unneeded on windows
IF(NOT WIN32)
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("typedef void *(* voidvoid)(void);
void *object = 0;
voidvoid function;
function = (voidvoid) object;
" PERMITS_OBJECT_TO_FUNCTION_CAST)
IF( NOT PERMITS_OBJECT_TO_FUNCTION_CAST )
SET(HAVE_FORBIDDEN_OBJECT_TO_FUNCTION_CAST 1)
ENDIF( NOT PERMITS_OBJECT_TO_FUNCTION_CAST )
ENDIF(NOT WIN32)
IF(VORBIS_LIBRARY)
SET(HAS_VORBIS_SUPPORT 1)
ELSE(VORBIS_LIBRARY)
SET(VORBIS_LIBRARY "")
ENDIF(VORBIS_LIBRARY)
IF(APPLE)
FIND_LIBRARY(SDL_MAIN_LIBRARY_PATH SDLmain)
FIND_LIBRARY(COCOA_LIBRARY_PATH Cocoa)
ENDIF(APPLE)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
#Plugin addition macro
MACRO(ADD_GEMRB_PLUGIN plugin_name)
ADD_LIBRARY(${plugin_name} MODULE ${ARGN})
SET_TARGET_PROPERTIES(${plugin_name} PROPERTIES PREFIX ""
INSTALL_RPATH ${LIB_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/gemrb/plugins)
TARGET_LINK_LIBRARIES(${plugin_name} gemrb_core)
INSTALL(TARGETS ${plugin_name} DESTINATION ${PLUGIN_DIR})
ENDMACRO(ADD_GEMRB_PLUGIN)
#gemrb overrides macro
MACRO(ADD_GEMRB_OVERRIDE game_name)
FILE( GLOB FILES_TO_INSTALL *.2da *.bmp *.ini *.chu *.ids *.bcs *.vvc *.mos *.spl *.wav *.pro)
INSTALL( FILES ${FILES_TO_INSTALL} DESTINATION ${DATA_DIR}/override/${game_name} )
ENDMACRO(ADD_GEMRB_OVERRIDE )
ADD_SUBDIRECTORY( gemrb )
INSTALL( FILES gemrb.6 DESTINATION ${MAN_DIR} )
INSTALL( FILES artwork/gemrb-logo.png DESTINATION ${ICON_DIR} )
INSTALL( FILES gemrb.desktop DESTINATION ${MENU_DIR} )
INSTALL( FILES README INSTALL COPYING NEWS AUTHORS DESTINATION ${DOC_DIR} )
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
# copy the variable, since the file uses @VERSION@
set(VERSION ${GEMRB_VERSION})
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/gemrb.spec.in"
"${CMAKE_CURRENT_BINARY_DIR}/gemrb.spec"
IMMEDIATE @ONLY
)
ADD_CUSTOM_TARGET( uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
# make dist for a gzipped tarball of current HEAD
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${GEMRB_VERSION})
add_custom_target( dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| gzip --best > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
message(STATUS "")
message(STATUS "These are the configured paths:")
message(STATUS " PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS " LIB_DIR: ${LIB_DIR}")
message(STATUS " PLUGIN_DIR: ${PLUGIN_DIR}")
message(STATUS " BIN_DIR: ${BIN_DIR}")
message(STATUS " DATA_DIR: ${DATA_DIR}")
message(STATUS " MAN_DIR: ${MAN_DIR}")
message(STATUS " SYSCONF_DIR: ${SYSCONF_DIR}")
message(STATUS " DOC_DIR: ${DOC_DIR}")
message(STATUS " ICON_DIR: ${ICON_DIR}")
message(STATUS " MENU_DIR: ${MENU_DIR}")
message(STATUS "")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "")