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