FindLua51.cmake 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. HINTS
  15. $ENV{LUA_DIR}
  16. PATH_SUFFIXES include/lua51 include/lua5.1 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
  28. NAMES lua51 lua5.1 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. IF(LUA_LIBRARY)
  43. # include the math library for Unix
  44. IF(UNIX AND NOT APPLE)
  45. FIND_LIBRARY(LUA_MATH_LIBRARY m)
  46. SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
  47. # For Windows and Mac, don't need to explicitly include the math library
  48. ELSE(UNIX AND NOT APPLE)
  49. SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
  50. ENDIF(UNIX AND NOT APPLE)
  51. ENDIF(LUA_LIBRARY)
  52. INCLUDE(FindPackageHandleStandardArgs)
  53. # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
  54. # all listed variables are TRUE
  55. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
  56. MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)