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