FindLua50.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Locate Lua library
  2. # This module defines
  3. # LUA_LIBRARIES, both lua and lualib
  4. # LUA_FOUND, if false, do not try to link to Lua
  5. # LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.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. HINTS
  15. $ENV{LUA_DIR}
  16. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  17. PATHS
  18. ~/Library/Frameworks
  19. /Library/Frameworks
  20. /usr/local
  21. /usr
  22. /sw # Fink
  23. /opt/local # DarwinPorts
  24. /opt/csw # Blastwave
  25. /opt
  26. )
  27. FIND_LIBRARY(LUA_LIBRARY_lua
  28. NAMES lua50 lua5.0 lua5 lua
  29. HINTS
  30. $ENV{LUA_DIR}
  31. PATH_SUFFIXES lib64 lib
  32. PATHS
  33. ~/Library/Frameworks
  34. /Library/Frameworks
  35. /usr/local
  36. /usr
  37. /sw
  38. /opt/local
  39. /opt/csw
  40. /opt
  41. )
  42. # In an OS X framework, lualib is usually included as part of the framework
  43. # (like GLU in OpenGL.framework)
  44. IF(${LUA_LIBRARY_lua} MATCHES "framework")
  45. SET( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
  46. ELSE(${LUA_LIBRARY_lua} MATCHES "framework")
  47. FIND_LIBRARY(LUA_LIBRARY_lualib
  48. NAMES lualib50 lualib5.0 lualib5 lualib
  49. HINTS
  50. $ENV{LUALIB_DIR}
  51. $ENV{LUA_DIR}
  52. PATH_SUFFIXES lib64 lib
  53. PATHS
  54. /usr/local
  55. /usr
  56. /sw
  57. /opt/local
  58. /opt/csw
  59. /opt
  60. )
  61. IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  62. # include the math library for Unix
  63. IF(UNIX AND NOT APPLE)
  64. FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m)
  65. SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  66. # For Windows and Mac, don't need to explicitly include the math library
  67. ELSE(UNIX AND NOT APPLE)
  68. SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  69. ENDIF(UNIX AND NOT APPLE)
  70. ENDIF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  71. ENDIF(${LUA_LIBRARY_lua} MATCHES "framework")
  72. INCLUDE(FindPackageHandleStandardArgs)
  73. # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
  74. # all listed variables are TRUE
  75. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
  76. MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES)