author | koda |
Tue, 11 Jun 2013 18:31:49 +0200 | |
changeset 9194 | 1cc97a207598 |
parent 9192 | a8a717cf4a66 |
child 9196 | 89d98f970de9 |
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) |
|
77 |
endif(CMAKE_COMPILER_IS_GNUCC) |
|
7768 | 78 |
|
8360 | 79 |
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro") |
80 |
add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT) |
|
81 |
add_definitions(-xldscope=hidden) |
|
82 |
endif(CMAKE_C_COMPILER_ID STREQUAL "SunPro") |
|
7768 | 83 |
|
8360 | 84 |
if(MSVC) |
7768 | 85 |
# VS.NET 8.0 got really really anal about strcpy, etc, which even if we |
86 |
# cleaned up our code, zlib, etc still use...so disable the warning. |
|
8360 | 87 |
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) |
88 |
endif(MSVC) |
|
89 |
||
7768 | 90 |
|
8360 | 91 |
if(BEOS) |
7768 | 92 |
# We add this explicitly, since we don't want CMake to think this |
93 |
# is a C++ project unless we're on BeOS. |
|
8360 | 94 |
set(PHYSFS_BEOS_SRCS src/platform_beos.cpp) |
95 |
find_library(BE_LIBRARY be) |
|
96 |
find_library(ROOT_LIBRARY root) |
|
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
97 |
set(optional_library_libs ${optional_library_libs} ${BE_LIBRARY} ${ROOT_LIBRARY}) |
8360 | 98 |
endif(BEOS) |
99 |
||
7768 | 100 |
|
101 |
# Almost everything is "compiled" here, but things that don't apply to the |
|
102 |
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into |
|
103 |
# another project or bring up a new build system: just compile all the source |
|
104 |
# code and #define the things you want. |
|
8360 | 105 |
set(PHYSFS_SRCS |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
106 |
physfs.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
107 |
physfs_byteorder.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
108 |
physfs_unicode.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
109 |
platform_posix.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
110 |
platform_unix.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
111 |
platform_macosx.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
112 |
platform_windows.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
113 |
archiver_dir.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
114 |
archiver_unpacked.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
115 |
archiver_grp.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
116 |
archiver_hog.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
117 |
archiver_lzma.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
118 |
archiver_mvl.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
119 |
archiver_qpak.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
120 |
archiver_wad.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
121 |
archiver_zip.c |
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
122 |
archiver_iso9660.c |
7768 | 123 |
${PHYSFS_BEOS_SRCS} |
124 |
) |
|
125 |
||
126 |
||
127 |
# platform layers ... |
|
128 |
||
8360 | 129 |
if(UNIX) |
130 |
if(BEOS) |
|
131 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
132 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
133 |
set(HAVE_PTHREAD_H TRUE) |
|
134 |
else(BEOS) |
|
7768 | 135 |
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) |
8360 | 136 |
if(HAVE_UCRED_H) |
137 |
add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1) |
|
138 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
139 |
endif(HAVE_UCRED_H) |
|
7768 | 140 |
|
141 |
CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H) |
|
8360 | 142 |
if(HAVE_MNTENT_H) |
143 |
add_definitions(-DPHYSFS_HAVE_MNTENT_H=1) |
|
144 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
145 |
endif(HAVE_MNTENT_H) |
|
7768 | 146 |
|
147 |
# !!! FIXME: Solaris fails this, because mnttab.h implicitly |
|
148 |
# !!! FIXME: depends on other system headers. :( |
|
149 |
#CHECK_INCLUDE_FILE(sys/mnttab.h HAVE_SYS_MNTTAB_H) |
|
150 |
CHECK_C_SOURCE_COMPILES(" |
|
151 |
#include <stdio.h> |
|
152 |
#include <sys/mnttab.h> |
|
153 |
int main(int argc, char **argv) { return 0; } |
|
154 |
" HAVE_SYS_MNTTAB_H) |
|
155 |
||
8360 | 156 |
if(HAVE_SYS_MNTTAB_H) |
157 |
add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1) |
|
158 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
159 |
endif(HAVE_SYS_MNTTAB_H) |
|
7768 | 160 |
|
161 |
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) |
|
8360 | 162 |
if(HAVE_PTHREAD_H) |
163 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
164 |
endif(HAVE_PTHREAD_H) |
|
165 |
endif(BEOS) |
|
166 |
endif(UNIX) |
|
7768 | 167 |
|
8360 | 168 |
if(WINDOWS) |
169 |
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE) |
|
170 |
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE) |
|
9192
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
171 |
list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY}) |
8360 | 172 |
endif(WINDOWS) |
7768 | 173 |
|
8360 | 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) |
|
7768 | 184 |
|
8360 | 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) |
|
7768 | 197 |
|
198 |
||
199 |
# Archivers ... |
|
200 |
||
8360 | 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) |
|
7768 | 206 |
|
8542 | 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) |
|
7768 | 212 |
|
8542 | 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) |
|
7768 | 218 |
|
8542 | 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) |
|
7768 | 224 |
|
8542 | 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) |
|
7768 | 230 |
|
8542 | 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) |
|
7768 | 236 |
|
8542 | 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) |
|
7768 | 242 |
|
9192
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
243 |
##Hedgewars modifications |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
244 |
add_library(physfs ${PHYSFS_SRCS}) |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
245 |
set_target_properties(physfs PROPERTIES |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
246 |
VERSION ${PHYSFS_VERSION} |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
247 |
SOVERSION ${PHYSFS_SOVERSION} |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
248 |
OUTPUT_NAME ${physfs_output_name}) |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
249 |
target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS}) |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
250 |
install(TARGETS physfs RUNTIME DESTINATION ${target_binary_install_dir} |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
251 |
LIBRARY DESTINATION ${target_library_install_dir} |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
252 |
ARCHIVE DESTINATION ${target_library_install_dir}) |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
253 |
get_target_property(physfs_fullpath physfs LOCATION) |
7768 | 254 |
|
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
255 |
## added standard variables emulating the FindPhysFS.cmake ones (FORCE or cmake won't pick 'em) |
9192
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
256 |
set(PHYSFS_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/libphysfs/ CACHE STRING "Physfs include dir" FORCE) |
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
257 |
set(PHYSFS_LIBRARY ${physfs_fullpath} CACHE STRING "Physfs library path" FORCE) |
8526
9f2bd885d773
update cmake files to use the two libraries independently
koda
parents:
8522
diff
changeset
|
258 |
|
7768 | 259 |
|
9192
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
260 |
## removed language bindings and test program |
8360 | 261 |
## simplified configuration output |
9192
a8a717cf4a66
use BUILD_SHARED_LIBS to control whether a library is shared or static, make our bundled physfs library check for this configuration
koda
parents:
9188
diff
changeset
|
262 |
## merged shared and static library building |
7768 | 263 |
|
8542 | 264 |
#message(STATUS "PhysFS will be built with ${PHYSFS_FEATURES} support") |
7768 | 265 |