CMakeLists.txt
changeset 1005 cafe3867784c
parent 993 e8ba2577ac1f
child 1009 56a3873c63e4
equal deleted inserted replaced
1003:a28d30d275e2 1005:cafe3867784c
   270 
   270 
   271 
   271 
   272 # See if some archiver required zlib, and see about using system version.
   272 # See if some archiver required zlib, and see about using system version.
   273 
   273 
   274 IF(PHYSFS_NEED_ZLIB)
   274 IF(PHYSFS_NEED_ZLIB)
   275     CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
   275     FIND_PACKAGE(ZLIB)
   276     IF(HAVE_ZLIB_H)
   276 
   277         CHECK_LIBRARY_EXISTS("z" "inflate" "" HAVE_LIBZ)
   277     IF(ZLIB_FOUND)
   278         IF(HAVE_LIBZ)
       
   279             SET(HAVE_SYSTEM_ZLIB TRUE)
       
   280         ENDIF(HAVE_LIBZ)
       
   281     ENDIF(HAVE_ZLIB_H)
       
   282 
       
   283     IF(HAVE_SYSTEM_ZLIB)
       
   284         OPTION(PHYSFS_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
   278         OPTION(PHYSFS_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
   285     ELSE(HAVE_SYSTEM_ZLIB)
   279     ELSE(HAVE_SYSTEM_ZLIB)
   286         SET(PHYSFS_INTERNAL_ZLIB TRUE)
   280         SET(PHYSFS_INTERNAL_ZLIB TRUE)
   287     ENDIF(HAVE_SYSTEM_ZLIB)
   281     ENDIF(ZLIB_FOUND)
   288 
   282 
   289     IF(PHYSFS_INTERNAL_ZLIB)
   283     IF(PHYSFS_INTERNAL_ZLIB)
   290         INCLUDE_DIRECTORIES(zlib123)
   284         INCLUDE_DIRECTORIES(zlib123)
   291         ADD_DEFINITIONS(-DZ_PREFIX=1)
   285         ADD_DEFINITIONS(-DZ_PREFIX=1)
   292         SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${ZLIB_SRCS})
   286         SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${ZLIB_SRCS})
   293     ELSE(PHYSFS_INTERNAL_ZLIB)
   287     ELSE(PHYSFS_INTERNAL_ZLIB)
   294         SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} z)
   288         SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${ZLIB_LIBRARY})
       
   289         INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
   295     ENDIF(PHYSFS_INTERNAL_ZLIB)
   290     ENDIF(PHYSFS_INTERNAL_ZLIB)
   296 ENDIF(PHYSFS_NEED_ZLIB)
   291 ENDIF(PHYSFS_NEED_ZLIB)
   297 
   292 
   298 OPTION(PHYSFS_BUILD_STATIC "Build static library" TRUE)
   293 OPTION(PHYSFS_BUILD_STATIC "Build static library" TRUE)
   299 IF(PHYSFS_BUILD_STATIC)
   294 IF(PHYSFS_BUILD_STATIC)
   324 ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
   319 ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
   325 
   320 
   326 OPTION(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
   321 OPTION(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
   327 MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
   322 MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
   328 IF(PHYSFS_BUILD_TEST)
   323 IF(PHYSFS_BUILD_TEST)
   329     CHECK_INCLUDE_FILE(readline/readline.h HAVE_READLINE_H)
   324     FIND_PATH(READLINE_H readline/readline.h)
   330     CHECK_INCLUDE_FILE(readline/history.h HAVE_HISTORY_H)
   325     FIND_PATH(HISTORY_H readline/history.h)
   331     IF(HAVE_READLINE_H AND HAVE_HISTORY_H)
   326     IF(READLINE_H AND HISTORY_H)
   332         SET(CMAKE_REQUIRED_LIBRARIES curses)
   327         SET(CMAKE_REQUIRED_LIBRARIES curses)
   333         CHECK_LIBRARY_EXISTS("readline" "readline" "" HAVE_LIBREADLINE)
   328         FIND_LIBRARY(READLINE_LIBRARY readline)
   334         CHECK_LIBRARY_EXISTS("readline" "history" "" HAVE_LIBHISTORY)
   329         FIND_LIBRARY(HISTORY_LIBRARY history)
   335         IF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
   330         IF(READLINE_LIBRARY AND HISTORY_LIBRARY)
   336             SET(HAVE_SYSTEM_READLINE TRUE)
   331             SET(HAVE_SYSTEM_READLINE TRUE)
   337             SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} " " readline curses)
   332             SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
       
   333             INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H})
   338             ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
   334             ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
   339         ENDIF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
   335         ENDIF(READLINE_LIBRARY AND HISTORY_LIBRARY)
   340     ENDIF(HAVE_READLINE_H AND HAVE_HISTORY_H)
   336     ENDIF(READLINE_H AND HISTORY_H)
   341     ADD_EXECUTABLE(test_physfs test/test_physfs.c)
   337     ADD_EXECUTABLE(test_physfs test/test_physfs.c)
   342     TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
   338     TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
   343     SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
   339     SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
   344 ENDIF(PHYSFS_BUILD_TEST)
   340 ENDIF(PHYSFS_BUILD_TEST)
   345 
   341