FindLua51.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  21. NO_DEFAULT_PATH
  22. PATH_SUFFIXES include/lua51 include/lua5.1 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/lua51 include/lua5.1 include/lua include
  35. )
  36. FIND_LIBRARY(LUA_LIBRARY
  37. NAMES lua51 lua5.1 lua
  38. PATHS
  39. $ENV{LUA_DIR}
  40. NO_DEFAULT_PATH
  41. PATH_SUFFIXES lib64 lib
  42. )
  43. FIND_LIBRARY(LUA_LIBRARY
  44. NAMES lua51 lua5.1 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
  50. NAMES lua51 lua5.1 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. IF(LUA_LIBRARY)
  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};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "Lua Libraries")
  67. # For Windows and Mac, don't need to explicitly include the math library
  68. ELSE(UNIX AND NOT APPLE)
  69. SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
  70. ENDIF(UNIX AND NOT APPLE)
  71. ENDIF(LUA_LIBRARY)
  72. SET(LUA_FOUND "NO")
  73. IF(LUA_LIBRARIES AND LUA_INCLUDE_DIR)
  74. SET(LUA_FOUND "YES")
  75. ENDIF(LUA_LIBRARIES AND LUA_INCLUDE_DIR)