author | Bryan Dunsmore <dunsmoreb@gmail.com> |
Sat, 01 Dec 2012 15:52:36 -0600 | |
branch | webgl |
changeset 8113 | 0ad9c42dca7c |
parent 8096 | 453917e94e55 |
child 8330 | aaefa587e277 |
permissions | -rw-r--r-- |
7768 | 1 |
# PhysicsFS; a portable, flexible file i/o abstraction. |
2 |
# Copyright (C) 2007 Ryan C. Gordon. |
|
3 |
# |
|
4 |
# Please see the file LICENSE.txt in the source's root directory. |
|
5 |
||
8087
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
6 |
#lines overridden by Hedgewars configuration |
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
7 |
#CMAKE_MINIMUM_REQUIRED(VERSION 2.4) |
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
8 |
#PROJECT(PhysicsFS) |
7768 | 9 |
SET(PHYSFS_VERSION 2.1.0) |
10 |
||
11 |
# Increment this if/when we break backwards compatibility. |
|
12 |
SET(PHYSFS_SOVERSION 1) |
|
13 |
||
14 |
# I hate that they define "WIN32" ... we're about to move to Win64...I hope! |
|
15 |
IF(WIN32 AND NOT WINDOWS) |
|
16 |
SET(WINDOWS TRUE) |
|
17 |
ENDIF(WIN32 AND NOT WINDOWS) |
|
18 |
||
19 |
# Bleh, let's do it for "APPLE" too. |
|
20 |
IF(APPLE AND NOT MACOSX) |
|
21 |
SET(MACOSX TRUE) |
|
22 |
ENDIF(APPLE AND NOT MACOSX) |
|
23 |
||
24 |
# For now, Haiku and BeOS are the same, as far as the build system cares. |
|
25 |
IF(HAIKU AND NOT BEOS) |
|
26 |
SET(BEOS TRUE) |
|
27 |
ENDIF(HAIKU AND NOT BEOS) |
|
28 |
||
29 |
IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
|
30 |
SET(SOLARIS TRUE) |
|
31 |
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
|
32 |
||
33 |
INCLUDE(CheckIncludeFile) |
|
34 |
INCLUDE(CheckLibraryExists) |
|
35 |
INCLUDE(CheckCSourceCompiles) |
|
36 |
||
8096 | 37 |
find_package(SDL REQUIRED) |
8073 | 38 |
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) |
39 |
include_directories(${SDL_INCLUDE_DIR}) #hw |
|
40 |
include_directories(${LUA_INCLUDE_DIR}) #hw |
|
7768 | 41 |
|
42 |
IF(MACOSX) |
|
43 |
# Fallback to older OS X on PowerPC to support wider range of systems... |
|
44 |
IF(CMAKE_OSX_ARCHITECTURES MATCHES ppc) |
|
45 |
ADD_DEFINITIONS(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020) |
|
46 |
SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} " -mmacosx-version-min=10.2") |
|
47 |
ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES ppc) |
|
48 |
||
49 |
# Need these everywhere... |
|
50 |
ADD_DEFINITIONS(-fno-common) |
|
51 |
SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework Carbon -framework IOKit") |
|
52 |
ENDIF(MACOSX) |
|
53 |
||
54 |
# Add some gcc-specific command lines. |
|
55 |
IF(CMAKE_COMPILER_IS_GNUCC) |
|
56 |
# Always build with debug symbols...you can strip it later. |
|
57 |
ADD_DEFINITIONS(-g -pipe -Werror -fsigned-char) |
|
58 |
||
59 |
# Stupid BeOS generates warnings in the system headers. |
|
60 |
IF(NOT BEOS) |
|
61 |
ADD_DEFINITIONS(-Wall) |
|
62 |
ENDIF(NOT BEOS) |
|
63 |
||
64 |
CHECK_C_SOURCE_COMPILES(" |
|
65 |
#if ((defined(__GNUC__)) && (__GNUC__ >= 4)) |
|
66 |
int main(int argc, char **argv) { int is_gcc4 = 1; return 0; } |
|
67 |
#else |
|
68 |
#error This is not gcc4. |
|
69 |
#endif |
|
70 |
" PHYSFS_IS_GCC4) |
|
71 |
||
72 |
IF(PHYSFS_IS_GCC4) |
|
73 |
# Not supported on several operating systems at this time. |
|
74 |
IF(NOT SOLARIS AND NOT WINDOWS) |
|
75 |
ADD_DEFINITIONS(-fvisibility=hidden) |
|
76 |
ENDIF(NOT SOLARIS AND NOT WINDOWS) |
|
77 |
ENDIF(PHYSFS_IS_GCC4) |
|
78 |
||
79 |
# Don't use -rpath. |
|
80 |
SET(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) |
|
81 |
ENDIF(CMAKE_COMPILER_IS_GNUCC) |
|
82 |
||
83 |
IF(CMAKE_C_COMPILER_ID STREQUAL "SunPro") |
|
84 |
ADD_DEFINITIONS(-erroff=E_EMPTY_TRANSLATION_UNIT) |
|
85 |
ADD_DEFINITIONS(-xldscope=hidden) |
|
86 |
ENDIF(CMAKE_C_COMPILER_ID STREQUAL "SunPro") |
|
87 |
||
88 |
IF(MSVC) |
|
89 |
# VS.NET 8.0 got really really anal about strcpy, etc, which even if we |
|
90 |
# cleaned up our code, zlib, etc still use...so disable the warning. |
|
91 |
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1) |
|
92 |
ENDIF(MSVC) |
|
93 |
||
94 |
# Basic chunks of source code ... |
|
95 |
||
96 |
SET(LZMA_SRCS |
|
97 |
src/lzma/C/7zCrc.c |
|
98 |
src/lzma/C/Archive/7z/7zBuffer.c |
|
99 |
src/lzma/C/Archive/7z/7zDecode.c |
|
100 |
src/lzma/C/Archive/7z/7zExtract.c |
|
101 |
src/lzma/C/Archive/7z/7zHeader.c |
|
102 |
src/lzma/C/Archive/7z/7zIn.c |
|
103 |
src/lzma/C/Archive/7z/7zItem.c |
|
104 |
src/lzma/C/Archive/7z/7zMethodID.c |
|
105 |
src/lzma/C/Compress/Branch/BranchX86.c |
|
106 |
src/lzma/C/Compress/Branch/BranchX86_2.c |
|
107 |
src/lzma/C/Compress/Lzma/LzmaDecode.c |
|
108 |
) |
|
109 |
||
110 |
IF(BEOS) |
|
111 |
# We add this explicitly, since we don't want CMake to think this |
|
112 |
# is a C++ project unless we're on BeOS. |
|
113 |
SET(PHYSFS_BEOS_SRCS src/platform_beos.cpp) |
|
114 |
FIND_LIBRARY(BE_LIBRARY be) |
|
115 |
FIND_LIBRARY(ROOT_LIBRARY root) |
|
116 |
SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY}) |
|
117 |
ENDIF(BEOS) |
|
118 |
||
119 |
# Almost everything is "compiled" here, but things that don't apply to the |
|
120 |
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into |
|
121 |
# another project or bring up a new build system: just compile all the source |
|
122 |
# code and #define the things you want. |
|
123 |
SET(PHYSFS_SRCS |
|
124 |
src/physfs.c |
|
125 |
src/physfs_byteorder.c |
|
126 |
src/physfs_unicode.c |
|
127 |
src/platform_posix.c |
|
128 |
src/platform_unix.c |
|
129 |
src/platform_macosx.c |
|
130 |
src/platform_windows.c |
|
131 |
src/archiver_dir.c |
|
132 |
src/archiver_unpacked.c |
|
133 |
src/archiver_grp.c |
|
134 |
src/archiver_hog.c |
|
135 |
src/archiver_lzma.c |
|
136 |
src/archiver_mvl.c |
|
137 |
src/archiver_qpak.c |
|
138 |
src/archiver_wad.c |
|
139 |
src/archiver_zip.c |
|
140 |
src/archiver_iso9660.c |
|
8073 | 141 |
#custom files from Hedgewars |
142 |
extras/physfsrwops.c |
|
143 |
extras/physfslualoader.c |
|
144 |
extras/hwpacksmounter.c |
|
7768 | 145 |
${PHYSFS_BEOS_SRCS} |
146 |
) |
|
147 |
||
148 |
||
149 |
# platform layers ... |
|
150 |
||
151 |
IF(UNIX) |
|
152 |
IF(BEOS) |
|
153 |
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
154 |
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
155 |
SET(HAVE_PTHREAD_H TRUE) |
|
156 |
ELSE(BEOS) |
|
157 |
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) |
|
158 |
IF(HAVE_UCRED_H) |
|
159 |
ADD_DEFINITIONS(-DPHYSFS_HAVE_SYS_UCRED_H=1) |
|
160 |
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
161 |
ENDIF(HAVE_UCRED_H) |
|
162 |
||
163 |
CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H) |
|
164 |
IF(HAVE_MNTENT_H) |
|
165 |
ADD_DEFINITIONS(-DPHYSFS_HAVE_MNTENT_H=1) |
|
166 |
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
167 |
ENDIF(HAVE_MNTENT_H) |
|
168 |
||
169 |
# !!! FIXME: Solaris fails this, because mnttab.h implicitly |
|
170 |
# !!! FIXME: depends on other system headers. :( |
|
171 |
#CHECK_INCLUDE_FILE(sys/mnttab.h HAVE_SYS_MNTTAB_H) |
|
172 |
CHECK_C_SOURCE_COMPILES(" |
|
173 |
#include <stdio.h> |
|
174 |
#include <sys/mnttab.h> |
|
175 |
int main(int argc, char **argv) { return 0; } |
|
176 |
" HAVE_SYS_MNTTAB_H) |
|
177 |
||
178 |
IF(HAVE_SYS_MNTTAB_H) |
|
179 |
ADD_DEFINITIONS(-DPHYSFS_HAVE_SYS_MNTTAB_H=1) |
|
180 |
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
181 |
ENDIF(HAVE_SYS_MNTTAB_H) |
|
182 |
||
183 |
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) |
|
184 |
IF(HAVE_PTHREAD_H) |
|
185 |
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
186 |
ENDIF(HAVE_PTHREAD_H) |
|
187 |
ENDIF(BEOS) |
|
188 |
ENDIF(UNIX) |
|
189 |
||
190 |
IF(WINDOWS) |
|
191 |
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
192 |
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
193 |
ENDIF(WINDOWS) |
|
194 |
||
195 |
IF(NOT PHYSFS_HAVE_CDROM_SUPPORT) |
|
196 |
ADD_DEFINITIONS(-DPHYSFS_NO_CDROM_SUPPORT=1) |
|
197 |
MESSAGE(WARNING " ***") |
|
198 |
MESSAGE(WARNING " *** There is no CD-ROM support in this build!") |
|
199 |
MESSAGE(WARNING " *** PhysicsFS will just pretend there are no discs.") |
|
200 |
MESSAGE(WARNING " *** This may be fine, depending on how PhysicsFS is used,") |
|
201 |
MESSAGE(WARNING " *** but is this what you REALLY wanted?") |
|
202 |
MESSAGE(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)") |
|
203 |
MESSAGE(WARNING " ***") |
|
204 |
ENDIF(NOT PHYSFS_HAVE_CDROM_SUPPORT) |
|
205 |
||
206 |
IF(PHYSFS_HAVE_THREAD_SUPPORT) |
|
207 |
ADD_DEFINITIONS(-D_REENTRANT -D_THREAD_SAFE) |
|
208 |
ELSE(PHYSFS_HAVE_THREAD_SUPPORT) |
|
209 |
ADD_DEFINITIONS(-DPHYSFS_NO_THREAD_SUPPORT=1) |
|
210 |
MESSAGE(WARNING " ***") |
|
211 |
MESSAGE(WARNING " *** There is no thread support in this build!") |
|
212 |
MESSAGE(WARNING " *** PhysicsFS will NOT be reentrant!") |
|
213 |
MESSAGE(WARNING " *** This may be fine, depending on how PhysicsFS is used,") |
|
214 |
MESSAGE(WARNING " *** but is this what you REALLY wanted?") |
|
215 |
MESSAGE(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)") |
|
216 |
MESSAGE(WARNING " ***") |
|
217 |
ENDIF(PHYSFS_HAVE_THREAD_SUPPORT) |
|
218 |
||
219 |
||
220 |
# Archivers ... |
|
221 |
||
222 |
OPTION(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE) |
|
223 |
IF(PHYSFS_ARCHIVE_ZIP) |
|
224 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_ZIP=1) |
|
225 |
ENDIF(PHYSFS_ARCHIVE_ZIP) |
|
226 |
||
227 |
OPTION(PHYSFS_ARCHIVE_7Z "Enable 7zip support" FALSE) |
|
228 |
IF(PHYSFS_ARCHIVE_7Z) |
|
229 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_7Z=1) |
|
230 |
# !!! FIXME: rename to 7z.c? |
|
231 |
SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS}) |
|
232 |
ENDIF(PHYSFS_ARCHIVE_7Z) |
|
233 |
||
234 |
OPTION(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE) |
|
235 |
IF(PHYSFS_ARCHIVE_GRP) |
|
236 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_GRP=1) |
|
237 |
ENDIF(PHYSFS_ARCHIVE_GRP) |
|
238 |
||
239 |
OPTION(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE) |
|
240 |
IF(PHYSFS_ARCHIVE_WAD) |
|
241 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_WAD=1) |
|
242 |
ENDIF(PHYSFS_ARCHIVE_WAD) |
|
243 |
||
244 |
OPTION(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE) |
|
245 |
IF(PHYSFS_ARCHIVE_HOG) |
|
246 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_HOG=1) |
|
247 |
ENDIF(PHYSFS_ARCHIVE_HOG) |
|
248 |
||
249 |
OPTION(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE) |
|
250 |
IF(PHYSFS_ARCHIVE_MVL) |
|
251 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_MVL=1) |
|
252 |
ENDIF(PHYSFS_ARCHIVE_MVL) |
|
253 |
||
254 |
OPTION(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE) |
|
255 |
IF(PHYSFS_ARCHIVE_QPAK) |
|
256 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_QPAK=1) |
|
257 |
ENDIF(PHYSFS_ARCHIVE_QPAK) |
|
258 |
||
259 |
OPTION(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE) |
|
260 |
IF(PHYSFS_ARCHIVE_ISO9660) |
|
261 |
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_ISO9660=1) |
|
262 |
ENDIF(PHYSFS_ARCHIVE_ISO9660) |
|
263 |
||
8087
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
264 |
#as needed by Hedgewars configuration |
8073 | 265 |
IF(WINDOWS) |
266 |
OPTION(PHYSFS_BUILD_STATIC "Build static library" FALSE) |
|
267 |
OPTION(PHYSFS_BUILD_SHARED "Build shared library" TRUE) |
|
8087
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
268 |
SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} ${SDL_LIBRARY}) |
8073 | 269 |
ELSE(WINDOWS) |
270 |
OPTION(PHYSFS_BUILD_STATIC "Build static library" TRUE) |
|
271 |
OPTION(PHYSFS_BUILD_SHARED "Build shared library" FALSE) |
|
272 |
ENDIF(WINDOWS) |
|
7768 | 273 |
|
274 |
IF(PHYSFS_BUILD_STATIC) |
|
7928 | 275 |
ADD_LIBRARY(physfs STATIC ${PHYSFS_SRCS}) |
276 |
SET_TARGET_PROPERTIES(physfs PROPERTIES OUTPUT_NAME "physfs") |
|
277 |
SET(PHYSFS_LIB_TARGET physfs) |
|
278 |
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs") |
|
7768 | 279 |
ENDIF(PHYSFS_BUILD_STATIC) |
280 |
||
8073 | 281 |
IF(PHYSFS_BUILD_SHARED) |
282 |
ADD_LIBRARY(physfs SHARED ${PHYSFS_SRCS}) |
|
283 |
SET_TARGET_PROPERTIES(physfs PROPERTIES VERSION ${PHYSFS_VERSION}) |
|
284 |
SET_TARGET_PROPERTIES(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION}) |
|
8087
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
285 |
TARGET_LINK_LIBRARIES(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS}) |
8073 | 286 |
SET(PHYSFS_LIB_TARGET physfs) |
287 |
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs") |
|
288 |
ENDIF(PHYSFS_BUILD_SHARED) |
|
7768 | 289 |
|
290 |
IF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) |
|
291 |
MESSAGE(FATAL "Both shared and static libraries are disabled!") |
|
292 |
ENDIF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) |
|
293 |
||
294 |
# CMake FAQ says I need this... |
|
295 |
IF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC) |
|
296 |
SET_TARGET_PROPERTIES(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
|
297 |
ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC) |
|
298 |
||
299 |
OPTION(PHYSFS_BUILD_TEST "Build stdio test program." FALSE) |
|
300 |
MARK_AS_ADVANCED(PHYSFS_BUILD_TEST) |
|
301 |
IF(PHYSFS_BUILD_TEST) |
|
302 |
FIND_PATH(READLINE_H readline/readline.h) |
|
303 |
FIND_PATH(HISTORY_H readline/history.h) |
|
304 |
IF(READLINE_H AND HISTORY_H) |
|
305 |
FIND_LIBRARY(CURSES_LIBRARY NAMES curses ncurses) |
|
306 |
SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY}) |
|
307 |
FIND_LIBRARY(READLINE_LIBRARY readline) |
|
308 |
IF(READLINE_LIBRARY) |
|
309 |
SET(HAVE_SYSTEM_READLINE TRUE) |
|
310 |
SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY}) |
|
311 |
INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H}) |
|
312 |
ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1) |
|
313 |
ENDIF(READLINE_LIBRARY) |
|
314 |
ENDIF(READLINE_H AND HISTORY_H) |
|
315 |
ADD_EXECUTABLE(test_physfs test/test_physfs.c) |
|
316 |
TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS}) |
|
317 |
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs") |
|
318 |
ENDIF(PHYSFS_BUILD_TEST) |
|
319 |
||
320 |
||
321 |
# Scripting language bindings... |
|
322 |
||
323 |
#CMake's SWIG support is basically useless. |
|
324 |
#FIND_PACKAGE(SWIG) |
|
325 |
||
7778 | 326 |
OPTION(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." FALSE) |
7768 | 327 |
MARK_AS_ADVANCED(PHYSFS_BUILD_SWIG) |
328 |
||
329 |
FIND_PROGRAM(SWIG swig DOC "Path to swig command line app: http://swig.org/") |
|
330 |
IF(NOT SWIG) |
|
331 |
MESSAGE(STATUS "SWIG not found. You won't be able to build scripting language bindings.") |
|
332 |
ELSE(NOT SWIG) |
|
333 |
MARK_AS_ADVANCED(SWIG) |
|
334 |
IF(DEFINED CMAKE_BUILD_TYPE) |
|
335 |
IF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")) |
|
336 |
IF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
|
337 |
SET(SWIG_OPT_CFLAGS "-small") |
|
338 |
ELSE(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
|
339 |
SET(SWIG_OPT_CFLAGS "-O") |
|
340 |
ENDIF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
|
341 |
ENDIF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")) |
|
342 |
ENDIF(DEFINED CMAKE_BUILD_TYPE) |
|
343 |
||
344 |
SET(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings") |
|
345 |
||
346 |
MACRO(CONFIGURE_SWIG_BINDING _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS) |
|
347 |
STRING(TOUPPER "${_LANG}" _UPPERLANG) |
|
348 |
STRING(TOLOWER "${_LANG}" _LOWERLANG) |
|
349 |
SET(_TARGET "physfs-${_LOWERLANG}") |
|
350 |
SET(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}") |
|
351 |
||
352 |
IF(NOT EXISTS "${_TARGETDIR}") |
|
353 |
FILE(MAKE_DIRECTORY "${_TARGETDIR}") |
|
354 |
ENDIF(NOT EXISTS "${_TARGETDIR}") |
|
355 |
||
356 |
IF(PHYSFS_BUILD_${_UPPERLANG}) |
|
357 |
ADD_CUSTOM_COMMAND( |
|
358 |
OUTPUT "${_TARGETDIR}/${_TARGET}.c" ${_EXTRAOUTPUTS} |
|
359 |
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i" |
|
360 |
COMMAND "${SWIG}" |
|
361 |
ARGS ${SWIG_OPT_CFLAGS} -${_LOWERLANG} -outdir "${_TARGETDIR}" -o "${_TARGETDIR}/${_TARGET}.c" "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i" |
|
362 |
COMMENT "Generating ${_LANG} bindings..." |
|
363 |
) |
|
364 |
||
365 |
ADD_LIBRARY(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c") |
|
366 |
TARGET_LINK_LIBRARIES(${_TARGET} ${PHYSFS_LIB_TARGET}) |
|
367 |
SET_TARGET_PROPERTIES(${_TARGET} PROPERTIES |
|
368 |
COMPILE_FLAGS "${_EXTRACFLAGS}" |
|
369 |
LINK_FLAGS "${_EXTRALDFLAGS}" |
|
370 |
LIBRARY_OUTPUT_NAME "physfs" |
|
371 |
LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}" |
|
372 |
CLEAN_DIRECT_OUTPUT 1 |
|
373 |
) |
|
374 |
INSTALL(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}") |
|
375 |
MESSAGE(STATUS "${_LANG} bindings configured!") |
|
376 |
ELSE(PHYSFS_BUILD_${_UPPERLANG}) |
|
377 |
MESSAGE(STATUS "Couldn't figure out ${_LANG} configuration. Skipping ${_LANG} bindings.") |
|
378 |
ENDIF(PHYSFS_BUILD_${_UPPERLANG}) |
|
379 |
ENDMACRO(CONFIGURE_SWIG_BINDING) |
|
380 |
||
381 |
MACRO(ADD_SCRIPT_BINDING_OPTION _VAR _LANG _DEFVAL) |
|
382 |
SET(BUILDSWIGVAL ${_DEFVAL}) |
|
383 |
IF(NOT PHYSFS_BUILD_SWIG) |
|
384 |
SET(BUILDSWIGVAL FALSE) |
|
385 |
ENDIF(NOT PHYSFS_BUILD_SWIG) |
|
386 |
OPTION(${_VAR} "Build ${_LANG} bindings." ${BUILDSWIGVAL}) |
|
387 |
MARK_AS_ADVANCED(${_VAR}) |
|
388 |
ENDMACRO(ADD_SCRIPT_BINDING_OPTION) |
|
389 |
||
390 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_PERL "Perl" TRUE) |
|
391 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_RUBY "Ruby" TRUE) |
|
392 |
ENDIF(NOT SWIG) |
|
393 |
||
394 |
IF(PHYSFS_BUILD_PERL) |
|
395 |
MESSAGE(STATUS "Configuring Perl bindings...") |
|
396 |
FIND_PROGRAM(PERL perl DOC "Path to perl command line app: http://perl.org/") |
|
397 |
IF(NOT PERL) |
|
398 |
MESSAGE(STATUS "Perl not found. You won't be able to build perl bindings.") |
|
399 |
SET(PHYSFS_BUILD_PERL FALSE) |
|
400 |
ENDIF(NOT PERL) |
|
401 |
MARK_AS_ADVANCED(PERL) |
|
402 |
||
403 |
MACRO(GET_PERL_CONFIG _KEY _VALUE) |
|
404 |
IF(PHYSFS_BUILD_PERL) |
|
405 |
MESSAGE(STATUS "Figuring out perl config value '${_KEY}' ...") |
|
406 |
EXECUTE_PROCESS( |
|
407 |
COMMAND ${PERL} -w -e "use Config; print \$Config{${_KEY}};" |
|
408 |
RESULT_VARIABLE GET_PERL_CONFIG_RC |
|
409 |
OUTPUT_VARIABLE ${_VALUE} |
|
410 |
) |
|
411 |
IF(NOT GET_PERL_CONFIG_RC EQUAL 0) |
|
412 |
MESSAGE(STATUS "Perl executable ('${PERL}') reported failure: ${GET_PERL_CONFIG_RC}") |
|
413 |
SET(PHYSFS_BUILD_PERL FALSE) |
|
414 |
ENDIF(NOT GET_PERL_CONFIG_RC EQUAL 0) |
|
415 |
IF(NOT ${_VALUE}) |
|
416 |
MESSAGE(STATUS "Perl executable ('${PERL}') didn't have a value for '${_KEY}'") |
|
417 |
SET(PHYSFS_BUILD_PERL FALSE) |
|
418 |
ENDIF(NOT ${_VALUE}) |
|
419 |
||
420 |
IF(PHYSFS_BUILD_PERL) |
|
421 |
MESSAGE(STATUS "Perl says: '${${_VALUE}}'.") |
|
422 |
ENDIF(PHYSFS_BUILD_PERL) |
|
423 |
ENDIF(PHYSFS_BUILD_PERL) |
|
424 |
ENDMACRO(GET_PERL_CONFIG) |
|
425 |
||
426 |
# !!! FIXME: installsitearch might be the wrong location. |
|
427 |
GET_PERL_CONFIG("archlibexp" PERL_INCLUDE_PATH) |
|
428 |
GET_PERL_CONFIG("ccflags" PERL_CCFLAGS) |
|
429 |
GET_PERL_CONFIG("ldflags" PERL_LDFLAGS) |
|
430 |
GET_PERL_CONFIG("installsitearch" PERL_INSTALL_PATH) |
|
431 |
||
432 |
# !!! FIXME: this test for Mac OS X is wrong. |
|
433 |
IF(MACOSX) |
|
434 |
GET_PERL_CONFIG("libperl" PERL_LIBPERL) |
|
435 |
SET(TMPLIBPERL "${PERL_LIBPERL}") |
|
436 |
STRING(REGEX REPLACE "^lib" "" TMPLIBPERL "${TMPLIBPERL}") |
|
437 |
STRING(REGEX REPLACE "\\.so$" "" TMPLIBPERL "${TMPLIBPERL}") |
|
438 |
STRING(REGEX REPLACE "\\.dylib$" "" TMPLIBPERL "${TMPLIBPERL}") |
|
439 |
STRING(REGEX REPLACE "\\.dll$" "" TMPLIBPERL "${TMPLIBPERL}") |
|
440 |
IF(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}") |
|
441 |
MESSAGE(STATUS "Stripped '${PERL_LIBPERL}' down to '${TMPLIBPERL}'.") |
|
442 |
SET(PERL_LIBPERL "${TMPLIBPERL}") |
|
443 |
ENDIF(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}") |
|
444 |
SET(PERL_LIBPERL "-l${PERL_LIBPERL}") |
|
445 |
ENDIF(MACOSX) |
|
446 |
||
447 |
CONFIGURE_SWIG_BINDING(Perl "${PERL_INSTALL_PATH}" "${SWIG_OUTPUT_DIR}/perl/physfs.pm" "\"-I${PERL_INCLUDE_PATH}/CORE\" ${PERL_CCFLAGS} -w" "\"-L${PERL_INCLUDE_PATH}/CORE\" ${PERL_LIBPERL} ${PERL_LDFLAGS}") |
|
448 |
INSTALL(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}") |
|
449 |
INSTALL( |
|
450 |
FILES test/test_physfs.pl |
|
451 |
DESTINATION bin |
|
452 |
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE |
|
453 |
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
|
454 |
) |
|
455 |
ENDIF(PHYSFS_BUILD_PERL) |
|
456 |
||
457 |
# !!! FIXME: lots of cut-and-paste from perl bindings. |
|
458 |
IF(PHYSFS_BUILD_RUBY) |
|
459 |
MESSAGE(STATUS "Configuring Ruby bindings...") |
|
460 |
FIND_PROGRAM(RUBY ruby DOC "Path to ruby command line app: http://ruby-lang.org/") |
|
461 |
IF(NOT RUBY) |
|
462 |
MESSAGE(STATUS "Ruby not found. You won't be able to build ruby bindings.") |
|
463 |
SET(PHYSFS_BUILD_RUBY FALSE) |
|
464 |
ENDIF(NOT RUBY) |
|
465 |
MARK_AS_ADVANCED(RUBY) |
|
466 |
||
467 |
MACRO(GET_RUBY_CONFIG _KEY _VALUE) |
|
468 |
IF(PHYSFS_BUILD_RUBY) |
|
469 |
MESSAGE(STATUS "Figuring out ruby config value '${_KEY}' ...") |
|
470 |
EXECUTE_PROCESS( |
|
471 |
COMMAND ${RUBY} -e "require 'rbconfig'; puts RbConfig::CONFIG['${_KEY}'];" |
|
472 |
RESULT_VARIABLE GET_RUBY_CONFIG_RC |
|
473 |
OUTPUT_VARIABLE ${_VALUE} |
|
474 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
475 |
) |
|
476 |
IF(NOT GET_RUBY_CONFIG_RC EQUAL 0) |
|
477 |
MESSAGE(STATUS "Ruby executable ('${RUBY}') reported failure: ${GET_RUBY_CONFIG_RC}") |
|
478 |
SET(PHYSFS_BUILD_RUBY FALSE) |
|
479 |
ENDIF(NOT GET_RUBY_CONFIG_RC EQUAL 0) |
|
480 |
IF(NOT ${_VALUE}) |
|
481 |
MESSAGE(STATUS "Ruby executable ('${RUBY}') didn't have a value for '${_KEY}'") |
|
482 |
SET(PHYSFS_BUILD_RUBY FALSE) |
|
483 |
ENDIF(NOT ${_VALUE}) |
|
484 |
||
485 |
IF(PHYSFS_BUILD_RUBY) |
|
486 |
MESSAGE(STATUS "Ruby says: '${${_VALUE}}'.") |
|
487 |
ENDIF(PHYSFS_BUILD_RUBY) |
|
488 |
ENDIF(PHYSFS_BUILD_RUBY) |
|
489 |
ENDMACRO(GET_RUBY_CONFIG) |
|
490 |
||
491 |
GET_RUBY_CONFIG("archdir" RUBY_INCLUDE_PATH) |
|
492 |
GET_RUBY_CONFIG("CFLAGS" RUBY_CCFLAGS) |
|
493 |
GET_RUBY_CONFIG("LDFLAGS" RUBY_LDFLAGS) |
|
494 |
GET_RUBY_CONFIG("sitearchdir" RUBY_INSTALL_PATH) |
|
495 |
GET_RUBY_CONFIG("LIBRUBYARG_SHARED" RUBY_LIBRUBY) |
|
496 |
GET_RUBY_CONFIG("libdir" RUBY_LIBDIR) |
|
497 |
||
498 |
CONFIGURE_SWIG_BINDING(Ruby "${RUBY_INSTALL_PATH}" "" "\"-I${RUBY_INCLUDE_PATH}\" ${RUBY_CCFLAGS} -w" "\"-L${RUBY_LIBDIR}\" ${RUBY_LIBRUBY} ${RUBY_LDFLAGS}") |
|
499 |
SET_TARGET_PROPERTIES(physfs-ruby PROPERTIES PREFIX "") |
|
500 |
INSTALL( |
|
501 |
FILES test/test_physfs.rb |
|
502 |
DESTINATION bin |
|
503 |
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE |
|
504 |
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
|
505 |
) |
|
506 |
ENDIF(PHYSFS_BUILD_RUBY) |
|
507 |
||
508 |
||
8084 | 509 |
#INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS} |
510 |
# RUNTIME DESTINATION bin |
|
511 |
# LIBRARY DESTINATION lib${LIB_SUFFIX} |
|
512 |
# ARCHIVE DESTINATION lib${LIB_SUFFIX}) |
|
513 |
#INSTALL(FILES src/physfs.h DESTINATION include) |
|
7768 | 514 |
|
515 |
IF(UNIX) |
|
516 |
SET(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz") |
|
517 |
ADD_CUSTOM_TARGET( |
|
518 |
dist |
|
519 |
hg archive -t tgz "${PHYSFS_TARBALL}" |
|
520 |
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
|
521 |
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..." |
|
522 |
) |
|
7778 | 523 |
# ADD_CUSTOM_TARGET( |
524 |
# uninstall |
|
525 |
# "${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh" |
|
526 |
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" |
|
527 |
# COMMENT "Uninstall the project..." |
|
528 |
# ) |
|
7768 | 529 |
ENDIF(UNIX) |
530 |
||
531 |
MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE) |
|
532 |
IF(${_VALUE}) |
|
533 |
MESSAGE(STATUS " ${_NAME}: enabled") |
|
534 |
ELSE(${_VALUE}) |
|
535 |
MESSAGE(STATUS " ${_NAME}: disabled") |
|
536 |
ENDIF(${_VALUE}) |
|
537 |
ENDMACRO(MESSAGE_BOOL_OPTION) |
|
538 |
||
539 |
MESSAGE(STATUS "PhysicsFS will build with the following options:") |
|
540 |
MESSAGE_BOOL_OPTION("ZIP support" PHYSFS_ARCHIVE_ZIP) |
|
541 |
MESSAGE_BOOL_OPTION("7zip support" PHYSFS_ARCHIVE_7Z) |
|
542 |
MESSAGE_BOOL_OPTION("GRP support" PHYSFS_ARCHIVE_GRP) |
|
543 |
MESSAGE_BOOL_OPTION("WAD support" PHYSFS_ARCHIVE_WAD) |
|
544 |
MESSAGE_BOOL_OPTION("HOG support" PHYSFS_ARCHIVE_HOG) |
|
545 |
MESSAGE_BOOL_OPTION("MVL support" PHYSFS_ARCHIVE_MVL) |
|
546 |
MESSAGE_BOOL_OPTION("QPAK support" PHYSFS_ARCHIVE_QPAK) |
|
547 |
MESSAGE_BOOL_OPTION("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT) |
|
548 |
MESSAGE_BOOL_OPTION("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT) |
|
549 |
MESSAGE_BOOL_OPTION("Build static library" PHYSFS_BUILD_STATIC) |
|
550 |
MESSAGE_BOOL_OPTION("Build shared library" PHYSFS_BUILD_SHARED) |
|
551 |
MESSAGE_BOOL_OPTION("Build Perl bindings" PHYSFS_BUILD_PERL) |
|
552 |
MESSAGE_BOOL_OPTION("Build Ruby bindings" PHYSFS_BUILD_RUBY) |
|
553 |
MESSAGE_BOOL_OPTION("Build stdio test program" PHYSFS_BUILD_TEST) |
|
554 |
IF(PHYSFS_BUILD_TEST) |
|
555 |
MESSAGE_BOOL_OPTION(" Use readline in test program" HAVE_SYSTEM_READLINE) |
|
556 |
ENDIF(PHYSFS_BUILD_TEST) |
|
557 |
||
558 |
# end of CMakeLists.txt ... |
|
559 |