FindPhysFS.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # - Locate PhysFS library
  2. # This module defines
  3. # PHYSFS_LIBRARY, the name of the library to link with
  4. # PHYSFS_FOUND, if false, do not try to link to PHYSFS
  5. # PHYSFS_INCLUDE_DIR, where to find PHYSFS/PHYSFS.h
  6. #
  7. # $PHYSFSDIR is an environment variable that would
  8. # correspond to the ./configure --prefix=$PHYSFSDIR
  9. # used in building PHYSFS.
  10. #
  11. # Created by Eric Wing. This was influenced by the FindSDL.cmake
  12. # module, but with modifications to recognize OS X frameworks.
  13. # On OSX, this will prefer the Framework version (if found) over others.
  14. # People will have to manually change the cache values of
  15. # PHYSFS_LIBRARY to override this selection.
  16. FIND_PATH(PHYSFS_INCLUDE_DIR NAMES physfs.h
  17. PATH_SUFFIXES physfs
  18. PATHS
  19. $ENV{PHYSFSDIR}/include
  20. ~/Library/Frameworks/PhysFS.framework/Headers
  21. /Library/Frameworks/PhysFS.framework/Headers
  22. )
  23. # I'm not sure if I should do a special casing for Apple. It is
  24. # unlikely that other Unix systems will find the framework path.
  25. # But if they do ([Next|Open|GNU]Step?),
  26. # do they want the -framework option also?
  27. IF(${PHYSFS_INCLUDE_DIR} MATCHES ".framework")
  28. STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" PHYSFS_FRAMEWORK_PATH_TMP ${PHYSFS_INCLUDE_DIR})
  29. IF("${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
  30. OR "${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
  31. )
  32. # String is in default search path, don't need to use -F
  33. SET(PHYSFS_LIBRARY "-framework PhysFS" CACHE STRING "PhysFS framework for OSX")
  34. ELSE("${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
  35. OR "${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
  36. )
  37. # String is not /Library/Frameworks, need to use -F
  38. SET(PHYSFS_LIBRARY "-F${PHYSFS_FRAMEWORK_PATH_TMP} -framework PhysFS" CACHE STRING "PhysFS framework for OSX")
  39. ENDIF("${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
  40. OR "${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
  41. )
  42. # Clear the temp variable so nobody can see it
  43. SET(PHYSFS_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
  44. ELSE(${PHYSFS_INCLUDE_DIR} MATCHES ".framework")
  45. FIND_LIBRARY(PHYSFS_LIBRARY
  46. NAMES physfs PhysFS
  47. PATHS
  48. $ENV{PHYSFSDIR}/lib
  49. )
  50. ENDIF(${PHYSFS_INCLUDE_DIR} MATCHES ".framework")
  51. # handle the QUIETLY and REQUIRED arguments and set PHYSFS_FOUND to TRUE if
  52. # all listed variables are TRUE
  53. INCLUDE(FindPackageHandleStandardArgs)
  54. FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)