# PhysicsFS; a portable, flexible file i/o abstraction.
#
# Please see the file LICENSE.txt in the source's root directory.
# 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.
set(PHYSFS_VERSION 3.0.2
)
# Increment this if/when we break backwards compatibility.
# I hate that they define "WIN32" ... we're about to move to Win64...I hope!
if(WIN32
AND NOT WINDOWS
)
set(OTHER_LDFLAGS
${OTHER_LDFLAGS} "-framework IOKit -framework Foundation")
set(PHYSFS_M_SRCS src/physfs_platform_apple.m
)
if(CMAKE_COMPILER_IS_GNUCC
)
# Don't use -rpath.
set(CMAKE_SKIP_RPATH
ON CACHE BOOL "Skip RPATH" FORCE)
if(CMAKE_C_COMPILER_ID
STREQUAL "SunPro")
# We add this explicitly, since we don't want CMake to think this
# is a C++ project unless we're on Haiku.
set(PHYSFS_CPP_SRCS src/physfs_platform_haiku.cpp
)
set(OPTIONAL_LIBRARY_LIBS
${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
if(CMAKE_SYSTEM_NAME
STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME
STREQUAL "WindowsStore")
set(PHYSFS_CPP_SRCS src/physfs_platform_winrt.cpp
)
if(UNIX
AND NOT WINDOWS
AND NOT APPLE
) # (MingW and such might be UNIX _and_ WINDOWS!)
set(OPTIONAL_LIBRARY_LIBS
${OPTIONAL_LIBRARY_LIBS} ${PTHREAD_LIBRARY})
# 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.
src/physfs.c
src/physfs_byteorder.c
src/physfs_unicode.c
src/physfs_platform_posix.c
src/physfs_platform_unix.c
src/physfs_platform_windows.c
src/physfs_platform_os2.c
src/physfs_platform_qnx.c
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
${PHYSFS_CPP_SRCS}
${PHYSFS_M_SRCS}
)
# Archivers ...
# These are (mostly) on by default now, so these options are only useful for
# disabling them.
option(PHYSFS_ARCHIVE_ZIP
"Enable ZIP support" TRUE)
if(NOT PHYSFS_ARCHIVE_ZIP
)
option(PHYSFS_ARCHIVE_7Z
"Enable 7zip support" TRUE)
if(NOT PHYSFS_ARCHIVE_7Z
)
option(PHYSFS_ARCHIVE_GRP
"Enable Build Engine GRP support" TRUE)
if(NOT PHYSFS_ARCHIVE_GRP
)
option(PHYSFS_ARCHIVE_WAD
"Enable Doom WAD support" TRUE)
if(NOT PHYSFS_ARCHIVE_WAD
)
option(PHYSFS_ARCHIVE_HOG
"Enable Descent I/II HOG support" TRUE)
if(NOT PHYSFS_ARCHIVE_HOG
)
option(PHYSFS_ARCHIVE_MVL
"Enable Descent I/II MVL support" TRUE)
if(NOT PHYSFS_ARCHIVE_MVL
)
option(PHYSFS_ARCHIVE_QPAK
"Enable Quake I/II QPAK support" TRUE)
if(NOT PHYSFS_ARCHIVE_QPAK
)
option(PHYSFS_ARCHIVE_SLB
"Enable I-War / Independence War SLB support" TRUE)
if(NOT PHYSFS_ARCHIVE_SLB
)
option(PHYSFS_ARCHIVE_ISO9660
"Enable ISO9660 support" TRUE)
if(NOT PHYSFS_ARCHIVE_ISO9660
)
option(PHYSFS_ARCHIVE_VDF
"Enable Gothic I/II VDF archive support" TRUE)
if(NOT PHYSFS_ARCHIVE_VDF
)
option(PHYSFS_BUILD_STATIC
"Build static library" TRUE)
# 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.
# Ignore LNK4264 warnings; we don't author any WinRT components, just consume them, so we're okay in a static library.
set(PHYSFS_LIB_TARGET physfs-static
)
set(PHYSFS_INSTALL_TARGETS
${PHYSFS_INSTALL_TARGETS} ";physfs-static")
option(PHYSFS_BUILD_SHARED
"Build shared library" TRUE)
set(PHYSFS_LIB_TARGET physfs
)
set(PHYSFS_INSTALL_TARGETS
${PHYSFS_INSTALL_TARGETS} ";physfs")
if(NOT PHYSFS_BUILD_SHARED
AND NOT PHYSFS_BUILD_STATIC
)
message(FATAL
"Both shared and static libraries are disabled!")
# CMake FAQ says I need this...
if(PHYSFS_BUILD_SHARED
AND PHYSFS_BUILD_STATIC
AND NOT WINDOWS
)
option(PHYSFS_BUILD_TEST
"Build stdio test program." TRUE)
if(READLINE_H
AND HISTORY_H
)
set(CMAKE_REQUIRED_LIBRARIES
${CURSES_LIBRARY})
set(HAVE_SYSTEM_READLINE
TRUE)
set(TEST_PHYSFS_LIBS
${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
set(PHYSFS_INSTALL_TARGETS
${PHYSFS_INSTALL_TARGETS} ";test_physfs")
install(TARGETS
${PHYSFS_INSTALL_TARGETS}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
install(FILES src/physfs.h DESTINATION include
)
set(PHYSFS_OUTPUT_DOXYFILE
"${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
"${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
"${PHYSFS_OUTPUT_DOXYFILE}"
COPYONLY
)
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")
set(PHYSFS_TARGETNAME_DOCS
"docs" CACHE STRING "Name of 'docs' build target")
${PHYSFS_TARGETNAME_DOCS}
${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building documentation in 'docs' directory..."
)
message(STATUS "Doxygen not found. You won't be able to build documentation.")
set(PHYSFS_TARBALL
"${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.bz2")
set(PHYSFS_TARGETNAME_DIST
"dist" CACHE STRING "Name of 'dist' build target")
${PHYSFS_TARGETNAME_DIST}
hg archive -t tbz2 "${PHYSFS_TARBALL}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
)
set(PHYSFS_TARGETNAME_UNINSTALL
"uninstall" CACHE STRING "Name of 'uninstall' build target")
${PHYSFS_TARGETNAME_UNINSTALL}
"${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Uninstall the project..."
)
"extras/physfs.pc.in"
"extras/physfs.pc"
@ONLY
)
FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
)
macro(message_bool_option _NAME _VALUE
)
message(STATUS " ${_NAME}: enabled")
message(STATUS " ${_NAME}: disabled")
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)
message_bool_option("SLB support" PHYSFS_ARCHIVE_SLB)
message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF)
message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
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)
message_bool_option(" Use readline in test program" HAVE_SYSTEM_READLINE)
# end of CMakeLists.txt ...