author | koda |
Mon, 17 Jun 2013 16:56:58 +0200 | |
branch | webgl |
changeset 9197 | e4e366013e9a |
parent 9160 | fc46e75f6b72 |
parent 9185 | 115e7daa4796 |
child 9236 | ddd675825672 |
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 |
||
8360 | 6 |
## lines starting with '##' are lines overridden/modified/added by Hedgewars configuration |
7 |
##CMAKE_MINIMUM_REQUIRED(VERSION 2.4) |
|
8 |
##PROJECT(PhysicsFS) |
|
9 |
set(PHYSFS_VERSION 2.1.0) |
|
7768 | 10 |
|
11 |
# Increment this if/when we break backwards compatibility. |
|
8360 | 12 |
set(PHYSFS_SOVERSION 1) |
7768 | 13 |
|
14 |
# I hate that they define "WIN32" ... we're about to move to Win64...I hope! |
|
8360 | 15 |
if(WIN32 AND NOT WINDOWS) |
16 |
set(WINDOWS TRUE) |
|
17 |
endif(WIN32 AND NOT WINDOWS) |
|
8286 | 18 |
|
7768 | 19 |
# Bleh, let's do it for "APPLE" too. |
8360 | 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. |
|
8360 | 25 |
if(HAIKU AND NOT BEOS) |
26 |
set(BEOS TRUE) |
|
27 |
endif(HAIKU AND NOT BEOS) |
|
7768 | 28 |
|
8360 | 29 |
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
30 |
set(SOLARIS TRUE) |
|
31 |
endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
|
7768 | 32 |
|
8360 | 33 |
include(CheckIncludeFile) |
34 |
include(CheckLibraryExists) |
|
35 |
include(CheckCSourceCompiles) |
|
7768 | 36 |
|
37 |
||
9117 | 38 |
# 32bit platforms won't link unless this is set |
39 |
# although Windows doesn't like it |
|
40 |
if(NOT WINDOWS) |
|
41 |
if(CMAKE_SIZEOF_VOID_P LESS 8) |
|
42 |
add_definitions(-DPHYSFS_NO_64BIT_SUPPORT=1) |
|
43 |
endif(CMAKE_SIZEOF_VOID_P LESS 8) |
|
44 |
endif(NOT WINDOWS) |
|
45 |
||
46 |
||
8360 | 47 |
if(MACOSX) |
7768 | 48 |
# Fallback to older OS X on PowerPC to support wider range of systems... |
8360 | 49 |
if(CMAKE_OSX_ARCHITECTURES MATCHES ppc) |
50 |
add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020) |
|
9185 | 51 |
list(APPEND OTHER_LDFLAGS "-mmacosx-version-min=10.2") |
8360 | 52 |
endif(CMAKE_OSX_ARCHITECTURES MATCHES ppc) |
7768 | 53 |
|
54 |
# Need these everywhere... |
|
8360 | 55 |
add_definitions(-fno-common) |
9185 | 56 |
find_library(foundation_framework NAMES Foundation) |
57 |
list(APPEND OTHER_LDFLAGS ${foundation_framework}) |
|
8360 | 58 |
find_library(iokit_framework NAMES IOKit) |
59 |
list(APPEND OTHER_LDFLAGS ${iokit_framework}) |
|
60 |
endif(MACOSX) |
|
7768 | 61 |
|
62 |
# Add some gcc-specific command lines. |
|
8360 | 63 |
if(CMAKE_COMPILER_IS_GNUCC) |
7768 | 64 |
# Always build with debug symbols...you can strip it later. |
9158
b4d8baf4669a
this was getting annoying, don't error out on warnings physfs
koda
parents:
9117
diff
changeset
|
65 |
add_definitions(-g -fsigned-char) |
7768 | 66 |
|
67 |
# Stupid BeOS generates warnings in the system headers. |
|
8360 | 68 |
if(NOT BEOS) |
69 |
add_definitions(-Wall) |
|
70 |
endif(NOT BEOS) |
|
7768 | 71 |
|
72 |
CHECK_C_SOURCE_COMPILES(" |
|
73 |
#if ((defined(__GNUC__)) && (__GNUC__ >= 4)) |
|
74 |
int main(int argc, char **argv) { int is_gcc4 = 1; return 0; } |
|
75 |
#else |
|
76 |
#error This is not gcc4. |
|
77 |
#endif |
|
78 |
" PHYSFS_IS_GCC4) |
|
79 |
||
8360 | 80 |
if(PHYSFS_IS_GCC4) |
7768 | 81 |
# Not supported on several operating systems at this time. |
8360 | 82 |
if(NOT SOLARIS AND NOT WINDOWS) |
83 |
add_definitions(-fvisibility=hidden) |
|
84 |
endif(NOT SOLARIS AND NOT WINDOWS) |
|
85 |
endif(PHYSFS_IS_GCC4) |
|
7768 | 86 |
|
87 |
# Don't use -rpath. |
|
8360 | 88 |
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) |
89 |
endif(CMAKE_COMPILER_IS_GNUCC) |
|
7768 | 90 |
|
8360 | 91 |
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro") |
92 |
add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT) |
|
93 |
add_definitions(-xldscope=hidden) |
|
94 |
endif(CMAKE_C_COMPILER_ID STREQUAL "SunPro") |
|
7768 | 95 |
|
8360 | 96 |
if(MSVC) |
7768 | 97 |
# VS.NET 8.0 got really really anal about strcpy, etc, which even if we |
98 |
# cleaned up our code, zlib, etc still use...so disable the warning. |
|
8360 | 99 |
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) |
100 |
endif(MSVC) |
|
101 |
||
7768 | 102 |
|
8360 | 103 |
if(BEOS) |
7768 | 104 |
# We add this explicitly, since we don't want CMake to think this |
105 |
# is a C++ project unless we're on BeOS. |
|
8360 | 106 |
set(PHYSFS_BEOS_SRCS src/platform_beos.cpp) |
107 |
find_library(BE_LIBRARY be) |
|
108 |
find_library(ROOT_LIBRARY root) |
|
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
109 |
set(optional_library_libs ${optional_library_libs} ${BE_LIBRARY} ${ROOT_LIBRARY}) |
8360 | 110 |
endif(BEOS) |
111 |
||
7768 | 112 |
|
113 |
# Almost everything is "compiled" here, but things that don't apply to the |
|
114 |
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into |
|
115 |
# another project or bring up a new build system: just compile all the source |
|
116 |
# code and #define the things you want. |
|
8360 | 117 |
set(PHYSFS_SRCS |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
118 |
physfs.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
119 |
physfs_byteorder.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
120 |
physfs_unicode.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
121 |
platform_posix.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
122 |
platform_unix.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
123 |
platform_macosx.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
124 |
platform_windows.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
125 |
archiver_dir.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
126 |
archiver_unpacked.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
127 |
archiver_grp.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
128 |
archiver_hog.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
129 |
archiver_lzma.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
130 |
archiver_mvl.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
131 |
archiver_qpak.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
132 |
archiver_wad.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
133 |
archiver_zip.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
134 |
archiver_iso9660.c |
7768 | 135 |
${PHYSFS_BEOS_SRCS} |
136 |
) |
|
137 |
||
138 |
||
139 |
# platform layers ... |
|
140 |
||
8360 | 141 |
if(UNIX) |
142 |
if(BEOS) |
|
143 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
144 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
145 |
set(HAVE_PTHREAD_H TRUE) |
|
146 |
else(BEOS) |
|
7768 | 147 |
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) |
8360 | 148 |
if(HAVE_UCRED_H) |
149 |
add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1) |
|
150 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
151 |
endif(HAVE_UCRED_H) |
|
7768 | 152 |
|
153 |
CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H) |
|
8360 | 154 |
if(HAVE_MNTENT_H) |
155 |
add_definitions(-DPHYSFS_HAVE_MNTENT_H=1) |
|
156 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
157 |
endif(HAVE_MNTENT_H) |
|
7768 | 158 |
|
159 |
# !!! FIXME: Solaris fails this, because mnttab.h implicitly |
|
160 |
# !!! FIXME: depends on other system headers. :( |
|
161 |
#CHECK_INCLUDE_FILE(sys/mnttab.h HAVE_SYS_MNTTAB_H) |
|
162 |
CHECK_C_SOURCE_COMPILES(" |
|
163 |
#include <stdio.h> |
|
164 |
#include <sys/mnttab.h> |
|
165 |
int main(int argc, char **argv) { return 0; } |
|
166 |
" HAVE_SYS_MNTTAB_H) |
|
167 |
||
8360 | 168 |
if(HAVE_SYS_MNTTAB_H) |
169 |
add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1) |
|
170 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
171 |
endif(HAVE_SYS_MNTTAB_H) |
|
7768 | 172 |
|
173 |
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) |
|
8360 | 174 |
if(HAVE_PTHREAD_H) |
175 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
176 |
endif(HAVE_PTHREAD_H) |
|
177 |
endif(BEOS) |
|
178 |
endif(UNIX) |
|
7768 | 179 |
|
8360 | 180 |
if(WINDOWS) |
181 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
182 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
183 |
endif(WINDOWS) |
|
7768 | 184 |
|
8360 | 185 |
if(NOT PHYSFS_HAVE_CDROM_SUPPORT) |
186 |
add_definitions(-DPHYSFS_NO_CDROM_SUPPORT=1) |
|
187 |
message(WARNING " ***") |
|
188 |
message(WARNING " *** There is no CD-ROM support in this build!") |
|
189 |
message(WARNING " *** PhysicsFS will just pretend there are no discs.") |
|
190 |
message(WARNING " *** This may be fine, depending on how PhysicsFS is used,") |
|
191 |
message(WARNING " *** but is this what you REALLY wanted?") |
|
192 |
message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)") |
|
193 |
message(WARNING " ***") |
|
194 |
endif(NOT PHYSFS_HAVE_CDROM_SUPPORT) |
|
7768 | 195 |
|
8360 | 196 |
if(PHYSFS_HAVE_THREAD_SUPPORT) |
197 |
add_definitions(-D_REENTRANT -D_THREAD_SAFE) |
|
198 |
else(PHYSFS_HAVE_THREAD_SUPPORT) |
|
199 |
add_definitions(-DPHYSFS_NO_THREAD_SUPPORT=1) |
|
200 |
message(WARNING " ***") |
|
201 |
message(WARNING " *** There is no thread support in this build!") |
|
202 |
message(WARNING " *** PhysicsFS will NOT be reentrant!") |
|
203 |
message(WARNING " *** This may be fine, depending on how PhysicsFS is used,") |
|
204 |
message(WARNING " *** but is this what you REALLY wanted?") |
|
205 |
message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)") |
|
206 |
message(WARNING " ***") |
|
207 |
endif(PHYSFS_HAVE_THREAD_SUPPORT) |
|
7768 | 208 |
|
209 |
||
210 |
# Archivers ... |
|
211 |
||
8360 | 212 |
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE) |
213 |
if(PHYSFS_ARCHIVE_ZIP) |
|
214 |
add_definitions(-DPHYSFS_SUPPORTS_ZIP=1) |
|
215 |
set(PHYSFS_FEATURES "ZIP") |
|
216 |
endif(PHYSFS_ARCHIVE_ZIP) |
|
7768 | 217 |
|
8542 | 218 |
#option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE) |
219 |
#if(PHYSFS_ARCHIVE_GRP) |
|
220 |
# add_definitions(-DPHYSFS_SUPPORTS_GRP=1) |
|
221 |
# set(PHYSFS_FEATURES "${PHYSFS_FEATURES} GRP") |
|
222 |
#endif(PHYSFS_ARCHIVE_GRP) |
|
7768 | 223 |
|
8542 | 224 |
#option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE) |
225 |
#if(PHYSFS_ARCHIVE_WAD) |
|
226 |
# add_definitions(-DPHYSFS_SUPPORTS_WAD=1) |
|
227 |
# set(PHYSFS_FEATURES "${PHYSFS_FEATURES} WAD") |
|
228 |
#endif(PHYSFS_ARCHIVE_WAD) |
|
7768 | 229 |
|
8542 | 230 |
#option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE) |
231 |
#if(PHYSFS_ARCHIVE_HOG) |
|
232 |
# add_definitions(-DPHYSFS_SUPPORTS_HOG=1) |
|
233 |
# set(PHYSFS_FEATURES "${PHYSFS_FEATURES} HOG") |
|
234 |
#endif(PHYSFS_ARCHIVE_HOG) |
|
7768 | 235 |
|
8542 | 236 |
#option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE) |
237 |
#if(PHYSFS_ARCHIVE_MVL) |
|
238 |
# add_definitions(-DPHYSFS_SUPPORTS_MVL=1) |
|
239 |
# set(PHYSFS_FEATURES "${PHYSFS_FEATURES} MVL") |
|
240 |
#endif(PHYSFS_ARCHIVE_MVL) |
|
7768 | 241 |
|
8542 | 242 |
#option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE) |
243 |
#if(PHYSFS_ARCHIVE_QPAK) |
|
244 |
# add_definitions(-DPHYSFS_SUPPORTS_QPAK=1) |
|
245 |
# set(PHYSFS_FEATURES "${PHYSFS_FEATURES} QPAK") |
|
246 |
#endif(PHYSFS_ARCHIVE_QPAK) |
|
7768 | 247 |
|
8542 | 248 |
#option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE) |
249 |
#if(PHYSFS_ARCHIVE_ISO9660) |
|
250 |
# add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1) |
|
251 |
# set(PHYSFS_FEATURES "${PHYSFS_FEATURES} CD-ROM") |
|
252 |
#endif(PHYSFS_ARCHIVE_ISO9660) |
|
7768 | 253 |
|
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
254 |
|
8360 | 255 |
##as needed by Hedgewars configuration |
256 |
if(WINDOWS) |
|
257 |
option(PHYSFS_BUILD_STATIC "Build static library" FALSE) |
|
258 |
option(PHYSFS_BUILD_SHARED "Build shared library" TRUE) |
|
259 |
list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY}) |
|
260 |
else(WINDOWS) |
|
261 |
option(PHYSFS_BUILD_STATIC "Build static library" TRUE) |
|
262 |
option(PHYSFS_BUILD_SHARED "Build shared library" FALSE) |
|
263 |
endif(WINDOWS) |
|
7768 | 264 |
|
8360 | 265 |
if(PHYSFS_BUILD_STATIC) |
266 |
add_library(physfs STATIC ${PHYSFS_SRCS}) |
|
8540
cf808329bb6f
this should hijack the linker name and always pick the bundled physfs when another version is already prsent
koda
parents:
8526
diff
changeset
|
267 |
set_target_properties(physfs PROPERTIES OUTPUT_NAME ${physfs_output_name}) ## |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
268 |
set(lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX}) ## |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
269 |
set(lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX}) ## |
8360 | 270 |
endif(PHYSFS_BUILD_STATIC) |
7768 | 271 |
|
8360 | 272 |
if(PHYSFS_BUILD_SHARED) |
273 |
add_library(physfs SHARED ${PHYSFS_SRCS}) |
|
274 |
set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION}) |
|
275 |
set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION}) |
|
8540
cf808329bb6f
this should hijack the linker name and always pick the bundled physfs when another version is already prsent
koda
parents:
8526
diff
changeset
|
276 |
set_target_properties(physfs PROPERTIES OUTPUT_NAME ${physfs_output_name}) ## |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
277 |
target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS}) |
8360 | 278 |
install(TARGETS physfs RUNTIME DESTINATION ${target_library_install_dir}) ## |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
279 |
set(lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX}) ## |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
280 |
set(lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) ## |
8360 | 281 |
endif(PHYSFS_BUILD_SHARED) |
282 |
||
283 |
if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) |
|
284 |
message(FATAL "Both shared and static libraries are disabled!") |
|
285 |
endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) |
|
7768 | 286 |
|
287 |
# CMake FAQ says I need this... |
|
8360 | 288 |
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC) |
289 |
set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
|
290 |
endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC) |
|
7768 | 291 |
|
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
292 |
## added standard variables emulating the FindPhysFS.cmake ones (FORCE or cmake won't pick 'em) |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
293 |
set(PHYSFS_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/libphysfs/ CACHE STRING "" FORCE) |
8540
cf808329bb6f
this should hijack the linker name and always pick the bundled physfs when another version is already prsent
koda
parents:
8526
diff
changeset
|
294 |
set(PHYSFS_LIBRARY ${LIBRARY_OUTPUT_PATH}/${lib_prefix}${physfs_output_name}${lib_suffix} CACHE STRING "" FORCE) |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
295 |
|
7768 | 296 |
|
8360 | 297 |
## removed install, language bindings and test program |
298 |
## simplified configuration output |
|
7768 | 299 |
|
8542 | 300 |
#message(STATUS "PhysFS will be built with ${PHYSFS_FEATURES} support") |
7768 | 301 |