author | koda |
Sat, 08 Dec 2012 15:35:03 +0100 | |
changeset 8270 | 16a52ad5a362 |
parent 8146 | 1fba650c2aa4 |
child 8208 | 171da01bd04d |
child 8281 | a1577759bf62 |
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 |
|
7768 | 144 |
${PHYSFS_BEOS_SRCS} |
145 |
) |
|
146 |
||
147 |
||
148 |
# platform layers ... |
|
149 |
||
8146 | 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) |
|
7768 | 156 |
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) |
8146 | 157 |
if(HAVE_UCRED_H) |
158 |
add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1) |
|
159 |
set(PHYSFS_HAVE_CDROM_SUPPORT false) |
|
160 |
endif(HAVE_UCRED_H) |
|
7768 | 161 |
|
162 |
CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H) |
|
8146 | 163 |
if(HAVE_MNTENT_H) |
164 |
add_definitions(-DPHYSFS_HAVE_MNTENT_H=1) |
|
165 |
set(PHYSFS_HAVE_CDROM_SUPPORT false) |
|
166 |
endif(HAVE_MNTENT_H) |
|
7768 | 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 |
||
8146 | 177 |
if(HAVE_SYS_MNTTAB_H) |
178 |
add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1) |
|
179 |
set(PHYSFS_HAVE_CDROM_SUPPORT false) |
|
180 |
endif(HAVE_SYS_MNTTAB_H) |
|
7768 | 181 |
|
182 |
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) |
|
8146 | 183 |
if(HAVE_PTHREAD_H) |
184 |
set(PHYSFS_HAVE_THREAD_SUPPORT false) |
|
185 |
endif(HAVE_PTHREAD_H) |
|
186 |
endif(BEOS) |
|
187 |
endif(UNIX) |
|
7768 | 188 |
|
8146 | 189 |
if(WINDOWS) |
190 |
set(PHYSFS_HAVE_CDROM_SUPPORT true) |
|
191 |
set(PHYSFS_HAVE_THREAD_SUPPORT true) |
|
192 |
endif(WINDOWS) |
|
7768 | 193 |
|
8146 | 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) |
|
7768 | 204 |
|
8146 | 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) |
|
7768 | 217 |
|
218 |
||
219 |
# Archivers ... |
|
220 |
||
8146 | 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) |
|
7768 | 225 |
|
8146 | 226 |
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" false) |
227 |
if(PHYSFS_ARCHIVE_7Z) |
|
228 |
add_definitions(-DPHYSFS_SUPPORTS_7Z=1) |
|
7768 | 229 |
# !!! FIXME: rename to 7z.c? |
8146 | 230 |
set(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS}) |
231 |
endif(PHYSFS_ARCHIVE_7Z) |
|
7768 | 232 |
|
8146 | 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) |
|
7768 | 237 |
|
8146 | 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) |
|
7768 | 242 |
|
8146 | 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) |
|
7768 | 247 |
|
8146 | 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) |
|
7768 | 252 |
|
8146 | 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) |
|
7768 | 257 |
|
8146 | 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) |
|
7768 | 262 |
|
8087
ccc99eebdac2
little cmake cleanup, search installed modules first, then our own
koda
parents:
8084
diff
changeset
|
263 |
#as needed by Hedgewars configuration |
8146 | 264 |
if(WINDOWS) |
265 |
option(PHYSFS_BUILD_STATIC "Build static library" false) |
|
266 |
option(PHYSFS_BUILD_SHARED "Build shared library" true) |
|
267 |
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} ${SDL_LIBRARY}) |
|
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 |
|
8146 | 273 |
if(PHYSFS_BUILD_STATIC) |
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") |
|
278 |
endif(PHYSFS_BUILD_STATIC) |
|
7768 | 279 |
|
8146 | 280 |
if(PHYSFS_BUILD_SHARED) |
8073 | 281 |
find_package(SDL REQUIRED) |
8146 | 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}) |
|
285 |
target_link_libraries(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS}) |
|
286 |
set(PHYSFS_LIB_TARGET physfs) |
|
287 |
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs") |
|
288 |
install(TARGETS ${PHYSFS_INSTALL_TARGETS} |
|
8101 | 289 |
RUNTIME DESTINATION bin) |
8146 | 290 |
endif(PHYSFS_BUILD_SHARED) |
7768 | 291 |
|
8146 | 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) |
|
7768 | 295 |
|
296 |
# CMake FAQ says I need this... |
|
8146 | 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) |
|
7768 | 300 |
|
8146 | 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) |
|
7768 | 321 |
|
322 |
||
323 |
# Scripting language bindings... |
|
324 |
||
325 |
#CMake's SWIG support is basically useless. |
|
326 |
#FIND_PACKAGE(SWIG) |
|
327 |
||
8146 | 328 |
option(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." false) |
329 |
mark_as_advanced(PHYSFS_BUILD_SWIG) |
|
7768 | 330 |
|
8146 | 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) |
|
7768 | 345 |
|
8146 | 346 |
set(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings") |
7768 | 347 |
|
8146 | 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}") |
|
7768 | 353 |
|
8146 | 354 |
if(NOT EXISTS "${_TARGETDIR}") |
355 |
file(MAKE_DIRECTORY "${_TARGETDIR}") |
|
356 |
endif(NOT EXISTS "${_TARGETDIR}") |
|
7768 | 357 |
|
8146 | 358 |
if(PHYSFS_BUILD_${_UPPERLANG}) |
359 |
add_custom_command( |
|
7768 | 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 |
||
8146 | 367 |
add_library(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c") |
368 |
target_link_libraries(${_TARGET} ${PHYSFS_LIB_TARGET}) |
|
369 |
set_target_properties(${_TARGET} PROPERTIES |
|
7768 | 370 |
COMPILE_FLAGS "${_EXTRACFLAGS}" |
371 |
LINK_FLAGS "${_EXTRALDFLAGS}" |
|
372 |
LIBRARY_OUTPUT_NAME "physfs" |
|
373 |
LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}" |
|
374 |
CLEAN_DIRECT_OUTPUT 1 |
|
375 |
) |
|
8146 | 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) |
|
7768 | 382 |
|
8146 | 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) |
|
7768 | 391 |
|
8146 | 392 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_PERL "Perl" true) |
393 |
ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_RUBY "Ruby" true) |
|
394 |
endif(NOT SWIG) |
|
7768 | 395 |
|
8146 | 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) |
|
7768 | 404 |
|
8146 | 405 |
macro(GET_PERL_CONFIG _KEY _VALUE) |
406 |
if(PHYSFS_BUILD_PERL) |
|
407 |
message(STATUS "Figuring out perl config value '${_KEY}' ...") |
|
408 |
execute_process( |
|
7768 | 409 |
COMMAND ${PERL} -w -e "use Config; print \$Config{${_KEY}};" |
410 |
RESULT_VARIABLE GET_PERL_CONFIG_RC |
|
411 |
OUTPUT_VARIABLE ${_VALUE} |
|
412 |
) |
|
8146 | 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}) |
|
7768 | 421 |
|
8146 | 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) |
|
7768 | 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. |
|
8146 | 435 |
if(MACOSX) |
7768 | 436 |
GET_PERL_CONFIG("libperl" PERL_LIBPERL) |
8146 | 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) |
|
7768 | 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}") |
|
8146 | 450 |
install(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}") |
451 |
install( |
|
7768 | 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 |
) |
|
8146 | 457 |
endif(PHYSFS_BUILD_PERL) |
7768 | 458 |
|
459 |
# !!! FIXME: lots of cut-and-paste from perl bindings. |
|
8146 | 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) |
|
7768 | 468 |
|
8146 | 469 |
macro(GET_RUBY_CONFIG _KEY _VALUE) |
470 |
if(PHYSFS_BUILD_RUBY) |
|
471 |
message(STATUS "Figuring out ruby config value '${_KEY}' ...") |
|
472 |
execute_process( |
|
7768 | 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 |
) |
|
8146 | 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}) |
|
7768 | 486 |
|
8146 | 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) |
|
7768 | 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}") |
|
8146 | 501 |
set_target_properties(physfs-ruby PROPERTIES PREFIX "") |
502 |
install( |
|
7768 | 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 |
) |
|
8146 | 508 |
endif(PHYSFS_BUILD_RUBY) |
7768 | 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 |
|
8146 | 517 |
if(UNIX) |
518 |
set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz") |
|
519 |
add_custom_target( |
|
7768 | 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 |
# ) |
|
8146 | 531 |
endif(UNIX) |
7768 | 532 |
|
8146 | 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) |
|
7768 | 540 |
|
8146 | 541 |
message(STATUS "PhysicsFS will build with the following options:") |
7768 | 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) |
|
8146 | 556 |
if(PHYSFS_BUILD_TEST) |
7768 | 557 |
MESSAGE_BOOL_OPTION(" Use readline in test program" HAVE_SYSTEM_READLINE) |
8146 | 558 |
endif(PHYSFS_BUILD_TEST) |
7768 | 559 |
|
560 |
# end of CMakeLists.txt ... |
|
561 |