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
|
|
|
|
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
|
|
|
|
|
|
|
# Bleh, let's do it for "APPLE" too.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(APPLE AND NOT MACOSX)
|
|
|
|
set(MACOSX TRUE)
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2011-07-16 16:14:00 +02:00
|
|
|
# For now, Haiku and BeOS are the same, as far as the build system cares.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(HAIKU AND NOT BEOS)
|
|
|
|
set(BEOS TRUE)
|
|
|
|
endif()
|
2011-07-16 16:14:00 +02:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
|
|
|
set(SOLARIS TRUE)
|
|
|
|
endif()
|
2009-04-13 09:40:02 +02:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
include(CheckIncludeFile)
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
include(CheckCSourceCompiles)
|
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
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(MACOSX)
|
2007-03-11 09:40:51 +01:00
|
|
|
# Fallback to older OS X on PowerPC to support wider range of systems...
|
2012-10-23 20:58:54 +02:00
|
|
|
if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
|
|
|
|
add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020)
|
|
|
|
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} " -mmacosx-version-min=10.2")
|
|
|
|
endif()
|
2007-03-11 09:40:51 +01:00
|
|
|
|
|
|
|
# Need these everywhere...
|
2012-10-23 20:58:54 +02:00
|
|
|
add_definitions(-fno-common)
|
|
|
|
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework Carbon -framework IOKit")
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
|
|
|
# Add some gcc-specific command lines.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
2007-03-10 07:32:52 +01:00
|
|
|
# Always build with debug symbols...you can strip it later.
|
2012-10-23 20:58:54 +02:00
|
|
|
add_definitions(-g -pipe -Werror -fsigned-char)
|
2007-03-12 04:41:20 +01:00
|
|
|
|
|
|
|
# Stupid BeOS generates warnings in the system headers.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(NOT BEOS)
|
|
|
|
add_definitions(-Wall)
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
check_c_source_compiles("
|
2007-03-10 07:32:52 +01:00
|
|
|
#if ((defined(__GNUC__)) && (__GNUC__ >= 4))
|
|
|
|
int main(int argc, char **argv) { int is_gcc4 = 1; return 0; }
|
|
|
|
#else
|
|
|
|
#error This is not gcc4.
|
|
|
|
#endif
|
|
|
|
" PHYSFS_IS_GCC4)
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(PHYSFS_IS_GCC4)
|
2009-07-12 22:43:59 +02:00
|
|
|
# Not supported on several operating systems at this time.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(NOT SOLARIS AND NOT WINDOWS)
|
|
|
|
add_definitions(-fvisibility=hidden)
|
|
|
|
endif()
|
|
|
|
endif()
|
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
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(MSVC)
|
2007-03-19 08:44:04 +01:00
|
|
|
# VS.NET 8.0 got really really anal about strcpy, etc, which even if we
|
|
|
|
# cleaned up our code, zlib, etc still use...so disable the warning.
|
2012-10-23 20:58:54 +02:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
|
|
|
# Basic chunks of source code ...
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
set(LZMA_SRCS
|
2009-03-27 20:10:42 +01:00
|
|
|
src/lzma/C/7zCrc.c
|
|
|
|
src/lzma/C/Archive/7z/7zBuffer.c
|
|
|
|
src/lzma/C/Archive/7z/7zDecode.c
|
|
|
|
src/lzma/C/Archive/7z/7zExtract.c
|
|
|
|
src/lzma/C/Archive/7z/7zHeader.c
|
|
|
|
src/lzma/C/Archive/7z/7zIn.c
|
|
|
|
src/lzma/C/Archive/7z/7zItem.c
|
|
|
|
src/lzma/C/Archive/7z/7zMethodID.c
|
|
|
|
src/lzma/C/Compress/Branch/BranchX86.c
|
|
|
|
src/lzma/C/Compress/Branch/BranchX86_2.c
|
|
|
|
src/lzma/C/Compress/Lzma/LzmaDecode.c
|
2007-03-10 07:32:52 +01:00
|
|
|
)
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(BEOS)
|
2007-03-11 23:50:53 +01:00
|
|
|
# We add this explicitly, since we don't want CMake to think this
|
|
|
|
# is a C++ project unless we're on BeOS.
|
2012-10-23 20:58:54 +02:00
|
|
|
set(PHYSFS_BEOS_SRCS src/platform_beos.cpp)
|
|
|
|
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
|
|
|
|
|
|
|
# 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
|
|
|
|
src/archiver_lzma.c
|
|
|
|
src/archiver_mvl.c
|
|
|
|
src/archiver_qpak.c
|
|
|
|
src/archiver_wad.c
|
|
|
|
src/archiver_zip.c
|
2010-03-17 19:50:54 +01:00
|
|
|
src/archiver_iso9660.c
|
2007-03-11 23:50:53 +01:00
|
|
|
${PHYSFS_BEOS_SRCS}
|
2007-03-10 07:32:52 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# platform layers ...
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(UNIX)
|
|
|
|
if(BEOS)
|
|
|
|
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
|
|
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
|
|
|
set(HAVE_PTHREAD_H TRUE)
|
|
|
|
else()
|
|
|
|
check_include_file(sys/ucred.h HAVE_UCRED_H)
|
|
|
|
if(HAVE_UCRED_H)
|
|
|
|
add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1)
|
|
|
|
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_file(mntent.h HAVE_MNTENT_H)
|
|
|
|
if(HAVE_MNTENT_H)
|
|
|
|
add_definitions(-DPHYSFS_HAVE_MNTENT_H=1)
|
|
|
|
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2009-04-13 23:59:15 +02:00
|
|
|
# !!! FIXME: Solaris fails this, because mnttab.h implicitly
|
|
|
|
# !!! FIXME: depends on other system headers. :(
|
2012-10-23 20:58:54 +02:00
|
|
|
#check_include_file(sys/mnttab.h HAVE_SYS_MNTTAB_H)
|
|
|
|
check_c_source_compiles("
|
2009-04-13 23:59:15 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/mnttab.h>
|
|
|
|
int main(int argc, char **argv) { return 0; }
|
|
|
|
" HAVE_SYS_MNTTAB_H)
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(HAVE_SYS_MNTTAB_H)
|
|
|
|
add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1)
|
|
|
|
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_file(pthread.h HAVE_PTHREAD_H)
|
|
|
|
if(HAVE_PTHREAD_H)
|
|
|
|
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WINDOWS)
|
|
|
|
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
|
|
|
|
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT PHYSFS_HAVE_CDROM_SUPPORT)
|
|
|
|
add_definitions(-DPHYSFS_NO_CDROM_SUPPORT=1)
|
|
|
|
message(WARNING " ***")
|
|
|
|
message(WARNING " *** There is no CD-ROM support in this build!")
|
|
|
|
message(WARNING " *** PhysicsFS will just pretend there are no discs.")
|
|
|
|
message(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
|
|
|
|
message(WARNING " *** but is this what you REALLY wanted?")
|
|
|
|
message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
|
|
|
|
message(WARNING " ***")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PHYSFS_HAVE_THREAD_SUPPORT)
|
|
|
|
add_definitions(-D_REENTRANT -D_THREAD_SAFE)
|
|
|
|
else()
|
|
|
|
add_definitions(-DPHYSFS_NO_THREAD_SUPPORT=1)
|
|
|
|
message(WARNING " ***")
|
|
|
|
message(WARNING " *** There is no thread support in this build!")
|
|
|
|
message(WARNING " *** PhysicsFS will NOT be reentrant!")
|
|
|
|
message(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
|
|
|
|
message(WARNING " *** but is this what you REALLY wanted?")
|
|
|
|
message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
|
|
|
|
message(WARNING " ***")
|
|
|
|
endif()
|
2007-03-10 07:32:52 +01:00
|
|
|
|
2007-03-11 23:50:53 +01:00
|
|
|
|
2007-03-10 07:32:52 +01:00
|
|
|
# Archivers ...
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_ZIP)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_ZIP=1)
|
|
|
|
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)
|
|
|
|
if(PHYSFS_ARCHIVE_7Z)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_7Z=1)
|
2007-03-10 07:32:52 +01:00
|
|
|
# !!! FIXME: rename to 7z.c?
|
2012-10-23 20:58:54 +02:00
|
|
|
set(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_GRP)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_GRP=1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_WAD)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_WAD=1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_HOG)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_HOG=1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_MVL)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_MVL=1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_QPAK)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_QPAK=1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
|
|
|
|
if(PHYSFS_ARCHIVE_ISO9660)
|
|
|
|
add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
|
|
|
|
if(PHYSFS_BUILD_STATIC)
|
|
|
|
add_library(physfs-static STATIC ${PHYSFS_SRCS})
|
|
|
|
set_target_properties(physfs-static PROPERTIES OUTPUT_NAME "physfs")
|
|
|
|
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...
|
2012-10-23 20:58:54 +02:00
|
|
|
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
|
|
|
|
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
|
|
|
|
2010-02-01 09:17:14 +01:00
|
|
|
|
|
|
|
# Scripting language bindings...
|
|
|
|
|
|
|
|
#CMake's SWIG support is basically useless.
|
2012-10-23 20:58:54 +02:00
|
|
|
#find_package(SWIG)
|
|
|
|
|
|
|
|
option(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." TRUE)
|
|
|
|
mark_as_advanced(PHYSFS_BUILD_SWIG)
|
|
|
|
|
|
|
|
find_program(SWIG swig DOC "Path to swig command line app: http://swig.org/")
|
|
|
|
if(NOT SWIG)
|
|
|
|
message(STATUS "SWIG not found. You won't be able to build scripting language bindings.")
|
|
|
|
else()
|
|
|
|
mark_as_advanced(SWIG)
|
|
|
|
if(DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
if((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
|
|
set(SWIG_OPT_CFLAGS "-small")
|
|
|
|
else()
|
|
|
|
set(SWIG_OPT_CFLAGS "-O")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings")
|
|
|
|
|
|
|
|
macro(configure_swig_binding _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS)
|
|
|
|
string(TOUPPER "${_LANG}" _UPPERLANG)
|
|
|
|
string(TOLOWER "${_LANG}" _LOWERLANG)
|
|
|
|
set(_TARGET "physfs-${_LOWERLANG}")
|
|
|
|
set(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}")
|
|
|
|
|
|
|
|
if(NOT EXISTS "${_TARGETDIR}")
|
2010-02-03 04:49:48 +01:00
|
|
|
FILE(MAKE_DIRECTORY "${_TARGETDIR}")
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
2010-02-03 04:49:48 +01:00
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
if(PHYSFS_BUILD_${_UPPERLANG})
|
|
|
|
add_custom_command(
|
2010-02-03 04:49:48 +01:00
|
|
|
OUTPUT "${_TARGETDIR}/${_TARGET}.c" ${_EXTRAOUTPUTS}
|
2010-02-01 10:22:05 +01:00
|
|
|
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
|
|
|
|
COMMAND "${SWIG}"
|
2010-02-03 04:49:48 +01:00
|
|
|
ARGS ${SWIG_OPT_CFLAGS} -${_LOWERLANG} -outdir "${_TARGETDIR}" -o "${_TARGETDIR}/${_TARGET}.c" "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
|
2010-02-01 10:22:05 +01:00
|
|
|
COMMENT "Generating ${_LANG} bindings..."
|
|
|
|
)
|
|
|
|
|
2012-10-23 20:58:54 +02:00
|
|
|
add_library(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c")
|
|
|
|
target_link_libraries(${_TARGET} ${PHYSFS_LIB_TARGET})
|
|
|
|
set_target_properties(${_TARGET} PROPERTIES
|
2010-02-01 10:22:05 +01:00
|
|
|
COMPILE_FLAGS "${_EXTRACFLAGS}"
|
2010-02-02 04:04:36 +01:00
|
|
|
LINK_FLAGS "${_EXTRALDFLAGS}"
|
2010-02-03 04:49:48 +01:00
|
|
|
LIBRARY_OUTPUT_NAME "physfs"
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}"
|
2010-02-03 05:04:13 +01:00
|
|
|
CLEAN_DIRECT_OUTPUT 1
|
2010-02-01 10:22:05 +01:00
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
install(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}")
|
|
|
|
message(STATUS "${_LANG} bindings configured!")
|
|
|
|
else()
|
|
|
|
message(STATUS "Couldn't figure out ${_LANG} configuration. Skipping ${_LANG} bindings.")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(add_script_binding_option _VAR _LANG _DEFVAL)
|
|
|
|
set(BUILDSWIGVAL ${_DEFVAL})
|
|
|
|
if(NOT PHYSFS_BUILD_SWIG)
|
|
|
|
set(BUILDSWIGVAL FALSE)
|
|
|
|
endif()
|
|
|
|
option(${_VAR} "Build ${_LANG} bindings." ${BUILDSWIGVAL})
|
|
|
|
mark_as_advanced(${_VAR})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
add_script_binding_option(PHYSFS_BUILD_PERL "Perl" TRUE)
|
|
|
|
add_script_binding_option(PHYSFS_BUILD_RUBY "Ruby" TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PHYSFS_BUILD_PERL)
|
|
|
|
message(STATUS "Configuring Perl bindings...")
|
|
|
|
find_program(PERL perl DOC "Path to perl command line app: http://perl.org/")
|
|
|
|
if(NOT PERL)
|
|
|
|
message(STATUS "Perl not found. You won't be able to build perl bindings.")
|
|
|
|
set(PHYSFS_BUILD_PERL FALSE)
|
|
|
|
endif()
|
|
|
|
mark_as_advanced(PERL)
|
|
|
|
|
|
|
|
macro(get_perl_config _KEY _VALUE)
|
|
|
|
if(PHYSFS_BUILD_PERL)
|
|
|
|
message(STATUS "Figuring out perl config value '${_KEY}' ...")
|
|
|
|
execute_process(
|
2010-02-02 03:32:38 +01:00
|
|
|
COMMAND ${PERL} -w -e "use Config; print \$Config{${_KEY}};"
|
2010-02-01 09:17:14 +01:00
|
|
|
RESULT_VARIABLE GET_PERL_CONFIG_RC
|
|
|
|
OUTPUT_VARIABLE ${_VALUE}
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
if(NOT GET_PERL_CONFIG_RC EQUAL 0)
|
|
|
|
message(STATUS "Perl executable ('${PERL}') reported failure: ${GET_PERL_CONFIG_RC}")
|
|
|
|
set(PHYSFS_BUILD_PERL FALSE)
|
|
|
|
endif()
|
|
|
|
if(NOT ${_VALUE})
|
|
|
|
message(STATUS "Perl executable ('${PERL}') didn't have a value for '${_KEY}'")
|
|
|
|
set(PHYSFS_BUILD_PERL FALSE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PHYSFS_BUILD_PERL)
|
|
|
|
message(STATUS "Perl says: '${${_VALUE}}'.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2010-02-01 09:17:14 +01:00
|
|
|
|
|
|
|
# !!! FIXME: installsitearch might be the wrong location.
|
2012-10-23 20:58:54 +02:00
|
|
|
get_perl_config("archlibexp" PERL_INCLUDE_PATH)
|
|
|
|
get_perl_config("ccflags" PERL_CCFLAGS)
|
|
|
|
get_perl_config("ldflags" PERL_LDFLAGS)
|
|
|
|
get_perl_config("installsitearch" PERL_INSTALL_PATH)
|
2010-02-01 09:17:14 +01:00
|
|
|
|
2010-02-02 05:15:36 +01:00
|
|
|
# !!! FIXME: this test for Mac OS X is wrong.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(MACOSX)
|
|
|
|
get_perl_config("libperl" PERL_LIBPERL)
|
|
|
|
set(TMPLIBPERL "${PERL_LIBPERL}")
|
|
|
|
string(REGEX REPLACE "^lib" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
|
|
string(REGEX REPLACE "\\.so$" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
|
|
string(REGEX REPLACE "\\.dylib$" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
|
|
string(REGEX REPLACE "\\.dll$" "" TMPLIBPERL "${TMPLIBPERL}")
|
|
|
|
if(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
|
|
|
|
message(STATUS "Stripped '${PERL_LIBPERL}' down to '${TMPLIBPERL}'.")
|
|
|
|
set(PERL_LIBPERL "${TMPLIBPERL}")
|
|
|
|
endif()
|
|
|
|
set(PERL_LIBPERL "-l${PERL_LIBPERL}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
configure_swig_binding(Perl "${PERL_INSTALL_PATH}" "${SWIG_OUTPUT_DIR}/perl/physfs.pm" "\"-I${PERL_INCLUDE_PATH}/CORE\" ${PERL_CCFLAGS} -w" "\"-L${PERL_INCLUDE_PATH}/CORE\" ${PERL_LIBPERL} ${PERL_LDFLAGS}")
|
|
|
|
install(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}")
|
|
|
|
install(
|
2010-02-03 05:55:12 +01:00
|
|
|
FILES test/test_physfs.pl
|
|
|
|
DESTINATION bin
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
2010-02-01 09:17:14 +01:00
|
|
|
|
2010-02-04 10:46:14 +01:00
|
|
|
# !!! FIXME: lots of cut-and-paste from perl bindings.
|
2012-10-23 20:58:54 +02:00
|
|
|
if(PHYSFS_BUILD_RUBY)
|
|
|
|
message(STATUS "Configuring Ruby bindings...")
|
|
|
|
find_program(RUBY ruby DOC "Path to ruby command line app: http://ruby-lang.org/")
|
|
|
|
if(NOT RUBY)
|
|
|
|
message(STATUS "Ruby not found. You won't be able to build ruby bindings.")
|
|
|
|
set(PHYSFS_BUILD_RUBY FALSE)
|
|
|
|
endif()
|
|
|
|
mark_as_advanced(RUBY)
|
|
|
|
|
|
|
|
macro(get_ruby_config _KEY _VALUE)
|
|
|
|
if(PHYSFS_BUILD_RUBY)
|
|
|
|
message(STATUS "Figuring out ruby config value '${_KEY}' ...")
|
|
|
|
execute_process(
|
2010-02-04 10:46:14 +01:00
|
|
|
COMMAND ${RUBY} -e "require 'rbconfig'; puts RbConfig::CONFIG['${_KEY}'];"
|
|
|
|
RESULT_VARIABLE GET_RUBY_CONFIG_RC
|
|
|
|
OUTPUT_VARIABLE ${_VALUE}
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
if(NOT GET_RUBY_CONFIG_RC EQUAL 0)
|
|
|
|
message(STATUS "Ruby executable ('${RUBY}') reported failure: ${GET_RUBY_CONFIG_RC}")
|
|
|
|
set(PHYSFS_BUILD_RUBY FALSE)
|
|
|
|
endif()
|
|
|
|
if(NOT ${_VALUE})
|
|
|
|
message(STATUS "Ruby executable ('${RUBY}') didn't have a value for '${_KEY}'")
|
|
|
|
set(PHYSFS_BUILD_RUBY FALSE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PHYSFS_BUILD_RUBY)
|
|
|
|
message(STATUS "Ruby says: '${${_VALUE}}'.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
get_ruby_config("archdir" RUBY_INCLUDE_PATH)
|
|
|
|
get_ruby_config("CFLAGS" RUBY_CCFLAGS)
|
|
|
|
get_ruby_config("LDFLAGS" RUBY_LDFLAGS)
|
|
|
|
get_ruby_config("sitearchdir" RUBY_INSTALL_PATH)
|
|
|
|
get_ruby_config("LIBRUBYARG_SHARED" RUBY_LIBRUBY)
|
|
|
|
get_ruby_config("libdir" RUBY_LIBDIR)
|
|
|
|
|
|
|
|
configure_swig_binding(Ruby "${RUBY_INSTALL_PATH}" "" "\"-I${RUBY_INCLUDE_PATH}\" ${RUBY_CCFLAGS} -w" "\"-L${RUBY_LIBDIR}\" ${RUBY_LIBRUBY} ${RUBY_LDFLAGS}")
|
|
|
|
set_target_properties(physfs-ruby PROPERTIES PREFIX "")
|
|
|
|
install(
|
2010-02-04 10:46:14 +01:00
|
|
|
FILES test/test_physfs.rb
|
|
|
|
DESTINATION bin
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
|
|
)
|
2012-10-23 20:58:54 +02:00
|
|
|
endif()
|
2010-02-01 10:22:05 +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()
|
|
|
|
|
|
|
|
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)
|
|
|
|
message_bool_option("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT)
|
|
|
|
message_bool_option("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT)
|
|
|
|
message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
|
|
|
|
message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
|
|
|
|
message_bool_option("Build Perl bindings" PHYSFS_BUILD_PERL)
|
|
|
|
message_bool_option("Build Ruby bindings" PHYSFS_BUILD_RUBY)
|
|
|
|
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 ...
|
|
|
|
|