Fixed CMakeLists.txt to properly handle cross-compiling (thanks, Marc!).
authorRyan C. Gordon <icculus@icculus.org>
Wed, 08 Jul 2009 18:45:21 -0400
changeset 1005 cafe3867784c
parent 1003 a28d30d275e2
child 1006 139e2ab9e303
Fixed CMakeLists.txt to properly handle cross-compiling (thanks, Marc!).
CMakeLists.txt
--- a/CMakeLists.txt	Wed Jul 08 17:53:48 2009 -0400
+++ b/CMakeLists.txt	Wed Jul 08 18:45:21 2009 -0400
@@ -272,26 +272,21 @@
 # See if some archiver required zlib, and see about using system version.
 
 IF(PHYSFS_NEED_ZLIB)
-    CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
-    IF(HAVE_ZLIB_H)
-        CHECK_LIBRARY_EXISTS("z" "inflate" "" HAVE_LIBZ)
-        IF(HAVE_LIBZ)
-            SET(HAVE_SYSTEM_ZLIB TRUE)
-        ENDIF(HAVE_LIBZ)
-    ENDIF(HAVE_ZLIB_H)
+    FIND_PACKAGE(ZLIB)
 
-    IF(HAVE_SYSTEM_ZLIB)
+    IF(ZLIB_FOUND)
         OPTION(PHYSFS_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
     ELSE(HAVE_SYSTEM_ZLIB)
         SET(PHYSFS_INTERNAL_ZLIB TRUE)
-    ENDIF(HAVE_SYSTEM_ZLIB)
+    ENDIF(ZLIB_FOUND)
 
     IF(PHYSFS_INTERNAL_ZLIB)
         INCLUDE_DIRECTORIES(zlib123)
         ADD_DEFINITIONS(-DZ_PREFIX=1)
         SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${ZLIB_SRCS})
     ELSE(PHYSFS_INTERNAL_ZLIB)
-        SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} z)
+        SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${ZLIB_LIBRARY})
+        INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
     ENDIF(PHYSFS_INTERNAL_ZLIB)
 ENDIF(PHYSFS_NEED_ZLIB)
 
@@ -326,18 +321,19 @@
 OPTION(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
 MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
 IF(PHYSFS_BUILD_TEST)
-    CHECK_INCLUDE_FILE(readline/readline.h HAVE_READLINE_H)
-    CHECK_INCLUDE_FILE(readline/history.h HAVE_HISTORY_H)
-    IF(HAVE_READLINE_H AND HAVE_HISTORY_H)
+    FIND_PATH(READLINE_H readline/readline.h)
+    FIND_PATH(HISTORY_H readline/history.h)
+    IF(READLINE_H AND HISTORY_H)
         SET(CMAKE_REQUIRED_LIBRARIES curses)
-        CHECK_LIBRARY_EXISTS("readline" "readline" "" HAVE_LIBREADLINE)
-        CHECK_LIBRARY_EXISTS("readline" "history" "" HAVE_LIBHISTORY)
-        IF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
+        FIND_LIBRARY(READLINE_LIBRARY readline)
+        FIND_LIBRARY(HISTORY_LIBRARY history)
+        IF(READLINE_LIBRARY AND HISTORY_LIBRARY)
             SET(HAVE_SYSTEM_READLINE TRUE)
-            SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} " " readline curses)
+            SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
+            INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H})
             ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
-        ENDIF(HAVE_LIBREADLINE AND HAVE_LIBHISTORY)
-    ENDIF(HAVE_READLINE_H AND HAVE_HISTORY_H)
+        ENDIF(READLINE_LIBRARY AND HISTORY_LIBRARY)
+    ENDIF(READLINE_H AND HISTORY_H)
     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")