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