Can now build shared or static (or both) libraries.

This commit is contained in:
Ryan C. Gordon 2007-03-11 08:37:01 +00:00
parent a1bb93b43f
commit 94496e3302
2 changed files with 26 additions and 4 deletions

View File

@ -3,7 +3,8 @@
*/ */
03112007 - Removed zlib_license_change.txt ... it's in Subversion and the 1.0 03112007 - Removed zlib_license_change.txt ... it's in Subversion and the 1.0
branch for history's sake. branch for history's sake. Added shared and static build options
to CMakeLists.txt
03082007 - Fixed a comment in physfs.h. Renamed win32.c to windows.c. 03082007 - Fixed a comment in physfs.h. Renamed win32.c to windows.c.
Cleaned up whitespace/formatting in pocketpc.c. Updated PocketPC Cleaned up whitespace/formatting in pocketpc.c. Updated PocketPC
code to expect UTF-8 strings from the higher level. Changed code to expect UTF-8 strings from the higher level. Changed

View File

@ -231,10 +231,29 @@ IF(PHYSFS_NEED_ZLIB)
ENDIF(PHYSFS_INTERNAL_ZLIB) ENDIF(PHYSFS_INTERNAL_ZLIB)
ENDIF(PHYSFS_NEED_ZLIB) ENDIF(PHYSFS_NEED_ZLIB)
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)
ENDIF(PHYSFS_BUILD_STATIC)
OPTION(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
IF(PHYSFS_BUILD_SHARED)
ADD_LIBRARY(physfs SHARED ${PHYSFS_SRCS})
TARGET_LINK_LIBRARIES(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
SET(PHYSFS_LIB_TARGET physfs)
ENDIF(PHYSFS_BUILD_SHARED)
ADD_LIBRARY(physfs SHARED ${PHYSFS_SRCS}) IF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
TARGET_LINK_LIBRARIES(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS}) MESSAGE(FATAL "Both shared and static libraries are disabled!")
ENDIF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
# CMake FAQ says I need this...
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(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
OPTION(PHYSFS_BUILD_TEST "Build test program." TRUE) OPTION(PHYSFS_BUILD_TEST "Build test program." TRUE)
MARK_AS_ADVANCED(PHYSFS_BUILD_TEST) MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
@ -252,7 +271,7 @@ IF(PHYSFS_BUILD_TEST)
ENDIF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY) ENDIF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
ENDIF(HAVE_READLINE_H AND HAVE_HISTORY_H) ENDIF(HAVE_READLINE_H AND HAVE_HISTORY_H)
ADD_EXECUTABLE(test_physfs test/test_physfs.c) ADD_EXECUTABLE(test_physfs test/test_physfs.c)
TARGET_LINK_LIBRARIES(test_physfs physfs ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS}) TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
ENDIF(PHYSFS_BUILD_TEST) ENDIF(PHYSFS_BUILD_TEST)
FIND_PACKAGE(Doxygen) FIND_PACKAGE(Doxygen)
@ -282,6 +301,8 @@ MESSAGE_BOOL_OPTION("QPAK support" PHYSFS_ARCHIVE_QPAK)
MESSAGE_BOOL_OPTION("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT) MESSAGE_BOOL_OPTION("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT)
MESSAGE_BOOL_OPTION("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT) MESSAGE_BOOL_OPTION("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT)
MESSAGE_BOOL_OPTION("Build own zlib" PHYSFS_INTERNAL_ZLIB) MESSAGE_BOOL_OPTION("Build own zlib" PHYSFS_INTERNAL_ZLIB)
MESSAGE_BOOL_OPTION("Build static library" PHYSFS_BUILD_STATIC)
MESSAGE_BOOL_OPTION("Build shared library" PHYSFS_BUILD_SHARED)
MESSAGE_BOOL_OPTION("Build test program" PHYSFS_BUILD_TEST) MESSAGE_BOOL_OPTION("Build test program" PHYSFS_BUILD_TEST)
IF(PHYSFS_BUILD_TEST) IF(PHYSFS_BUILD_TEST)
MESSAGE_BOOL_OPTION(" Use readline in test program" HAVE_SYSTEM_READLINE) MESSAGE_BOOL_OPTION(" Use readline in test program" HAVE_SYSTEM_READLINE)