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