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