FindLua50.cmake 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. PATHS
  15. $ENV{LUA_DIR}
  16. NO_DEFAULT_PATH
  17. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  18. )
  19. FIND_PATH(LUA_INCLUDE_DIR lua.h
  20. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  21. NO_DEFAULT_PATH
  22. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  23. )
  24. FIND_PATH(LUA_INCLUDE_DIR lua.h
  25. PATHS
  26. ~/Library/Frameworks
  27. /Library/Frameworks
  28. /usr/local
  29. /usr
  30. /sw # Fink
  31. /opt/local # DarwinPorts
  32. /opt/csw # Blastwave
  33. /opt
  34. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  35. )
  36. FIND_LIBRARY(LUA_LIBRARY_lua
  37. NAMES lua50 lua5.0 lua5 lua
  38. PATHS
  39. $ENV{LUA_DIR}
  40. NO_DEFAULT_PATH
  41. PATH_SUFFIXES lib64 lib
  42. )
  43. FIND_LIBRARY(LUA_LIBRARY_lua
  44. NAMES lua50 lua5.0 lua5 lua
  45. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  46. NO_DEFAULT_PATH
  47. PATH_SUFFIXES lib64 lib
  48. )
  49. FIND_LIBRARY(LUA_LIBRARY_lua
  50. NAMES lua50 lua5.0 lua5 lua
  51. PATHS
  52. ~/Library/Frameworks
  53. /Library/Frameworks
  54. /usr/local
  55. /usr
  56. /sw
  57. /opt/local
  58. /opt/csw
  59. /opt
  60. PATH_SUFFIXES lib64 lib
  61. )
  62. # In an OS X framework, lualib is usually included as part of the framework
  63. # (like GLU in OpenGL.framework)
  64. IF(${LUA_LIBRARY_lua} MATCHES "framework")
  65. SET( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
  66. ELSE(${LUA_LIBRARY_lua} MATCHES "framework")
  67. FIND_LIBRARY(LUA_LIBRARY_lualib
  68. NAMES lualib50 lualib5.0 lualib5 lualib
  69. PATHS
  70. $ENV{LUALIB_DIR}
  71. $ENV{LUA_DIR}
  72. NO_DEFAULT_PATH
  73. PATH_SUFFIXES lib64 lib
  74. )
  75. FIND_LIBRARY(LUA_LIBRARY_lualib
  76. NAMES lualib50 lualib5.0 lualib5 lualib
  77. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  78. NO_DEFAULT_PATH
  79. PATH_SUFFIXES lib64 lib
  80. )
  81. FIND_LIBRARY(LUA_LIBRARY_lualib
  82. NAMES lualib50 lualib5.0 lualib5 lualib
  83. PATHS
  84. /usr/local
  85. /usr
  86. /sw
  87. /opt/local
  88. /opt/csw
  89. /opt
  90. PATH_SUFFIXES lib64 lib
  91. )
  92. IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  93. # include the math library for Unix
  94. IF(UNIX AND NOT APPLE)
  95. FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m)
  96. SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  97. # For Windows and Mac, don't need to explicitly include the math library
  98. ELSE(UNIX AND NOT APPLE)
  99. SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  100. ENDIF(UNIX AND NOT APPLE)
  101. ENDIF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  102. ENDIF(${LUA_LIBRARY_lua} MATCHES "framework")
  103. SET(LUA_FOUND "NO")
  104. IF(LUA_LIBRARIES AND LUA_INCLUDE_DIR)
  105. SET(LUA_FOUND "YES")
  106. ENDIF(LUA_LIBRARIES AND LUA_INCLUDE_DIR)