FindLua51.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Locate Lua library
  2. # This module defines
  3. # LUA_LIBRARIES
  4. # LUA_FOUND, if false, do not try to link to Lua
  5. # LUA_INCLUDE_DIR, where to find lua.h
  6. #
  7. # Note that the expected include convention is
  8. # #include "lua.h"
  9. # and not
  10. # #include <lua/lua.h>
  11. # This is because, the lua location is not standardized and may exist
  12. # in locations other than lua/
  13. FIND_PATH(LUA_INCLUDE_DIR lua.h
  14. PATHS
  15. $ENV{LUA_DIR}
  16. NO_DEFAULT_PATH
  17. PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
  18. )
  19. FIND_PATH(LUA_INCLUDE_DIR lua.h
  20. PATHS
  21. ~/Library/Frameworks
  22. /Library/Frameworks
  23. /usr/local
  24. /usr
  25. /sw # Fink
  26. /opt/local # DarwinPorts
  27. /opt/csw # Blastwave
  28. /opt
  29. PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
  30. )
  31. FIND_LIBRARY(LUA_LIBRARY
  32. NAMES lua51 lua5.1 lua
  33. PATHS
  34. $ENV{LUA_DIR}
  35. NO_DEFAULT_PATH
  36. PATH_SUFFIXES lib64 lib
  37. )
  38. FIND_LIBRARY(LUA_LIBRARY
  39. NAMES lua51 lua5.1 lua
  40. PATHS
  41. ~/Library/Frameworks
  42. /Library/Frameworks
  43. /usr/local
  44. /usr
  45. /sw
  46. /opt/local
  47. /opt/csw
  48. /opt
  49. PATH_SUFFIXES lib64 lib
  50. )
  51. IF(LUA_LIBRARY)
  52. # include the math library for Unix
  53. IF(UNIX AND NOT APPLE)
  54. FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m)
  55. SET( LUA_LIBRARIES "${LUA_LIBRARY};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "Lua Libraries")
  56. # For Windows and Mac, don't need to explicitly include the math library
  57. ELSE(UNIX AND NOT APPLE)
  58. SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
  59. ENDIF(UNIX AND NOT APPLE)
  60. ENDIF(LUA_LIBRARY)
  61. SET(LUA_FOUND "NO")
  62. IF(LUA_LIBRARIES AND LUA_INCLUDE_DIR)
  63. SET(LUA_FOUND "YES")
  64. ENDIF(LUA_LIBRARIES AND LUA_INCLUDE_DIR)