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 |
|
|
6 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
|
|
7 |
|
|
8 |
PROJECT(PhysicsFS)
|
|
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)
|
|
50 |
SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework Carbon -framework IOKit")
|
|
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 |
|
8073
|
263 |
IF(WINDOWS)
|
|
264 |
OPTION(PHYSFS_BUILD_STATIC "Build static library" FALSE)
|
|
265 |
OPTION(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
|
|
266 |
ELSE(WINDOWS)
|
|
267 |
OPTION(PHYSFS_BUILD_STATIC "Build static library" TRUE)
|
|
268 |
OPTION(PHYSFS_BUILD_SHARED "Build shared library" FALSE)
|
|
269 |
ENDIF(WINDOWS)
|
7768
|
270 |
|
|
271 |
IF(PHYSFS_BUILD_STATIC)
|
7928
|
272 |
ADD_LIBRARY(physfs STATIC ${PHYSFS_SRCS})
|
|
273 |
SET_TARGET_PROPERTIES(physfs PROPERTIES OUTPUT_NAME "physfs")
|
|
274 |
SET(PHYSFS_LIB_TARGET physfs)
|
|
275 |
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
|
7768
|
276 |
ENDIF(PHYSFS_BUILD_STATIC)
|
|
277 |
|
8073
|
278 |
IF(PHYSFS_BUILD_SHARED)
|
|
279 |
find_package(SDL REQUIRED)
|
|
280 |
ADD_LIBRARY(physfs SHARED ${PHYSFS_SRCS})
|
|
281 |
SET_TARGET_PROPERTIES(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
|
|
282 |
SET_TARGET_PROPERTIES(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
|
8076
|
283 |
TARGET_LINK_LIBRARIES(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS} ${SDL_LIBRARY})
|
8073
|
284 |
SET(PHYSFS_LIB_TARGET physfs)
|
|
285 |
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
|
|
286 |
ENDIF(PHYSFS_BUILD_SHARED)
|
7768
|
287 |
|
|
288 |
IF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
|
|
289 |
MESSAGE(FATAL "Both shared and static libraries are disabled!")
|
|
290 |
ENDIF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
|
|
291 |
|
|
292 |
# CMake FAQ says I need this...
|
|
293 |
IF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
|
294 |
SET_TARGET_PROPERTIES(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
|
295 |
ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
|
296 |
|
|
297 |
OPTION(PHYSFS_BUILD_TEST "Build stdio test program." FALSE)
|
|
298 |
MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
|
|
299 |
IF(PHYSFS_BUILD_TEST)
|
|
300 |
FIND_PATH(READLINE_H readline/readline.h)
|
|
301 |
FIND_PATH(HISTORY_H readline/history.h)
|
|
302 |
IF(READLINE_H AND HISTORY_H)
|
|
303 |
FIND_LIBRARY(CURSES_LIBRARY NAMES curses ncurses)
|
|
304 |
SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
|
|
305 |
FIND_LIBRARY(READLINE_LIBRARY readline)
|
|
306 |
IF(READLINE_LIBRARY)
|
|
307 |
SET(HAVE_SYSTEM_READLINE TRUE)
|
|
308 |
SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
|
|
309 |
INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H})
|
|
310 |
ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
|
|
311 |
ENDIF(READLINE_LIBRARY)
|
|
312 |
ENDIF(READLINE_H AND HISTORY_H)
|
|
313 |
ADD_EXECUTABLE(test_physfs test/test_physfs.c)
|
|
314 |
TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
|
|
315 |
SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
|
|
316 |
ENDIF(PHYSFS_BUILD_TEST)
|
|
317 |
|
|
318 |
|
|
319 |
# Scripting language bindings...
|
|
320 |
|
|
321 |
#CMake's SWIG support is basically useless.
|
|
322 |
#FIND_PACKAGE(SWIG)
|
|
323 |
|
7778
|
324 |
OPTION(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." FALSE)
|
7768
|
325 |
MARK_AS_ADVANCED(PHYSFS_BUILD_SWIG)
|
|
326 |
|
|
327 |
FIND_PROGRAM(SWIG swig DOC "Path to swig command line app: http://swig.org/")
|
|
328 |
IF(NOT SWIG)
|
|
329 |
MESSAGE(STATUS "SWIG not found. You won't be able to build scripting language bindings.")
|
|
330 |
ELSE(NOT SWIG)
|
|
331 |
MARK_AS_ADVANCED(SWIG)
|
|
332 |
IF(DEFINED CMAKE_BUILD_TYPE)
|
|
333 |
IF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
|
334 |
IF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
335 |
SET(SWIG_OPT_CFLAGS "-small")
|
|
336 |
ELSE(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
337 |
SET(SWIG_OPT_CFLAGS "-O")
|
|
338 |
ENDIF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
339 |
ENDIF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
|
340 |
ENDIF(DEFINED CMAKE_BUILD_TYPE)
|
|
341 |
|
|
342 |
SET(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings")
|
|
343 |
|
|
344 |
MACRO(CONFIGURE_SWIG_BINDING _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS)
|
|
345 |
STRING(TOUPPER "${_LANG}" _UPPERLANG)
|
|
346 |
STRING(TOLOWER "${_LANG}" _LOWERLANG)
|
|
347 |
SET(_TARGET "physfs-${_LOWERLANG}")
|
|
348 |
SET(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}")
|
|
349 |
|
|
350 |
IF(NOT EXISTS "${_TARGETDIR}")
|
|
351 |
FILE(MAKE_DIRECTORY "${_TARGETDIR}")
|
|
352 |
ENDIF(NOT EXISTS "${_TARGETDIR}")
|
|
353 |
|
|
354 |
IF(PHYSFS_BUILD_${_UPPERLANG})
|
|
355 |
ADD_CUSTOM_COMMAND(
|
|
356 |
OUTPUT "${_TARGETDIR}/${_TARGET}.c" ${_EXTRAOUTPUTS}
|
|
357 |
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
|
|
358 |
COMMAND "${SWIG}"
|
|
359 |
ARGS ${SWIG_OPT_CFLAGS} -${_LOWERLANG} -outdir "${_TARGETDIR}" -o "${_TARGETDIR}/${_TARGET}.c" "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
|
|
360 |
COMMENT "Generating ${_LANG} bindings..."
|
|
361 |
)
|
|
362 |
|
|
363 |
ADD_LIBRARY(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c")
|
|
364 |
TARGET_LINK_LIBRARIES(${_TARGET} ${PHYSFS_LIB_TARGET})
|
|
365 |
SET_TARGET_PROPERTIES(${_TARGET} PROPERTIES
|
|
366 |
COMPILE_FLAGS "${_EXTRACFLAGS}"
|
|
367 |
LINK_FLAGS "${_EXTRALDFLAGS}"
|
|
368 |
LIBRARY_OUTPUT_NAME "physfs"
|
|
369 |
LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}"
|
|
370 |
CLEAN_DIRECT_OUTPUT 1
|
|
371 |
)
|
|
372 |
INSTALL(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}")
|
|
373 |
MESSAGE(STATUS "${_LANG} bindings configured!")
|
|
374 |
ELSE(PHYSFS_BUILD_${_UPPERLANG})
|
|
375 |
MESSAGE(STATUS "Couldn't figure out ${_LANG} configuration. Skipping ${_LANG} bindings.")
|
|
376 |
ENDIF(PHYSFS_BUILD_${_UPPERLANG})
|
|
377 |
ENDMACRO(CONFIGURE_SWIG_BINDING)
|
|
378 |
|
|
379 |
MACRO(ADD_SCRIPT_BINDING_OPTION _VAR _LANG _DEFVAL)
|
|
380 |
SET(BUILDSWIGVAL ${_DEFVAL})
|
|
381 |
IF(NOT PHYSFS_BUILD_SWIG)
|
|
382 |
SET(BUILDSWIGVAL FALSE)
|
|
383 |
ENDIF(NOT PHYSFS_BUILD_SWIG)
|
|
384 |
OPTION(${_VAR} "Build ${_LANG} bindings." ${BUILDSWIGVAL})
|
|
385 |
MARK_AS_ADVANCED(${_VAR})
|
|
386 |
ENDMACRO(ADD_SCRIPT_BINDING_OPTION)
|
|
387 |
|
|
388 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_PERL "Perl" TRUE)
|
|
389 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_RUBY "Ruby" TRUE)
|
|
390 |
ENDIF(NOT SWIG)
|
|
391 |
|
|
392 |
IF(PHYSFS_BUILD_PERL)
|
|
393 |
MESSAGE(STATUS "Configuring Perl bindings...")
|
|
394 |
FIND_PROGRAM(PERL perl DOC "Path to perl command line app: http://perl.org/")
|
|
395 |
IF(NOT PERL)
|
|
396 |
MESSAGE(STATUS "Perl not found. You won't be able to build perl bindings.")
|
|
397 |
SET(PHYSFS_BUILD_PERL FALSE)
|
|
398 |
ENDIF(NOT PERL)
|
|
399 |
MARK_AS_ADVANCED(PERL)
|
|
400 |
|
|
401 |
MACRO(GET_PERL_CONFIG _KEY _VALUE)
|
|
402 |
IF(PHYSFS_BUILD_PERL)
|
|
403 |
MESSAGE(STATUS "Figuring out perl config value '${_KEY}' ...")
|
|
404 |
EXECUTE_PROCESS(
|
|
405 |
COMMAND ${PERL} -w -e "use Config; print \$Config{${_KEY}};"
|
|
406 |
RESULT_VARIABLE GET_PERL_CONFIG_RC
|
|
407 |
OUTPUT_VARIABLE ${_VALUE}
|
|
408 |
)
|
|
409 |
IF(NOT GET_PERL_CONFIG_RC EQUAL 0)
|
|
410 |
MESSAGE(STATUS "Perl executable ('${PERL}') reported failure: ${GET_PERL_CONFIG_RC}")
|
|
411 |
SET(PHYSFS_BUILD_PERL FALSE)
|
|
412 |
ENDIF(NOT GET_PERL_CONFIG_RC EQUAL 0)
|
|
413 |
IF(NOT ${_VALUE})
|
|
414 |
MESSAGE(STATUS "Perl executable ('${PERL}') didn't have a value for '${_KEY}'")
|
|
415 |
SET(PHYSFS_BUILD_PERL FALSE)
|
|
416 |
ENDIF(NOT ${_VALUE})
|
|
417 |
|
|
418 |
IF(PHYSFS_BUILD_PERL)
|
|
419 |
MESSAGE(STATUS "Perl says: '${${_VALUE}}'.")
|
|
420 |
ENDIF(PHYSFS_BUILD_PERL)
|
|
421 |
ENDIF(PHYSFS_BUILD_PERL)
|
|
422 |
ENDMACRO(GET_PERL_CONFIG)
|
|
423 |
|
|
424 |
# !!! FIXME: installsitearch might be the wrong location.
|
|
425 |
GET_PERL_CONFIG("archlibexp" PERL_INCLUDE_PATH)
|
|
426 |
GET_PERL_CONFIG("ccflags" PERL_CCFLAGS)
|
|
427 |
GET_PERL_CONFIG("ldflags" PERL_LDFLAGS)
|
|
428 |
GET_PERL_CONFIG("installsitearch" PERL_INSTALL_PATH)
|
|
429 |
|
|
430 |
# !!! FIXME: this test for Mac OS X is wrong.
|
|
431 |
IF(MACOSX)
|
|
432 |
GET_PERL_CONFIG("libperl" PERL_LIBPERL)
|
|
433 |
SET(TMPLIBPERL "${PERL_LIBPERL}")
|
|
434 |
STRING(REGEX REPLACE "^lib" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
435 |
STRING(REGEX REPLACE "\\.so$" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
436 |
STRING(REGEX REPLACE "\\.dylib$" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
437 |
STRING(REGEX REPLACE "\\.dll$" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
438 |
IF(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
|
|
439 |
MESSAGE(STATUS "Stripped '${PERL_LIBPERL}' down to '${TMPLIBPERL}'.")
|
|
440 |
SET(PERL_LIBPERL "${TMPLIBPERL}")
|
|
441 |
ENDIF(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
|
|
442 |
SET(PERL_LIBPERL "-l${PERL_LIBPERL}")
|
|
443 |
ENDIF(MACOSX)
|
|
444 |
|
|
445 |
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}")
|
|
446 |
INSTALL(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}")
|
|
447 |
INSTALL(
|
|
448 |
FILES test/test_physfs.pl
|
|
449 |
DESTINATION bin
|
|
450 |
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
451 |
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
452 |
)
|
|
453 |
ENDIF(PHYSFS_BUILD_PERL)
|
|
454 |
|
|
455 |
# !!! FIXME: lots of cut-and-paste from perl bindings.
|
|
456 |
IF(PHYSFS_BUILD_RUBY)
|
|
457 |
MESSAGE(STATUS "Configuring Ruby bindings...")
|
|
458 |
FIND_PROGRAM(RUBY ruby DOC "Path to ruby command line app: http://ruby-lang.org/")
|
|
459 |
IF(NOT RUBY)
|
|
460 |
MESSAGE(STATUS "Ruby not found. You won't be able to build ruby bindings.")
|
|
461 |
SET(PHYSFS_BUILD_RUBY FALSE)
|
|
462 |
ENDIF(NOT RUBY)
|
|
463 |
MARK_AS_ADVANCED(RUBY)
|
|
464 |
|
|
465 |
MACRO(GET_RUBY_CONFIG _KEY _VALUE)
|
|
466 |
IF(PHYSFS_BUILD_RUBY)
|
|
467 |
MESSAGE(STATUS "Figuring out ruby config value '${_KEY}' ...")
|
|
468 |
EXECUTE_PROCESS(
|
|
469 |
COMMAND ${RUBY} -e "require 'rbconfig'; puts RbConfig::CONFIG['${_KEY}'];"
|
|
470 |
RESULT_VARIABLE GET_RUBY_CONFIG_RC
|
|
471 |
OUTPUT_VARIABLE ${_VALUE}
|
|
472 |
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
473 |
)
|
|
474 |
IF(NOT GET_RUBY_CONFIG_RC EQUAL 0)
|
|
475 |
MESSAGE(STATUS "Ruby executable ('${RUBY}') reported failure: ${GET_RUBY_CONFIG_RC}")
|
|
476 |
SET(PHYSFS_BUILD_RUBY FALSE)
|
|
477 |
ENDIF(NOT GET_RUBY_CONFIG_RC EQUAL 0)
|
|
478 |
IF(NOT ${_VALUE})
|
|
479 |
MESSAGE(STATUS "Ruby executable ('${RUBY}') didn't have a value for '${_KEY}'")
|
|
480 |
SET(PHYSFS_BUILD_RUBY FALSE)
|
|
481 |
ENDIF(NOT ${_VALUE})
|
|
482 |
|
|
483 |
IF(PHYSFS_BUILD_RUBY)
|
|
484 |
MESSAGE(STATUS "Ruby says: '${${_VALUE}}'.")
|
|
485 |
ENDIF(PHYSFS_BUILD_RUBY)
|
|
486 |
ENDIF(PHYSFS_BUILD_RUBY)
|
|
487 |
ENDMACRO(GET_RUBY_CONFIG)
|
|
488 |
|
|
489 |
GET_RUBY_CONFIG("archdir" RUBY_INCLUDE_PATH)
|
|
490 |
GET_RUBY_CONFIG("CFLAGS" RUBY_CCFLAGS)
|
|
491 |
GET_RUBY_CONFIG("LDFLAGS" RUBY_LDFLAGS)
|
|
492 |
GET_RUBY_CONFIG("sitearchdir" RUBY_INSTALL_PATH)
|
|
493 |
GET_RUBY_CONFIG("LIBRUBYARG_SHARED" RUBY_LIBRUBY)
|
|
494 |
GET_RUBY_CONFIG("libdir" RUBY_LIBDIR)
|
|
495 |
|
|
496 |
CONFIGURE_SWIG_BINDING(Ruby "${RUBY_INSTALL_PATH}" "" "\"-I${RUBY_INCLUDE_PATH}\" ${RUBY_CCFLAGS} -w" "\"-L${RUBY_LIBDIR}\" ${RUBY_LIBRUBY} ${RUBY_LDFLAGS}")
|
|
497 |
SET_TARGET_PROPERTIES(physfs-ruby PROPERTIES PREFIX "")
|
|
498 |
INSTALL(
|
|
499 |
FILES test/test_physfs.rb
|
|
500 |
DESTINATION bin
|
|
501 |
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
502 |
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
503 |
)
|
|
504 |
ENDIF(PHYSFS_BUILD_RUBY)
|
|
505 |
|
|
506 |
|
|
507 |
INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS}
|
|
508 |
RUNTIME DESTINATION bin
|
|
509 |
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
|
510 |
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
|
511 |
INSTALL(FILES src/physfs.h DESTINATION include)
|
|
512 |
|
|
513 |
IF(UNIX)
|
|
514 |
SET(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz")
|
|
515 |
ADD_CUSTOM_TARGET(
|
|
516 |
dist
|
|
517 |
hg archive -t tgz "${PHYSFS_TARBALL}"
|
|
518 |
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
519 |
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
|
|
520 |
)
|
7778
|
521 |
# ADD_CUSTOM_TARGET(
|
|
522 |
# uninstall
|
|
523 |
# "${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh"
|
|
524 |
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
525 |
# COMMENT "Uninstall the project..."
|
|
526 |
# )
|
7768
|
527 |
ENDIF(UNIX)
|
|
528 |
|
|
529 |
MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
|
530 |
IF(${_VALUE})
|
|
531 |
MESSAGE(STATUS " ${_NAME}: enabled")
|
|
532 |
ELSE(${_VALUE})
|
|
533 |
MESSAGE(STATUS " ${_NAME}: disabled")
|
|
534 |
ENDIF(${_VALUE})
|
|
535 |
ENDMACRO(MESSAGE_BOOL_OPTION)
|
|
536 |
|
|
537 |
MESSAGE(STATUS "PhysicsFS will build with the following options:")
|
|
538 |
MESSAGE_BOOL_OPTION("ZIP support" PHYSFS_ARCHIVE_ZIP)
|
|
539 |
MESSAGE_BOOL_OPTION("7zip support" PHYSFS_ARCHIVE_7Z)
|
|
540 |
MESSAGE_BOOL_OPTION("GRP support" PHYSFS_ARCHIVE_GRP)
|
|
541 |
MESSAGE_BOOL_OPTION("WAD support" PHYSFS_ARCHIVE_WAD)
|
|
542 |
MESSAGE_BOOL_OPTION("HOG support" PHYSFS_ARCHIVE_HOG)
|
|
543 |
MESSAGE_BOOL_OPTION("MVL support" PHYSFS_ARCHIVE_MVL)
|
|
544 |
MESSAGE_BOOL_OPTION("QPAK support" PHYSFS_ARCHIVE_QPAK)
|
|
545 |
MESSAGE_BOOL_OPTION("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT)
|
|
546 |
MESSAGE_BOOL_OPTION("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT)
|
|
547 |
MESSAGE_BOOL_OPTION("Build static library" PHYSFS_BUILD_STATIC)
|
|
548 |
MESSAGE_BOOL_OPTION("Build shared library" PHYSFS_BUILD_SHARED)
|
|
549 |
MESSAGE_BOOL_OPTION("Build Perl bindings" PHYSFS_BUILD_PERL)
|
|
550 |
MESSAGE_BOOL_OPTION("Build Ruby bindings" PHYSFS_BUILD_RUBY)
|
|
551 |
MESSAGE_BOOL_OPTION("Build stdio test program" PHYSFS_BUILD_TEST)
|
|
552 |
IF(PHYSFS_BUILD_TEST)
|
|
553 |
MESSAGE_BOOL_OPTION(" Use readline in test program" HAVE_SYSTEM_READLINE)
|
|
554 |
ENDIF(PHYSFS_BUILD_TEST)
|
|
555 |
|
|
556 |
# end of CMakeLists.txt ...
|
|
557 |
|