2007-03-10 07:32:52 +01:00
|
|
|
# PhysicsFS; a portable, flexible file i/o abstraction.
|
|
|
|
#
|
2007-03-11 11:10:28 +01:00
|
|
|
# Please see the file LICENSE.txt in the source's root directory.
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2017-07-12 05:32:46 +02:00
|
|
|
# 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.
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8.4)
|
2007-03-11 09:56:23 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
project(PhysicsFS)
|
|
|
|
set(PHYSFS_VERSION 2.1.0)
|
2009-03-23 02:19:21 +01:00
|
|
|
|
|
|
|
# Increment this if/when we break backwards compatibility.
|
2012-10-23 20:58:54 +02:00
|
|
|
set(PHYSFS_SOVERSION 1)
|
2007-03-10 07:32:52 +01:00
|
|
|
|
|
|
|
# I hate that they define "WIN32" ... we're about to move to Win64...I hope!
|
2012-10-23 20:58:54 +02:00
|
|
|
if(WIN32 AND NOT WINDOWS)
|
|
|
|
set(WINDOWS TRUE)
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
include_directories(./src)
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2017-07-12 05:32:46 +02:00
|
|
|
if(APPLE)
|
2017-07-12 21:41:12 +02:00
|
|
|
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework CoreFoundation -framework IOKit")
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
2010-02-03 05:04:28 +01:00
|
|
|
# Don't use -rpath.
|
2012-10-23 20:58:54 +02:00
|
|
|
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
|
|
|
|
add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
|
|
|
|
add_definitions(-xldscope=hidden)
|
|
|
|
endif()
|
2009-04-13 23:58:35 +02:00
|
|
|
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2017-07-12 06:16:57 +02:00
|
|
|
if(HAIKU)
|
2007-03-11 23:50:53 +01:00
|
|
|
# We add this explicitly, since we don't want CMake to think this
|
2017-07-12 06:16:57 +02:00
|
|
|
# is a C++ project unless we're on Haiku.
|
|
|
|
set(PHYSFS_HAIKU_SRCS src/platform_beos.cpp)
|
2012-10-23 20:58:54 +02:00
|
|
|
find_library(BE_LIBRARY be)
|
|
|
|
find_library(ROOT_LIBRARY root)
|
|
|
|
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
|
|
|
|
endif()
|
2007-03-11 23:50:53 +01:00
|
|
|
|
2017-07-12 05:32:46 +02:00
|
|
|
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()
|
|
|
|
|
2007-03-11 23:50:53 +01:00
|
|
|
# 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.
|
2012-10-23 20:58:54 +02:00
|
|
|
set(PHYSFS_SRCS
|
2009-03-27 20:10:42 +01:00
|
|
|
src/physfs.c
|
|
|
|
src/physfs_byteorder.c
|
|
|
|
src/physfs_unicode.c
|
|
|
|
src/platform_posix.c
|
|
|
|
src/platform_unix.c
|
|
|
|
src/platform_macosx.c
|
|
|
|
src/platform_windows.c
|
|
|
|
src/archiver_dir.c
|
2010-09-06 08:50:29 +02:00
|
|
|
src/archiver_unpacked.c
|
2009-03-27 20:10:42 +01:00
|
|
|
src/archiver_grp.c
|
|
|
|
src/archiver_hog.c
|
2017-07-17 18:26:50 +02:00
|
|
|
src/archiver_7z.c
|
2009-03-27 20:10:42 +01:00
|
|
|
src/archiver_mvl.c
|
|
|
|
src/archiver_qpak.c
|
|
|
|
src/archiver_wad.c
|
|
|
|
src/archiver_zip.c
|
2012-11-12 22:40:29 +01:00
|
|
|
src/archiver_slb.c
|
2010-03-17 19:50:54 +01:00
|
|
|
src/archiver_iso9660.c
|
2017-06-20 19:22:41 +02:00
|
|
|
src/archiver_vdf.c
|
2017-07-12 06:16:57 +02:00
|
|
|
${PHYSFS_HAIKU_SRCS}
|
2007-03-10 07:32:52 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Archivers ...
|
2017-07-11 06:40:51 +02:00
|
|
|
# These are (mostly) on by default now, so these options are only useful for
|
|
|
|
# disabling them.
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_ZIP)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_ZIP=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" TRUE)
|
2017-07-17 18:26:50 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_7Z)
|
2017-07-11 06:40:51 +02:00
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_7Z=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_GRP)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_GRP=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_WAD)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_WAD=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_HOG)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_HOG=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_MVL)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_MVL=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_QPAK)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_QPAK=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
2012-11-12 22:40:29 +01:00
|
|
|
option(PHYSFS_ARCHIVE_SLB "Enable I-War / Independence War SLB support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_SLB)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_SLB=0)
|
2012-11-12 22:40:29 +01:00
|
|
|
endif()
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_ISO9660)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_ISO9660=0)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
2017-06-20 19:22:41 +02:00
|
|
|
option(PHYSFS_ARCHIVE_VDF "Enable Gothic I/II VDF archive support" TRUE)
|
2017-07-11 06:40:51 +02:00
|
|
|
if(NOT PHYSFS_ARCHIVE_VDF)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_VDF=0)
|
2017-06-20 19:22:41 +02:00
|
|
|
endif()
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
|
|
|
|
option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
|
|
|
|
if(PHYSFS_BUILD_STATIC)
|
|
|
|
add_library(physfs-static STATIC ${PHYSFS_SRCS})
|
2017-07-11 05:32:54 +02:00
|
|
|
# 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.
|
|
|
|
if(NOT WINDOWS)
|
|
|
|
set_target_properties(physfs-static PROPERTIES OUTPUT_NAME "physfs")
|
|
|
|
endif()
|
2012-10-23 20:58:54 +02:00
|
|
|
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})
|
|
|
|
set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
|
|
|
|
set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
|
|
|
|
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()
|
2007-03-11 09:37:01 +01:00
|
|
|
|
|
|
|
# CMake FAQ says I need this...
|
2017-07-11 05:32:54 +02:00
|
|
|
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC AND NOT WINDOWS)
|
2012-10-23 20:58:54 +02:00
|
|
|
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})
|
|
|
|
include_directories(${READLINE_H} ${HISTORY_H})
|
|
|
|
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()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
install(TARGETS ${PHYSFS_INSTALL_TARGETS}
|
2007-03-11 09:56:23 +01:00
|
|
|
RUNTIME DESTINATION bin
|
2011-02-17 21:02:20 +01:00
|
|
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
|
|
|
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
2012-10-23 20:58:54 +02:00
|
|
|
install(FILES src/physfs.h DESTINATION include)
|
2007-03-11 09:56:23 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
find_package(Doxygen)
|
|
|
|
if(DOXYGEN_FOUND)
|
|
|
|
set(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
|
|
|
|
configure_file(
|
2011-02-22 05:43:36 +01:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
|
2011-02-22 05:35:24 +01:00
|
|
|
"${PHYSFS_OUTPUT_DOXYFILE}"
|
|
|
|
COPYONLY
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
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")
|
2011-02-22 05:35:24 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
add_custom_target(
|
2011-02-22 05:35:24 +01:00
|
|
|
docs
|
|
|
|
${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
COMMENT "Building documentation in 'docs' directory..."
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
else()
|
|
|
|
message(STATUS "Doxygen not found. You won't be able to build documentation.")
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(UNIX)
|
2012-10-23 20:59:29 +02:00
|
|
|
set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.bz2")
|
2012-10-23 20:58:54 +02:00
|
|
|
add_custom_target(
|
2010-02-03 05:22:49 +01:00
|
|
|
dist
|
2012-10-23 20:59:29 +02:00
|
|
|
hg archive -t tbz2 "${PHYSFS_TARBALL}"
|
2010-02-03 05:33:57 +01:00
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
|
2010-02-03 05:22:49 +01:00
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
add_custom_target(
|
2010-02-03 05:22:49 +01:00
|
|
|
uninstall
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh"
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
COMMENT "Uninstall the project..."
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
|
|
|
|
2013-11-13 06:38:35 +01:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
configure_file(
|
|
|
|
"extras/physfs.pc.in"
|
|
|
|
"extras/physfs.pc"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
|
|
|
|
DESTINATION "lib/pkgconfig"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
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)
|
2012-11-12 22:40:29 +01:00
|
|
|
message_bool_option("SLB support" PHYSFS_ARCHIVE_SLB)
|
2017-07-11 04:56:49 +02:00
|
|
|
message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF)
|
|
|
|
message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
|
2012-10-23 20:58:54 +02:00
|
|
|
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()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
|
|
|
# end of CMakeLists.txt ...
|
|
|
|
|