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 |
|
8360
|
37 |
## SDL is needed by extra
|
8288
|
38 |
find_package(SDL REQUIRED)
|
8360
|
39 |
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) ##
|
|
40 |
include_directories(${SDL_INCLUDE_DIR}) ##
|
|
41 |
include_directories(${LUA_INCLUDE_DIR}) ##
|
7768
|
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 |
|
|
97 |
# Basic chunks of source code ...
|
8360
|
98 |
set(LZMA_SRCS
|
7768
|
99 |
src/lzma/C/7zCrc.c
|
|
100 |
src/lzma/C/Archive/7z/7zBuffer.c
|
|
101 |
src/lzma/C/Archive/7z/7zDecode.c
|
|
102 |
src/lzma/C/Archive/7z/7zExtract.c
|
|
103 |
src/lzma/C/Archive/7z/7zHeader.c
|
|
104 |
src/lzma/C/Archive/7z/7zIn.c
|
|
105 |
src/lzma/C/Archive/7z/7zItem.c
|
|
106 |
src/lzma/C/Archive/7z/7zMethodID.c
|
|
107 |
src/lzma/C/Compress/Branch/BranchX86.c
|
|
108 |
src/lzma/C/Compress/Branch/BranchX86_2.c
|
|
109 |
src/lzma/C/Compress/Lzma/LzmaDecode.c
|
|
110 |
)
|
|
111 |
|
8360
|
112 |
if(BEOS)
|
7768
|
113 |
# We add this explicitly, since we don't want CMake to think this
|
|
114 |
# is a C++ project unless we're on BeOS.
|
8360
|
115 |
set(PHYSFS_BEOS_SRCS src/platform_beos.cpp)
|
|
116 |
find_library(BE_LIBRARY be)
|
|
117 |
find_library(ROOT_LIBRARY root)
|
|
118 |
set(optionAL_LIBRARY_LIBS ${optionAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
|
|
119 |
endif(BEOS)
|
|
120 |
|
|
121 |
## extra functions needed by Hedgewars
|
|
122 |
## TODO: maybe it's better to have them in a separate library?
|
|
123 |
set(PHYSFS_HEDGE_SRCS
|
|
124 |
extras/physfsrwops.c
|
|
125 |
extras/physfslualoader.c
|
|
126 |
extras/hwpacksmounter.c
|
|
127 |
)
|
7768
|
128 |
|
|
129 |
# Almost everything is "compiled" here, but things that don't apply to the
|
|
130 |
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
|
|
131 |
# another project or bring up a new build system: just compile all the source
|
|
132 |
# code and #define the things you want.
|
8360
|
133 |
set(PHYSFS_SRCS
|
7768
|
134 |
src/physfs.c
|
|
135 |
src/physfs_byteorder.c
|
|
136 |
src/physfs_unicode.c
|
|
137 |
src/platform_posix.c
|
|
138 |
src/platform_unix.c
|
|
139 |
src/platform_macosx.c
|
|
140 |
src/platform_windows.c
|
|
141 |
src/archiver_dir.c
|
|
142 |
src/archiver_unpacked.c
|
|
143 |
src/archiver_grp.c
|
|
144 |
src/archiver_hog.c
|
|
145 |
src/archiver_lzma.c
|
|
146 |
src/archiver_mvl.c
|
|
147 |
src/archiver_qpak.c
|
|
148 |
src/archiver_wad.c
|
|
149 |
src/archiver_zip.c
|
|
150 |
src/archiver_iso9660.c
|
|
151 |
${PHYSFS_BEOS_SRCS}
|
8360
|
152 |
${PHYSFS_HEDGE_SRCS} ##
|
7768
|
153 |
)
|
|
154 |
|
|
155 |
|
|
156 |
# platform layers ...
|
|
157 |
|
8360
|
158 |
if(UNIX)
|
|
159 |
if(BEOS)
|
|
160 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
161 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
|
162 |
set(HAVE_PTHREAD_H TRUE)
|
|
163 |
else(BEOS)
|
7768
|
164 |
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H)
|
8360
|
165 |
if(HAVE_UCRED_H)
|
|
166 |
add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1)
|
|
167 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
168 |
endif(HAVE_UCRED_H)
|
7768
|
169 |
|
|
170 |
CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H)
|
8360
|
171 |
if(HAVE_MNTENT_H)
|
|
172 |
add_definitions(-DPHYSFS_HAVE_MNTENT_H=1)
|
|
173 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
174 |
endif(HAVE_MNTENT_H)
|
7768
|
175 |
|
|
176 |
# !!! FIXME: Solaris fails this, because mnttab.h implicitly
|
|
177 |
# !!! FIXME: depends on other system headers. :(
|
|
178 |
#CHECK_INCLUDE_FILE(sys/mnttab.h HAVE_SYS_MNTTAB_H)
|
|
179 |
CHECK_C_SOURCE_COMPILES("
|
|
180 |
#include <stdio.h>
|
|
181 |
#include <sys/mnttab.h>
|
|
182 |
int main(int argc, char **argv) { return 0; }
|
|
183 |
" HAVE_SYS_MNTTAB_H)
|
|
184 |
|
8360
|
185 |
if(HAVE_SYS_MNTTAB_H)
|
|
186 |
add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1)
|
|
187 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
188 |
endif(HAVE_SYS_MNTTAB_H)
|
7768
|
189 |
|
|
190 |
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
8360
|
191 |
if(HAVE_PTHREAD_H)
|
|
192 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
|
193 |
endif(HAVE_PTHREAD_H)
|
|
194 |
endif(BEOS)
|
|
195 |
endif(UNIX)
|
7768
|
196 |
|
8360
|
197 |
if(WINDOWS)
|
|
198 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
199 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
|
200 |
endif(WINDOWS)
|
7768
|
201 |
|
8360
|
202 |
if(NOT PHYSFS_HAVE_CDROM_SUPPORT)
|
|
203 |
add_definitions(-DPHYSFS_NO_CDROM_SUPPORT=1)
|
|
204 |
message(WARNING " ***")
|
|
205 |
message(WARNING " *** There is no CD-ROM support in this build!")
|
|
206 |
message(WARNING " *** PhysicsFS will just pretend there are no discs.")
|
|
207 |
message(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
|
|
208 |
message(WARNING " *** but is this what you REALLY wanted?")
|
|
209 |
message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
|
|
210 |
message(WARNING " ***")
|
|
211 |
endif(NOT PHYSFS_HAVE_CDROM_SUPPORT)
|
7768
|
212 |
|
8360
|
213 |
if(PHYSFS_HAVE_THREAD_SUPPORT)
|
|
214 |
add_definitions(-D_REENTRANT -D_THREAD_SAFE)
|
|
215 |
else(PHYSFS_HAVE_THREAD_SUPPORT)
|
|
216 |
add_definitions(-DPHYSFS_NO_THREAD_SUPPORT=1)
|
|
217 |
message(WARNING " ***")
|
|
218 |
message(WARNING " *** There is no thread support in this build!")
|
|
219 |
message(WARNING " *** PhysicsFS will NOT be reentrant!")
|
|
220 |
message(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
|
|
221 |
message(WARNING " *** but is this what you REALLY wanted?")
|
|
222 |
message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
|
|
223 |
message(WARNING " ***")
|
|
224 |
endif(PHYSFS_HAVE_THREAD_SUPPORT)
|
7768
|
225 |
|
|
226 |
|
|
227 |
# Archivers ...
|
|
228 |
|
8360
|
229 |
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
|
|
230 |
if(PHYSFS_ARCHIVE_ZIP)
|
|
231 |
add_definitions(-DPHYSFS_SUPPORTS_ZIP=1)
|
|
232 |
set(PHYSFS_FEATURES "ZIP")
|
|
233 |
endif(PHYSFS_ARCHIVE_ZIP)
|
7768
|
234 |
|
8360
|
235 |
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" FALSE)
|
|
236 |
if(PHYSFS_ARCHIVE_7Z)
|
|
237 |
add_definitions(-DPHYSFS_SUPPORTS_7Z=1)
|
|
238 |
list(APPEND PHYSFS_SRCS ${LZMA_SRCS})
|
|
239 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} 7zip")
|
|
240 |
endif(PHYSFS_ARCHIVE_7Z)
|
7768
|
241 |
|
8360
|
242 |
option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
|
|
243 |
if(PHYSFS_ARCHIVE_GRP)
|
|
244 |
add_definitions(-DPHYSFS_SUPPORTS_GRP=1)
|
|
245 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} GRP")
|
|
246 |
endif(PHYSFS_ARCHIVE_GRP)
|
7768
|
247 |
|
8360
|
248 |
option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
|
|
249 |
if(PHYSFS_ARCHIVE_WAD)
|
|
250 |
add_definitions(-DPHYSFS_SUPPORTS_WAD=1)
|
|
251 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} WAD")
|
|
252 |
endif(PHYSFS_ARCHIVE_WAD)
|
7768
|
253 |
|
8360
|
254 |
option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
|
|
255 |
if(PHYSFS_ARCHIVE_HOG)
|
|
256 |
add_definitions(-DPHYSFS_SUPPORTS_HOG=1)
|
|
257 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} HOG")
|
|
258 |
endif(PHYSFS_ARCHIVE_HOG)
|
7768
|
259 |
|
8360
|
260 |
option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
|
|
261 |
if(PHYSFS_ARCHIVE_MVL)
|
|
262 |
add_definitions(-DPHYSFS_SUPPORTS_MVL=1)
|
|
263 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} MVL")
|
|
264 |
endif(PHYSFS_ARCHIVE_MVL)
|
7768
|
265 |
|
8360
|
266 |
option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
|
|
267 |
if(PHYSFS_ARCHIVE_QPAK)
|
|
268 |
add_definitions(-DPHYSFS_SUPPORTS_QPAK=1)
|
|
269 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} QPAK")
|
|
270 |
endif(PHYSFS_ARCHIVE_QPAK)
|
7768
|
271 |
|
8360
|
272 |
option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
|
|
273 |
if(PHYSFS_ARCHIVE_ISO9660)
|
|
274 |
add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
|
|
275 |
set(PHYSFS_FEATURES "${PHYSFS_FEATURES} CD-ROM")
|
|
276 |
endif(PHYSFS_ARCHIVE_ISO9660)
|
7768
|
277 |
|
8360
|
278 |
##as needed by Hedgewars configuration
|
|
279 |
if(WINDOWS)
|
|
280 |
option(PHYSFS_BUILD_STATIC "Build static library" FALSE)
|
|
281 |
option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
|
|
282 |
list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY})
|
|
283 |
else(WINDOWS)
|
|
284 |
option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
|
|
285 |
option(PHYSFS_BUILD_SHARED "Build shared library" FALSE)
|
|
286 |
endif(WINDOWS)
|
7768
|
287 |
|
8360
|
288 |
if(PHYSFS_BUILD_STATIC)
|
|
289 |
add_library(physfs STATIC ${PHYSFS_SRCS})
|
|
290 |
set_target_properties(physfs PROPERTIES OUTPUT_NAME "physfs")
|
|
291 |
endif(PHYSFS_BUILD_STATIC)
|
7768
|
292 |
|
8360
|
293 |
if(PHYSFS_BUILD_SHARED)
|
|
294 |
add_library(physfs SHARED ${PHYSFS_SRCS})
|
|
295 |
set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
|
|
296 |
set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
|
|
297 |
target_link_libraries(physfs ${optionAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
|
|
298 |
install(TARGETS physfs RUNTIME DESTINATION ${target_library_install_dir}) ##
|
|
299 |
endif(PHYSFS_BUILD_SHARED)
|
|
300 |
|
|
301 |
if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
|
|
302 |
message(FATAL "Both shared and static libraries are disabled!")
|
|
303 |
endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
|
7768
|
304 |
|
|
305 |
# CMake FAQ says I need this...
|
8360
|
306 |
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
|
307 |
set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
|
308 |
endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
7768
|
309 |
|
|
310 |
|
8360
|
311 |
## removed install, language bindings and test program
|
|
312 |
## simplified configuration output
|
7768
|
313 |
|
8360
|
314 |
message(STATUS "PhysicsFS will build with ${PHYSFS_FEATURES} support")
|
7768
|
315 |
|