author | koda |
Tue, 04 Dec 2012 03:25:31 +0100 | |
branch | flibqtfrontend |
changeset 8214 | 8edc37cdcfbf |
parent 8208 | 171da01bd04d |
child 8304 | 620560c89284 |
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) |
8146 | 9 |
set(PHYSFS_VERSION 2.1.0) |
7768 | 10 |
|
11 |
# Increment this if/when we break backwards compatibility. |
|
8146 | 12 |
set(PHYSFS_SOVERSION 1) |
7768 | 13 |
|
14 |
# I hate that they define "WIN32" ... we're about to move to Win64...I hope! |
|
8146 | 15 |
if(WIN32 AND NOT WINDOWS) |
16 |
set(WINDOWS true) |
|
17 |
endif(WIN32 AND NOT WINDOWS) |
|
7768 | 18 |
|
19 |
# Bleh, let's do it for "APPLE" too. |
|
8146 | 20 |
if(APPLE AND NOT MACOSX) |
21 |
set(MACOSX true) |
|
22 |
endif(APPLE AND NOT MACOSX) |
|
7768 | 23 |
|
24 |
# For now, Haiku and BeOS are the same, as far as the build system cares. |
|
8146 | 25 |
if(HAIKU AND NOT BEOS) |
26 |
set(BEOS true) |
|
27 |
endif(HAIKU AND NOT BEOS) |
|
7768 | 28 |
|
8146 | 29 |
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
30 |
set(SOLARIS true) |
|
31 |
endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
|
7768 | 32 |
|
8146 | 33 |
include(CheckIncludeFile) |
34 |
include(CheckLibraryExists) |
|
35 |
include(CheckCSourceCompiles) |
|
7768 | 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 |
|
8146 | 41 |
if(MACOSX) |
7768 | 42 |
# Fallback to older OS X on PowerPC to support wider range of systems... |
8146 | 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) |
|
7768 | 47 |
|
48 |
# Need these everywhere... |
|
8146 | 49 |
add_definitions(-fno-common) |
50 |
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit") |
|
51 |
endif(MACOSX) |
|
7768 | 52 |
|
53 |
# Add some gcc-specific command lines. |
|
8146 | 54 |
if(CMAKE_COMPILER_IS_GNUCC) |
7768 | 55 |
# Always build with debug symbols...you can strip it later. |
8146 | 56 |
add_definitions(-g -pipe -Werror -fsigned-char) |
7768 | 57 |
|
58 |
# Stupid BeOS generates warnings in the system headers. |
|
8146 | 59 |
if(NOT BEOS) |
60 |
add_definitions(-Wall) |
|
61 |
endif(NOT BEOS) |
|
7768 | 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 |
||
8146 | 71 |
if(PHYSFS_IS_GCC4) |
7768 | 72 |
# Not supported on several operating systems at this time. |
8146 | 73 |
if(NOT SOLARIS AND NOT WINDOWS) |
74 |
add_definitions(-fvisibility=hidden) |
|
75 |
endif(NOT SOLARIS AND NOT WINDOWS) |
|
76 |
endif(PHYSFS_IS_GCC4) |
|
7768 | 77 |
|
78 |
# Don't use -rpath. |
|
8146 | 79 |
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) |
80 |
endif(CMAKE_COMPILER_IS_GNUCC) |
|
7768 | 81 |
|
8146 | 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") |
|
7768 | 86 |
|
8146 | 87 |
if(MSVC) |
7768 | 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. |
|
8146 | 90 |
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) |
91 |
endif(MSVC) |
|
7768 | 92 |
|
93 |
# Basic chunks of source code ... |
|
94 |
||
8146 | 95 |
set(LZMA_SRCS |
7768 | 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 |
||
8146 | 109 |
if(BEOS) |
7768 | 110 |
# We add this explicitly, since we don't want CMake to think this |
111 |
# is a C++ project unless we're on BeOS. |
|
8146 | 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) |
|
7768 | 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. |
|
8146 | 122 |
set(PHYSFS_SRCS |
7768 | 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 |
|
8100 | 144 |
extras/physfsfgets.c |
7768 | 145 |
${PHYSFS_BEOS_SRCS} |
146 |
) |
|
147 |
||
148 |
||
149 |
# platform layers ... |
|
150 |
||
8146 | 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) |
|
7768 | 157 |
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) |
8146 | 158 |
if(HAVE_UCRED_H) |
159 |
add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1) |
|
160 |
set(PHYSFS_HAVE_CDROM_SUPPORT false) |
|
161 |
endif(HAVE_UCRED_H) |
|
7768 | 162 |
|
163 |
CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H) |
|
8146 | 164 |
if(HAVE_MNTENT_H) |
165 |
add_definitions(-DPHYSFS_HAVE_MNTENT_H=1) |
|
166 |
set(PHYSFS_HAVE_CDROM_SUPPORT false) |
|
167 |
endif(HAVE_MNTENT_H) |
|
7768 | 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 |
||
8146 | 178 |
if(HAVE_SYS_MNTTAB_H) |
179 |
add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1) |
|
180 |
set(PHYSFS_HAVE_CDROM_SUPPORT false) |
|
181 |
endif(HAVE_SYS_MNTTAB_H) |
|
7768 | 182 |
|
183 |
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) |
|
8146 | 184 |
if(HAVE_PTHREAD_H) |
185 |
set(PHYSFS_HAVE_THREAD_SUPPORT false) |
|
186 |
endif(HAVE_PTHREAD_H) |
|
187 |
endif(BEOS) |
|
188 |
endif(UNIX) |
|
7768 | 189 |
|
8146 | 190 |
if(WINDOWS) |
191 |
set(PHYSFS_HAVE_CDROM_SUPPORT true) |
|
192 |
set(PHYSFS_HAVE_THREAD_SUPPORT true) |
|
193 |
endif(WINDOWS) |
|
7768 | 194 |
|
8146 | 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) |
|
7768 | 205 |
|
8146 | 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) |
|
7768 | 218 |
|
219 |
||
220 |
# Archivers ... |
|
221 |
||
8146 | 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) |
|
7768 | 226 |
|
8146 | 227 |
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" false) |
228 |
if(PHYSFS_ARCHIVE_7Z) |
|
229 |
add_definitions(-DPHYSFS_SUPPORTS_7Z=1) |
|
7768 | 230 |
# !!! FIXME: rename to 7z.c? |
8146 | 231 |
set(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS}) |
232 |
endif(PHYSFS_ARCHIVE_7Z) |
|
7768 | 233 |
|
8146 | 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) |
|
7768 | 238 |
|
8146 | 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) |
|
7768 | 243 |
|
8146 | 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) |
|
7768 | 248 |
|
8146 | 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) |
|
7768 | 253 |
|
8146 | 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) |
|
7768 | 258 |
|
8146 | 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) |
|
7768 | 263 |
|
8087
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
264 |
#as needed by Hedgewars configuration |
8146 | 265 |
if(WINDOWS) |
266 |
option(PHYSFS_BUILD_STATIC "Build static library" false) |
|
267 |
option(PHYSFS_BUILD_SHARED "Build shared library" true) |
|
268 |
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} ${SDL_LIBRARY}) |
|
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 |
|
8146 | 274 |
if(PHYSFS_BUILD_STATIC) |
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") |
|
279 |
endif(PHYSFS_BUILD_STATIC) |
|
7768 | 280 |
|
8146 | 281 |
if(PHYSFS_BUILD_SHARED) |
8073 | 282 |
find_package(SDL REQUIRED) |
8146 | 283 |
add_library(physfs SHARED ${PHYSFS_SRCS}) |
284 |
set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION}) |
|
285 |
set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION}) |
|
286 |
target_link_libraries(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS}) |
|
287 |
set(PHYSFS_LIB_TARGET physfs) |
|
288 |
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs") |
|
289 |
install(TARGETS ${PHYSFS_INSTALL_TARGETS} |
|
8101 | 290 |
RUNTIME DESTINATION bin) |
8146 | 291 |
endif(PHYSFS_BUILD_SHARED) |
7768 | 292 |
|
8146 | 293 |
if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) |
294 |
message(FATAL "Both shared and static libraries are disabled!") |
|
295 |
endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) |
|
7768 | 296 |
|
297 |
# CMake FAQ says I need this... |
|
8146 | 298 |
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC) |
299 |
set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
|
300 |
endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC) |
|
7768 | 301 |
|
8146 | 302 |
option(PHYSFS_BUILD_TEST "Build stdio test program." false) |
303 |
mark_as_advanced(PHYSFS_BUILD_TEST) |
|
304 |
if(PHYSFS_BUILD_TEST) |
|
305 |
find_path(READLINE_H readline/readline.h) |
|
306 |
find_path(HISTORY_H readline/history.h) |
|
307 |
if(READLINE_H AND HISTORY_H) |
|
308 |
find_library(CURSES_LIBRARY NAMES curses ncurses) |
|
309 |
set(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY}) |
|
310 |
find_library(READLINE_LIBRARY readline) |
|
311 |
if(READLINE_LIBRARY) |
|
312 |
set(HAVE_SYSTEM_READLINE true) |
|
313 |
set(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY}) |
|
314 |
include_directories(${READLINE_H} ${HISTORY_H}) |
|
315 |
add_definitions(-DPHYSFS_HAVE_READLINE=1) |
|
316 |
endif(READLINE_LIBRARY) |
|
317 |
endif(READLINE_H AND HISTORY_H) |
|
318 |
add_executable(test_physfs test/test_physfs.c) |
|
319 |
target_link_libraries(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS}) |
|
320 |
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs") |
|
321 |
endif(PHYSFS_BUILD_TEST) |
|
7768 | 322 |
|
323 |
||
324 |
# Scripting language bindings... |
|
325 |
||
326 |
#CMake's SWIG support is basically useless. |
|
327 |
#FIND_PACKAGE(SWIG) |
|
328 |
||
8146 | 329 |
option(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." false) |
330 |
mark_as_advanced(PHYSFS_BUILD_SWIG) |
|
7768 | 331 |
|
8146 | 332 |
find_program(SWIG swig DOC "Path to swig command line app: http://swig.org/") |
333 |
if(NOT SWIG) |
|
334 |
message(STATUS "SWIG not found. You won't be able to build scripting language bindings.") |
|
335 |
else(NOT SWIG) |
|
336 |
mark_as_advanced(SWIG) |
|
337 |
if(DEFINED CMAKE_BUILD_TYPE) |
|
338 |
if((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")) |
|
339 |
if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
|
340 |
set(SWIG_OPT_CFLAGS "-small") |
|
341 |
else(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
|
342 |
set(SWIG_OPT_CFLAGS "-O") |
|
343 |
endif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
|
344 |
endif((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")) |
|
345 |
endif(DEFINED CMAKE_BUILD_TYPE) |
|
7768 | 346 |
|
8146 | 347 |
set(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings") |
7768 | 348 |
|
8146 | 349 |
macro(CONFIGURE_SWIG_BINDING _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS) |
350 |
string(TOUPPER "${_LANG}" _UPPERLANG) |
|
351 |
string(TOLOWER "${_LANG}" _LOWERLANG) |
|
352 |
set(_TARGET "physfs-${_LOWERLANG}") |
|
353 |
set(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}") |
|
7768 | 354 |
|
8146 | 355 |
if(NOT EXISTS "${_TARGETDIR}") |
356 |
file(MAKE_DIRECTORY "${_TARGETDIR}") |
|
357 |
endif(NOT EXISTS "${_TARGETDIR}") |
|
7768 | 358 |
|
8146 | 359 |
if(PHYSFS_BUILD_${_UPPERLANG}) |
360 |
add_custom_command( |
|
7768 | 361 |
OUTPUT "${_TARGETDIR}/${_TARGET}.c" ${_EXTRAOUTPUTS} |
362 |
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i" |
|
363 |
COMMAND "${SWIG}" |
|
364 |
ARGS ${SWIG_OPT_CFLAGS} -${_LOWERLANG} -outdir "${_TARGETDIR}" -o "${_TARGETDIR}/${_TARGET}.c" "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i" |
|
365 |
COMMENT "Generating ${_LANG} bindings..." |
|
366 |
) |
|
367 |
||
8146 | 368 |
add_library(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c") |
369 |
target_link_libraries(${_TARGET} ${PHYSFS_LIB_TARGET}) |
|
370 |
set_target_properties(${_TARGET} PROPERTIES |
|
7768 | 371 |
COMPILE_FLAGS "${_EXTRACFLAGS}" |
372 |
LINK_FLAGS "${_EXTRALDFLAGS}" |
|
373 |
LIBRARY_OUTPUT_NAME "physfs" |
|
374 |
LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}" |
|
375 |
CLEAN_DIRECT_OUTPUT 1 |
|
376 |
) |
|
8146 | 377 |
install(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}") |
378 |
message(STATUS "${_LANG} bindings configured!") |
|
379 |
else(PHYSFS_BUILD_${_UPPERLANG}) |
|
380 |
message(STATUS "Couldn't figure out ${_LANG} configuration. Skipping ${_LANG} bindings.") |
|
381 |
endif(PHYSFS_BUILD_${_UPPERLANG}) |
|
382 |
endmacro(CONFIGURE_SWIG_BINDING) |
|
7768 | 383 |
|
8146 | 384 |
macro(ADD_SCRIPT_BINDING_OPTION _VAR _LANG _DEFVAL) |
385 |
set(BUILDSWIGVAL ${_DEFVAL}) |
|
386 |
if(NOT PHYSFS_BUILD_SWIG) |
|
387 |
set(BUILDSWIGVAL false) |
|
388 |
endif(NOT PHYSFS_BUILD_SWIG) |
|
389 |
option(${_VAR} "Build ${_LANG} bindings." ${BUILDSWIGVAL}) |
|
390 |
mark_as_advanced(${_VAR}) |
|
391 |
endmacro(ADD_SCRIPT_BINDING_OPTION) |
|
7768 | 392 |
|
8146 | 393 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_PERL "Perl" true) |
394 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_RUBY "Ruby" true) |
|
395 |
endif(NOT SWIG) |
|
7768 | 396 |
|
8146 | 397 |
if(PHYSFS_BUILD_PERL) |
398 |
message(STATUS "Configuring Perl bindings...") |
|
399 |
find_program(PERL perl DOC "Path to perl command line app: http://perl.org/") |
|
400 |
if(NOT PERL) |
|
401 |
message(STATUS "Perl not found. You won't be able to build perl bindings.") |
|
402 |
set(PHYSFS_BUILD_PERL false) |
|
403 |
endif(NOT PERL) |
|
404 |
mark_as_advanced(PERL) |
|
7768 | 405 |
|
8146 | 406 |
macro(GET_PERL_CONFIG _KEY _VALUE) |
407 |
if(PHYSFS_BUILD_PERL) |
|
408 |
message(STATUS "Figuring out perl config value '${_KEY}' ...") |
|
409 |
execute_process( |
|
7768 | 410 |
COMMAND ${PERL} -w -e "use Config; print \$Config{${_KEY}};" |
411 |
RESULT_VARIABLE GET_PERL_CONFIG_RC |
|
412 |
OUTPUT_VARIABLE ${_VALUE} |
|
413 |
) |
|
8146 | 414 |
if(NOT GET_PERL_CONFIG_RC EQUAL 0) |
415 |
message(STATUS "Perl executable ('${PERL}') reported failure: ${GET_PERL_CONFIG_RC}") |
|
416 |
set(PHYSFS_BUILD_PERL false) |
|
417 |
endif(NOT GET_PERL_CONFIG_RC EQUAL 0) |
|
418 |
if(NOT ${_VALUE}) |
|
419 |
message(STATUS "Perl executable ('${PERL}') didn't have a value for '${_KEY}'") |
|
420 |
set(PHYSFS_BUILD_PERL false) |
|
421 |
endif(NOT ${_VALUE}) |
|
7768 | 422 |
|
8146 | 423 |
if(PHYSFS_BUILD_PERL) |
424 |
message(STATUS "Perl says: '${${_VALUE}}'.") |
|
425 |
endif(PHYSFS_BUILD_PERL) |
|
426 |
endif(PHYSFS_BUILD_PERL) |
|
427 |
endmacro(GET_PERL_CONFIG) |
|
7768 | 428 |
|
429 |
# !!! FIXME: installsitearch might be the wrong location. |
|
430 |
GET_PERL_CONFIG("archlibexp" PERL_INCLUDE_PATH) |
|
431 |
GET_PERL_CONFIG("ccflags" PERL_CCFLAGS) |
|
432 |
GET_PERL_CONFIG("ldflags" PERL_LDFLAGS) |
|
433 |
GET_PERL_CONFIG("installsitearch" PERL_INSTALL_PATH) |
|
434 |
||
435 |
# !!! FIXME: this test for Mac OS X is wrong. |
|
8146 | 436 |
if(MACOSX) |
7768 | 437 |
GET_PERL_CONFIG("libperl" PERL_LIBPERL) |
8146 | 438 |
set(TMPLIBPERL "${PERL_LIBPERL}") |
439 |
string(REGEX REPLACE "^lib" "" TMPLIBPERL "${TMPLIBPERL}") |
|
440 |
string(REGEX REPLACE "\\.so$" "" TMPLIBPERL "${TMPLIBPERL}") |
|
441 |
string(REGEX REPLACE "\\.dylib$" "" TMPLIBPERL "${TMPLIBPERL}") |
|
442 |
string(REGEX REPLACE "\\.dll$" "" TMPLIBPERL "${TMPLIBPERL}") |
|
443 |
if(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}") |
|
444 |
message(STATUS "Stripped '${PERL_LIBPERL}' down to '${TMPLIBPERL}'.") |
|
445 |
set(PERL_LIBPERL "${TMPLIBPERL}") |
|
446 |
endif(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}") |
|
447 |
set(PERL_LIBPERL "-l${PERL_LIBPERL}") |
|
448 |
endif(MACOSX) |
|
7768 | 449 |
|
450 |
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}") |
|
8146 | 451 |
install(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}") |
452 |
install( |
|
7768 | 453 |
FILES test/test_physfs.pl |
454 |
DESTINATION bin |
|
455 |
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE |
|
456 |
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
|
457 |
) |
|
8146 | 458 |
endif(PHYSFS_BUILD_PERL) |
7768 | 459 |
|
460 |
# !!! FIXME: lots of cut-and-paste from perl bindings. |
|
8146 | 461 |
if(PHYSFS_BUILD_RUBY) |
462 |
message(STATUS "Configuring Ruby bindings...") |
|
463 |
find_program(RUBY ruby DOC "Path to ruby command line app: http://ruby-lang.org/") |
|
464 |
if(NOT RUBY) |
|
465 |
message(STATUS "Ruby not found. You won't be able to build ruby bindings.") |
|
466 |
set(PHYSFS_BUILD_RUBY FALSE) |
|
467 |
endif(NOT RUBY) |
|
468 |
mark_as_advanced(RUBY) |
|
7768 | 469 |
|
8146 | 470 |
macro(GET_RUBY_CONFIG _KEY _VALUE) |
471 |
if(PHYSFS_BUILD_RUBY) |
|
472 |
message(STATUS "Figuring out ruby config value '${_KEY}' ...") |
|
473 |
execute_process( |
|
7768 | 474 |
COMMAND ${RUBY} -e "require 'rbconfig'; puts RbConfig::CONFIG['${_KEY}'];" |
475 |
RESULT_VARIABLE GET_RUBY_CONFIG_RC |
|
476 |
OUTPUT_VARIABLE ${_VALUE} |
|
477 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
478 |
) |
|
8146 | 479 |
if(NOT GET_RUBY_CONFIG_RC EQUAL 0) |
480 |
message(STATUS "Ruby executable ('${RUBY}') reported failure: ${GET_RUBY_CONFIG_RC}") |
|
481 |
set(PHYSFS_BUILD_RUBY FALSE) |
|
482 |
endif(NOT GET_RUBY_CONFIG_RC EQUAL 0) |
|
483 |
if(NOT ${_VALUE}) |
|
484 |
message(STATUS "Ruby executable ('${RUBY}') didn't have a value for '${_KEY}'") |
|
485 |
set(PHYSFS_BUILD_RUBY FALSE) |
|
486 |
endif(NOT ${_VALUE}) |
|
7768 | 487 |
|
8146 | 488 |
if(PHYSFS_BUILD_RUBY) |
489 |
message(STATUS "Ruby says: '${${_VALUE}}'.") |
|
490 |
endif(PHYSFS_BUILD_RUBY) |
|
491 |
endif(PHYSFS_BUILD_RUBY) |
|
492 |
endmacro(GET_RUBY_CONFIG) |
|
7768 | 493 |
|
494 |
GET_RUBY_CONFIG("archdir" RUBY_INCLUDE_PATH) |
|
495 |
GET_RUBY_CONFIG("CFLAGS" RUBY_CCFLAGS) |
|
496 |
GET_RUBY_CONFIG("LDFLAGS" RUBY_LDFLAGS) |
|
497 |
GET_RUBY_CONFIG("sitearchdir" RUBY_INSTALL_PATH) |
|
498 |
GET_RUBY_CONFIG("LIBRUBYARG_SHARED" RUBY_LIBRUBY) |
|
499 |
GET_RUBY_CONFIG("libdir" RUBY_LIBDIR) |
|
500 |
||
501 |
CONFIGURE_SWIG_BINDING(Ruby "${RUBY_INSTALL_PATH}" "" "\"-I${RUBY_INCLUDE_PATH}\" ${RUBY_CCFLAGS} -w" "\"-L${RUBY_LIBDIR}\" ${RUBY_LIBRUBY} ${RUBY_LDFLAGS}") |
|
8146 | 502 |
set_target_properties(physfs-ruby PROPERTIES PREFIX "") |
503 |
install( |
|
7768 | 504 |
FILES test/test_physfs.rb |
505 |
DESTINATION bin |
|
506 |
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE |
|
507 |
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
|
508 |
) |
|
8146 | 509 |
endif(PHYSFS_BUILD_RUBY) |
7768 | 510 |
|
511 |
||
8084 | 512 |
#INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS} |
513 |
# RUNTIME DESTINATION bin |
|
514 |
# LIBRARY DESTINATION lib${LIB_SUFFIX} |
|
515 |
# ARCHIVE DESTINATION lib${LIB_SUFFIX}) |
|
516 |
#INSTALL(FILES src/physfs.h DESTINATION include) |
|
7768 | 517 |
|
8146 | 518 |
if(UNIX) |
519 |
set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz") |
|
520 |
add_custom_target( |
|
7768 | 521 |
dist |
522 |
hg archive -t tgz "${PHYSFS_TARBALL}" |
|
523 |
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
|
524 |
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..." |
|
525 |
) |
|
7778 | 526 |
# ADD_CUSTOM_TARGET( |
527 |
# uninstall |
|
528 |
# "${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh" |
|
529 |
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" |
|
530 |
# COMMENT "Uninstall the project..." |
|
531 |
# ) |
|
8146 | 532 |
endif(UNIX) |
7768 | 533 |
|
8146 | 534 |
macro(MESSAGE_BOOL_OPTION _NAME _VALUE) |
535 |
if(${_VALUE}) |
|
536 |
message(STATUS " ${_NAME}: enabled") |
|
537 |
else(${_VALUE}) |
|
538 |
message(STATUS " ${_NAME}: disabled") |
|
539 |
endif(${_VALUE}) |
|
540 |
endmacro(MESSAGE_BOOL_OPTION) |
|
7768 | 541 |
|
8146 | 542 |
message(STATUS "PhysicsFS will build with the following options:") |
7768 | 543 |
MESSAGE_BOOL_OPTION("ZIP support" PHYSFS_ARCHIVE_ZIP) |
544 |
MESSAGE_BOOL_OPTION("7zip support" PHYSFS_ARCHIVE_7Z) |
|
545 |
MESSAGE_BOOL_OPTION("GRP support" PHYSFS_ARCHIVE_GRP) |
|
546 |
MESSAGE_BOOL_OPTION("WAD support" PHYSFS_ARCHIVE_WAD) |
|
547 |
MESSAGE_BOOL_OPTION("HOG support" PHYSFS_ARCHIVE_HOG) |
|
548 |
MESSAGE_BOOL_OPTION("MVL support" PHYSFS_ARCHIVE_MVL) |
|
549 |
MESSAGE_BOOL_OPTION("QPAK support" PHYSFS_ARCHIVE_QPAK) |
|
550 |
MESSAGE_BOOL_OPTION("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT) |
|
551 |
MESSAGE_BOOL_OPTION("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT) |
|
552 |
MESSAGE_BOOL_OPTION("Build static library" PHYSFS_BUILD_STATIC) |
|
553 |
MESSAGE_BOOL_OPTION("Build shared library" PHYSFS_BUILD_SHARED) |
|
554 |
MESSAGE_BOOL_OPTION("Build Perl bindings" PHYSFS_BUILD_PERL) |
|
555 |
MESSAGE_BOOL_OPTION("Build Ruby bindings" PHYSFS_BUILD_RUBY) |
|
556 |
MESSAGE_BOOL_OPTION("Build stdio test program" PHYSFS_BUILD_TEST) |
|
8146 | 557 |
if(PHYSFS_BUILD_TEST) |
7768 | 558 |
MESSAGE_BOOL_OPTION(" Use readline in test program" HAVE_SYSTEM_READLINE) |
8146 | 559 |
endif(PHYSFS_BUILD_TEST) |
7768 | 560 |
|
561 |
# end of CMakeLists.txt ... |
|
562 |