FindPhysFS.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 physfs.h
  17. $ENV{PHYSFSDIR}/include
  18. ~/Library/Frameworks/PhysFS.framework/Headers
  19. /Library/Frameworks/PhysFS.framework/Headers
  20. /usr/local/include/physfs
  21. /usr/local/include
  22. /usr/include/physfs
  23. /usr/include
  24. /sw/include/physfs # Fink
  25. /sw/include
  26. /opt/local/include/physfs # DarwinPorts
  27. /opt/local/include
  28. /opt/csw/include/physfs # Blastwave
  29. /opt/csw/include
  30. /opt/include/physfs
  31. /opt/include
  32. )
  33. # I'm not sure if I should do a special casing for Apple. It is
  34. # unlikely that other Unix systems will find the framework path.
  35. # But if they do ([Next|Open|GNU]Step?),
  36. # do they want the -framework option also?
  37. IF(${PHYSFS_INCLUDE_DIR} MATCHES ".framework")
  38. STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" PHYSFS_FRAMEWORK_PATH_TMP ${PHYSFS_INCLUDE_DIR})
  39. IF("${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
  40. OR "${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
  41. )
  42. # String is in default search path, don't need to use -F
  43. SET(PHYSFS_LIBRARY "-framework PhysFS" CACHE STRING "PhysFS framework for OSX")
  44. ELSE("${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
  45. OR "${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
  46. )
  47. # String is not /Library/Frameworks, need to use -F
  48. SET(PHYSFS_LIBRARY "-F${PHYSFS_FRAMEWORK_PATH_TMP} -framework PhysFS" CACHE STRING "PhysFS framework for OSX")
  49. ENDIF("${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
  50. OR "${PHYSFS_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
  51. )
  52. # Clear the temp variable so nobody can see it
  53. SET(PHYSFS_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
  54. ELSE(${PHYSFS_INCLUDE_DIR} MATCHES ".framework")
  55. FIND_LIBRARY(PHYSFS_LIBRARY
  56. NAMES physfs PhysFS
  57. PATHS
  58. $ENV{PHYSFSDIR}/lib
  59. /usr/local/lib
  60. /usr/lib
  61. /sw/lib
  62. /opt/local/lib
  63. /opt/csw/lib
  64. /opt/lib
  65. )
  66. ENDIF(${PHYSFS_INCLUDE_DIR} MATCHES ".framework")
  67. SET(PHYSFS_FOUND "NO")
  68. IF(PHYSFS_LIBRARY)
  69. SET(PHYSFS_FOUND "YES")
  70. ENDIF(PHYSFS_LIBRARY)