1
0

FindLua50.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindLua50
  5. ---------
  6. Locate Lua library This module defines
  7. ::
  8. LUA50_FOUND, if false, do not try to link to Lua
  9. LUA_LIBRARIES, both lua and lualib
  10. LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
  11. Note that the expected include convention is
  12. ::
  13. #include "lua.h"
  14. and not
  15. ::
  16. #include <lua/lua.h>
  17. This is because, the lua location is not standardized and may exist in
  18. locations other than lua/
  19. #]=======================================================================]
  20. find_path(LUA_INCLUDE_DIR lua.h
  21. HINTS
  22. ENV LUA_DIR
  23. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  24. PATHS
  25. ~/Library/Frameworks
  26. /Library/Frameworks
  27. /sw # Fink
  28. /opt/local # DarwinPorts
  29. /opt/csw # Blastwave
  30. /opt
  31. )
  32. find_library(LUA_LIBRARY_lua
  33. NAMES lua50 lua5.0 lua-5.0 lua5 lua
  34. HINTS
  35. ENV LUA_DIR
  36. PATH_SUFFIXES lib
  37. PATHS
  38. ~/Library/Frameworks
  39. /Library/Frameworks
  40. /sw
  41. /opt/local
  42. /opt/csw
  43. /opt
  44. )
  45. # In an OS X framework, lualib is usually included as part of the framework
  46. # (like GLU in OpenGL.framework)
  47. if(${LUA_LIBRARY_lua} MATCHES "framework")
  48. set( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
  49. else()
  50. find_library(LUA_LIBRARY_lualib
  51. NAMES lualib50 lualib5.0 lualib5 lualib
  52. HINTS
  53. ENV LUALIB_DIR
  54. ENV LUA_DIR
  55. PATH_SUFFIXES lib
  56. PATHS
  57. /sw
  58. /opt/local
  59. /opt/csw
  60. /opt
  61. )
  62. if(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  63. # include the math library for Unix
  64. if(UNIX AND NOT APPLE)
  65. find_library(MATH_LIBRARY_FOR_LUA m)
  66. set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatenation of lua and lualib libraries")
  67. # For Windows and Mac, don't need to explicitly include the math library
  68. else()
  69. set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatenation of lua and lualib libraries")
  70. endif()
  71. endif()
  72. endif()
  73. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  74. # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
  75. # all listed variables are TRUE
  76. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
  77. mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES)