FindSDL_net.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # - Locate the SDL_net library
  2. # This module defines
  3. # SDLNET_LIBRARY, the library to link against
  4. # SDLNET_FOUND, if false, do not try to link against
  5. # SDLNET_INCLUDE_DIR, where to find the headers
  6. #
  7. # $SDLDIR is an environment variable that would
  8. # correspond to the ./configure --prefix=$SDLDIR
  9. # used in building SDL.
  10. #
  11. # Created by Eric Wing. This was influenced by the FindSDL.cmake
  12. # module, but with modifications to recognize OS X frameworks and
  13. # additional Unix paths (FreeBSD, etc).
  14. # On OSX, this will prefer the Framework version (if found) over others.
  15. # People will have to manually change the cache values of
  16. # SDLNET_LIBRARY to override this selection.
  17. FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h
  18. $ENV{SDLNETDIR}/include
  19. $ENV{SDLDIR}/include
  20. ~/Library/Frameworks/SDL_net.framework/Headers
  21. /Library/Frameworks/SDL_net.framework/Headers
  22. /usr/local/include/SDL
  23. /usr/include/SDL
  24. /usr/local/include/SDL12
  25. /usr/local/include/SDL11 # FreeBSD ports
  26. /usr/include/SDL12
  27. /usr/include/SDL11
  28. /usr/local/include
  29. /usr/include
  30. /sw/include/SDL # Fink
  31. /sw/include
  32. /opt/local/include/SDL # DarwinPorts
  33. /opt/local/include
  34. /opt/csw/include/SDL # Blastwave
  35. /opt/csw/include
  36. /opt/include/SDL
  37. /opt/include
  38. )
  39. # I'm not sure if I should do a special casing for Apple. It is
  40. # unlikely that other Unix systems will find the framework path.
  41. # But if they do ([Next|Open|GNU]Step?),
  42. # do they want the -framework option also?
  43. IF(${SDLNET_INCLUDE_DIR} MATCHES ".framework")
  44. # Extract the path the framework resides in so we can use it for the -F flag
  45. STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" SDLNET_FRAMEWORK_PATH_TEMP ${SDLNET_INCLUDE_DIR})
  46. IF("${SDLNET_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
  47. OR "${SDLNET_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
  48. )
  49. # String is in default search path, don't need to use -F
  50. SET(SDLNET_LIBRARY "-framework SDL_net" CACHE STRING "SDL_net framework for OSX")
  51. ELSE("${SDLNET_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
  52. OR "${SDLNET_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
  53. )
  54. # String is not /Library/Frameworks, need to use -F
  55. SET(SDLNET_LIBRARY "-F${SDLNET_FRAMEWORK_PATH_TEMP} -framework SDL_net" CACHE STRING "SDL_net framework for OSX")
  56. ENDIF("${SDLNET_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
  57. OR "${SDLNET_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
  58. )
  59. # Clear the temp variable so nobody can see it
  60. SET(SDLNET_FRAMEWORK_PATH_TEMP "" CACHE INTERNAL "")
  61. ELSE(${SDLNET_INCLUDE_DIR} MATCHES ".framework")
  62. FIND_LIBRARY(SDLNET_LIBRARY
  63. NAMES SDL_net
  64. PATHS
  65. $ENV{SDLNET}/lib
  66. $ENV{SDLDIR}/lib
  67. /usr/local/lib
  68. /usr/lib
  69. /sw/lib
  70. /opt/local/lib
  71. /opt/csw/lib
  72. /opt/lib
  73. )
  74. ENDIF(${SDLNET_INCLUDE_DIR} MATCHES ".framework")
  75. SET(SDLNET_FOUND "NO")
  76. IF(SDLNET_LIBRARY)
  77. SET(SDLNET_FOUND "YES")
  78. ENDIF(SDLNET_LIBRARY)