Skip to content

Latest commit

 

History

History
313 lines (267 loc) · 10.8 KB

CMakeLists.txt

File metadata and controls

313 lines (267 loc) · 10.8 KB
 
Mar 10, 2007
Mar 10, 2007
1
2
# PhysicsFS; a portable, flexible file i/o abstraction.
#
Mar 11, 2007
Mar 11, 2007
3
# Please see the file LICENSE.txt in the source's root directory.
Mar 10, 2007
Mar 10, 2007
4
Jul 12, 2017
Jul 12, 2017
5
6
7
8
9
10
11
# The CMake project file is meant to get this compiling on all sorts of
# platforms quickly, and serve as the way Unix platforms and Linux distros
# package up official builds, but you don't _need_ to use this; we have
# built PhysicsFS to (hopefully) be able to drop into your project and
# compile, using preprocessor checks for platform-specific bits instead of
# testing in here.
May 21, 2019
May 21, 2019
12
cmake_minimum_required(VERSION 2.8.12)
Mar 11, 2007
Mar 11, 2007
13
Oct 23, 2012
Oct 23, 2012
14
project(PhysicsFS)
Mar 8, 2018
Mar 8, 2018
15
set(PHYSFS_VERSION 3.1.0)
Mar 23, 2009
Mar 23, 2009
16
17
# Increment this if/when we break backwards compatibility.
Oct 23, 2012
Oct 23, 2012
18
set(PHYSFS_SOVERSION 1)
Mar 10, 2007
Mar 10, 2007
19
20
# I hate that they define "WIN32" ... we're about to move to Win64...I hope!
Oct 23, 2012
Oct 23, 2012
21
22
23
if(WIN32 AND NOT WINDOWS)
set(WINDOWS TRUE)
endif()
Mar 10, 2007
Mar 10, 2007
24
Oct 23, 2012
Oct 23, 2012
25
include_directories(./src)
Mar 10, 2007
Mar 10, 2007
26
Jul 12, 2017
Jul 12, 2017
27
if(APPLE)
Aug 8, 2017
Aug 8, 2017
28
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit -framework Foundation")
Aug 8, 2017
Aug 8, 2017
29
set(PHYSFS_M_SRCS src/physfs_platform_apple.m)
Oct 23, 2012
Oct 23, 2012
30
endif()
Mar 10, 2007
Mar 10, 2007
31
Oct 23, 2012
Oct 23, 2012
32
if(CMAKE_COMPILER_IS_GNUCC)
Feb 3, 2010
Feb 3, 2010
33
# Don't use -rpath.
Oct 23, 2012
Oct 23, 2012
34
35
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
endif()
Mar 10, 2007
Mar 10, 2007
36
Oct 23, 2012
Oct 23, 2012
37
38
39
40
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
add_definitions(-xldscope=hidden)
endif()
Apr 13, 2009
Apr 13, 2009
41
Jul 12, 2017
Jul 12, 2017
42
if(HAIKU)
Mar 11, 2007
Mar 11, 2007
43
# We add this explicitly, since we don't want CMake to think this
Jul 12, 2017
Jul 12, 2017
44
# is a C++ project unless we're on Haiku.
Jul 24, 2017
Jul 24, 2017
45
set(PHYSFS_CPP_SRCS src/physfs_platform_haiku.cpp)
Oct 23, 2012
Oct 23, 2012
46
47
48
49
find_library(BE_LIBRARY be)
find_library(ROOT_LIBRARY root)
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
endif()
Mar 11, 2007
Mar 11, 2007
50
Jul 24, 2017
Jul 24, 2017
51
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
Jul 25, 2017
Jul 25, 2017
52
53
54
55
set(WINRT TRUE)
endif()
if(WINRT)
Jul 24, 2017
Jul 24, 2017
56
57
58
set(PHYSFS_CPP_SRCS src/physfs_platform_winrt.cpp)
endif()
Jul 12, 2017
Jul 12, 2017
59
60
61
62
63
64
65
if(UNIX AND NOT WINDOWS AND NOT APPLE) # (MingW and such might be UNIX _and_ WINDOWS!)
find_library(PTHREAD_LIBRARY pthread)
if(PTHREAD_LIBRARY)
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${PTHREAD_LIBRARY})
endif()
endif()
Mar 11, 2007
Mar 11, 2007
66
67
68
69
# Almost everything is "compiled" here, but things that don't apply to the
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
# another project or bring up a new build system: just compile all the source
# code and #define the things you want.
Oct 23, 2012
Oct 23, 2012
70
set(PHYSFS_SRCS
Mar 27, 2009
Mar 27, 2009
71
72
73
src/physfs.c
src/physfs_byteorder.c
src/physfs_unicode.c
Jul 22, 2017
Jul 22, 2017
74
75
76
77
src/physfs_platform_posix.c
src/physfs_platform_unix.c
src/physfs_platform_windows.c
src/physfs_platform_os2.c
Aug 17, 2017
Aug 17, 2017
78
src/physfs_platform_qnx.c
Jun 12, 2020
Jun 12, 2020
79
src/physfs_platform_android.c
Jul 22, 2017
Jul 22, 2017
80
81
82
83
84
85
86
87
88
89
90
91
src/physfs_archiver_dir.c
src/physfs_archiver_unpacked.c
src/physfs_archiver_grp.c
src/physfs_archiver_hog.c
src/physfs_archiver_7z.c
src/physfs_archiver_mvl.c
src/physfs_archiver_qpak.c
src/physfs_archiver_wad.c
src/physfs_archiver_zip.c
src/physfs_archiver_slb.c
src/physfs_archiver_iso9660.c
src/physfs_archiver_vdf.c
Jul 24, 2017
Jul 24, 2017
92
${PHYSFS_CPP_SRCS}
Aug 8, 2017
Aug 8, 2017
93
${PHYSFS_M_SRCS}
Mar 10, 2007
Mar 10, 2007
94
95
96
97
)
# Archivers ...
Jul 11, 2017
Jul 11, 2017
98
99
# These are (mostly) on by default now, so these options are only useful for
# disabling them.
Mar 10, 2007
Mar 10, 2007
100
Oct 23, 2012
Oct 23, 2012
101
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
Jul 11, 2017
Jul 11, 2017
102
103
if(NOT PHYSFS_ARCHIVE_ZIP)
add_definitions(-DPHYSFS_SUPPORTS_ZIP=0)
Oct 23, 2012
Oct 23, 2012
104
endif()
Mar 10, 2007
Mar 10, 2007
105
Oct 23, 2012
Oct 23, 2012
106
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" TRUE)
Jul 17, 2017
Jul 17, 2017
107
if(NOT PHYSFS_ARCHIVE_7Z)
Jul 11, 2017
Jul 11, 2017
108
add_definitions(-DPHYSFS_SUPPORTS_7Z=0)
Oct 23, 2012
Oct 23, 2012
109
110
111
endif()
option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
Jul 11, 2017
Jul 11, 2017
112
113
if(NOT PHYSFS_ARCHIVE_GRP)
add_definitions(-DPHYSFS_SUPPORTS_GRP=0)
Oct 23, 2012
Oct 23, 2012
114
115
116
endif()
option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
Jul 11, 2017
Jul 11, 2017
117
118
if(NOT PHYSFS_ARCHIVE_WAD)
add_definitions(-DPHYSFS_SUPPORTS_WAD=0)
Oct 23, 2012
Oct 23, 2012
119
120
121
endif()
option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
Jul 11, 2017
Jul 11, 2017
122
123
if(NOT PHYSFS_ARCHIVE_HOG)
add_definitions(-DPHYSFS_SUPPORTS_HOG=0)
Oct 23, 2012
Oct 23, 2012
124
125
126
endif()
option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
Jul 11, 2017
Jul 11, 2017
127
128
if(NOT PHYSFS_ARCHIVE_MVL)
add_definitions(-DPHYSFS_SUPPORTS_MVL=0)
Oct 23, 2012
Oct 23, 2012
129
130
131
endif()
option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
Jul 11, 2017
Jul 11, 2017
132
133
if(NOT PHYSFS_ARCHIVE_QPAK)
add_definitions(-DPHYSFS_SUPPORTS_QPAK=0)
Oct 23, 2012
Oct 23, 2012
134
135
endif()
Nov 12, 2012
Nov 12, 2012
136
option(PHYSFS_ARCHIVE_SLB "Enable I-War / Independence War SLB support" TRUE)
Jul 11, 2017
Jul 11, 2017
137
138
if(NOT PHYSFS_ARCHIVE_SLB)
add_definitions(-DPHYSFS_SUPPORTS_SLB=0)
Nov 12, 2012
Nov 12, 2012
139
140
endif()
Oct 23, 2012
Oct 23, 2012
141
option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
Jul 11, 2017
Jul 11, 2017
142
143
if(NOT PHYSFS_ARCHIVE_ISO9660)
add_definitions(-DPHYSFS_SUPPORTS_ISO9660=0)
Oct 23, 2012
Oct 23, 2012
144
145
endif()
Jun 20, 2017
Jun 20, 2017
146
option(PHYSFS_ARCHIVE_VDF "Enable Gothic I/II VDF archive support" TRUE)
Jul 11, 2017
Jul 11, 2017
147
148
if(NOT PHYSFS_ARCHIVE_VDF)
add_definitions(-DPHYSFS_SUPPORTS_VDF=0)
Jun 20, 2017
Jun 20, 2017
149
150
endif()
Oct 23, 2012
Oct 23, 2012
151
152
153
154
option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
if(PHYSFS_BUILD_STATIC)
add_library(physfs-static STATIC ${PHYSFS_SRCS})
Jul 11, 2017
Jul 11, 2017
155
156
157
158
# Don't rename this on Windows, since DLLs will also produce an import
# library named "physfs.lib" which would conflict; Unix tend to like the
# same library name with a different extension for static libs, but
# Windows can just have a separate name.
Jul 17, 2017
Jul 17, 2017
159
if(NOT MSVC)
Jul 11, 2017
Jul 11, 2017
160
161
set_target_properties(physfs-static PROPERTIES OUTPUT_NAME "physfs")
endif()
Jul 25, 2017
Jul 25, 2017
162
if(WINRT)
Jul 26, 2017
Jul 26, 2017
163
# Ignore LNK4264 warnings; we don't author any WinRT components, just consume them, so we're okay in a static library.
Jul 25, 2017
Jul 25, 2017
164
set_target_properties(physfs-static PROPERTIES VS_WINRT_COMPONENT True)
Jul 26, 2017
Jul 26, 2017
165
set_target_properties(physfs-static PROPERTIES STATIC_LIBRARY_FLAGS "/ignore:4264")
Jul 25, 2017
Jul 25, 2017
166
167
endif()
Oct 23, 2012
Oct 23, 2012
168
169
170
171
172
173
174
set(PHYSFS_LIB_TARGET physfs-static)
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs-static")
endif()
option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
if(PHYSFS_BUILD_SHARED)
add_library(physfs SHARED ${PHYSFS_SRCS})
Aug 8, 2017
Aug 8, 2017
175
set_target_properties(physfs PROPERTIES MACOSX_RPATH 1)
Oct 23, 2012
Oct 23, 2012
176
177
set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
Jul 25, 2017
Jul 25, 2017
178
179
180
if(WINRT)
set_target_properties(physfs PROPERTIES VS_WINRT_COMPONENT True)
endif()
Oct 23, 2012
Oct 23, 2012
181
182
183
184
185
186
187
188
target_link_libraries(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
set(PHYSFS_LIB_TARGET physfs)
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
endif()
if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
message(FATAL "Both shared and static libraries are disabled!")
endif()
Mar 11, 2007
Mar 11, 2007
189
190
# CMake FAQ says I need this...
Jul 11, 2017
Jul 11, 2017
191
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC AND NOT WINDOWS)
Oct 23, 2012
Oct 23, 2012
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(physfs-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
option(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
mark_as_advanced(PHYSFS_BUILD_TEST)
if(PHYSFS_BUILD_TEST)
find_path(READLINE_H readline/readline.h)
find_path(HISTORY_H readline/history.h)
if(READLINE_H AND HISTORY_H)
find_library(CURSES_LIBRARY NAMES curses ncurses)
set(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
find_library(READLINE_LIBRARY readline)
if(READLINE_LIBRARY)
set(HAVE_SYSTEM_READLINE TRUE)
set(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
Sep 25, 2017
Sep 25, 2017
208
include_directories(SYSTEM ${READLINE_H} ${HISTORY_H})
Oct 23, 2012
Oct 23, 2012
209
210
211
212
213
214
215
add_definitions(-DPHYSFS_HAVE_READLINE=1)
endif()
endif()
add_executable(test_physfs test/test_physfs.c)
target_link_libraries(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
endif()
Mar 10, 2007
Mar 10, 2007
216
Apr 19, 2019
Apr 19, 2019
217
install(TARGETS ${PHYSFS_INSTALL_TARGETS} EXPORT PhysFSExport
Mar 11, 2007
Mar 11, 2007
218
RUNTIME DESTINATION bin
Feb 17, 2011
Feb 17, 2011
219
LIBRARY DESTINATION lib${LIB_SUFFIX}
Apr 19, 2019
Apr 19, 2019
220
221
ARCHIVE DESTINATION lib${LIB_SUFFIX}
INCLUDES DESTINATION include)
Oct 23, 2012
Oct 23, 2012
222
install(FILES src/physfs.h DESTINATION include)
Mar 11, 2007
Mar 11, 2007
223
Apr 19, 2019
Apr 19, 2019
224
225
226
227
228
229
install(EXPORT PhysFSExport
DESTINATION "lib${LIB_SUFFIX}/cmake/PhysFS"
FILE PhysFSConfig.cmake
)
Oct 23, 2012
Oct 23, 2012
230
231
232
233
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
configure_file(
Feb 22, 2011
Feb 22, 2011
234
"${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
Feb 22, 2011
Feb 22, 2011
235
236
237
"${PHYSFS_OUTPUT_DOXYFILE}"
COPYONLY
)
Oct 23, 2012
Oct 23, 2012
238
239
240
241
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${PHYSFS_VERSION}\"\n")
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n")
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
Feb 22, 2011
Feb 22, 2011
242
Feb 10, 2019
Feb 10, 2019
243
set(PHYSFS_TARGETNAME_DOCS "docs" CACHE STRING "Name of 'docs' build target")
Oct 23, 2012
Oct 23, 2012
244
add_custom_target(
Feb 10, 2019
Feb 10, 2019
245
${PHYSFS_TARGETNAME_DOCS}
Feb 22, 2011
Feb 22, 2011
246
247
248
249
${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building documentation in 'docs' directory..."
)
Oct 23, 2012
Oct 23, 2012
250
251
252
else()
message(STATUS "Doxygen not found. You won't be able to build documentation.")
endif()
Mar 10, 2007
Mar 10, 2007
253
Oct 23, 2012
Oct 23, 2012
254
if(UNIX)
Oct 23, 2012
Oct 23, 2012
255
set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.bz2")
Feb 10, 2019
Feb 10, 2019
256
257
set(PHYSFS_TARGETNAME_DIST "dist" CACHE STRING "Name of 'dist' build target")
Oct 23, 2012
Oct 23, 2012
258
add_custom_target(
Feb 10, 2019
Feb 10, 2019
259
${PHYSFS_TARGETNAME_DIST}
Oct 23, 2012
Oct 23, 2012
260
hg archive -t tbz2 "${PHYSFS_TARBALL}"
Feb 3, 2010
Feb 3, 2010
261
262
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
Feb 3, 2010
Feb 3, 2010
263
)
Feb 10, 2019
Feb 10, 2019
264
265
set(PHYSFS_TARGETNAME_UNINSTALL "uninstall" CACHE STRING "Name of 'uninstall' build target")
Oct 23, 2012
Oct 23, 2012
266
add_custom_target(
Feb 10, 2019
Feb 10, 2019
267
${PHYSFS_TARGETNAME_UNINSTALL}
Feb 3, 2010
Feb 3, 2010
268
269
270
271
"${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Uninstall the project..."
)
Oct 23, 2012
Oct 23, 2012
272
273
endif()
Jul 17, 2017
Jul 17, 2017
274
if(NOT MSVC)
Nov 13, 2013
Nov 13, 2013
275
276
277
278
279
280
281
configure_file(
"extras/physfs.pc.in"
"extras/physfs.pc"
@ONLY
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
Sep 27, 2017
Sep 27, 2017
282
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
Nov 13, 2013
Nov 13, 2013
283
284
285
)
endif()
Oct 23, 2012
Oct 23, 2012
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
macro(message_bool_option _NAME _VALUE)
if(${_VALUE})
message(STATUS " ${_NAME}: enabled")
else()
message(STATUS " ${_NAME}: disabled")
endif()
endmacro()
message(STATUS "PhysicsFS will build with the following options:")
message_bool_option("ZIP support" PHYSFS_ARCHIVE_ZIP)
message_bool_option("7zip support" PHYSFS_ARCHIVE_7Z)
message_bool_option("GRP support" PHYSFS_ARCHIVE_GRP)
message_bool_option("WAD support" PHYSFS_ARCHIVE_WAD)
message_bool_option("HOG support" PHYSFS_ARCHIVE_HOG)
message_bool_option("MVL support" PHYSFS_ARCHIVE_MVL)
message_bool_option("QPAK support" PHYSFS_ARCHIVE_QPAK)
Nov 12, 2012
Nov 12, 2012
302
message_bool_option("SLB support" PHYSFS_ARCHIVE_SLB)
Jul 11, 2017
Jul 11, 2017
303
304
message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF)
message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
Oct 23, 2012
Oct 23, 2012
305
306
307
308
309
310
message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST)
if(PHYSFS_BUILD_TEST)
message_bool_option(" Use readline in test program" HAVE_SYSTEM_READLINE)
endif()
Mar 10, 2007
Mar 10, 2007
311
312
# end of CMakeLists.txt ...