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