FindLua50.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Locate Lua library
  2. # This module defines
  3. # LUA50_FOUND, if false, do not try to link to Lua
  4. # LUA_LIBRARIES, both lua and lualib
  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. #=============================================================================
  14. # Copyright 2007-2009 Kitware, Inc.
  15. #
  16. # Distributed under the OSI-approved BSD License (the "License");
  17. # see accompanying file Copyright.txt for details.
  18. #
  19. # This software is distributed WITHOUT ANY WARRANTY; without even the
  20. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. # See the License for more information.
  22. #=============================================================================
  23. # (To distributed this file outside of CMake, substitute the full
  24. # License text for the above reference.)
  25. FIND_PATH(LUA_INCLUDE_DIR lua.h
  26. HINTS
  27. $ENV{LUA_DIR}
  28. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  29. PATHS
  30. ~/Library/Frameworks
  31. /Library/Frameworks
  32. /usr/local
  33. /usr
  34. /sw # Fink
  35. /opt/local # DarwinPorts
  36. /opt/csw # Blastwave
  37. /opt
  38. )
  39. FIND_LIBRARY(LUA_LIBRARY_lua
  40. NAMES lua50 lua5.0 lua-5.0 lua5 lua
  41. HINTS
  42. $ENV{LUA_DIR}
  43. PATH_SUFFIXES lib64 lib
  44. PATHS
  45. ~/Library/Frameworks
  46. /Library/Frameworks
  47. /usr/local
  48. /usr
  49. /sw
  50. /opt/local
  51. /opt/csw
  52. /opt
  53. )
  54. # In an OS X framework, lualib is usually included as part of the framework
  55. # (like GLU in OpenGL.framework)
  56. IF(${LUA_LIBRARY_lua} MATCHES "framework")
  57. SET( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
  58. ELSE(${LUA_LIBRARY_lua} MATCHES "framework")
  59. FIND_LIBRARY(LUA_LIBRARY_lualib
  60. NAMES lualib50 lualib5.0 lualib5 lualib
  61. HINTS
  62. $ENV{LUALIB_DIR}
  63. $ENV{LUA_DIR}
  64. PATH_SUFFIXES lib64 lib
  65. PATHS
  66. /usr/local
  67. /usr
  68. /sw
  69. /opt/local
  70. /opt/csw
  71. /opt
  72. )
  73. IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  74. # include the math library for Unix
  75. IF(UNIX AND NOT APPLE)
  76. FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m)
  77. SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  78. # For Windows and Mac, don't need to explicitly include the math library
  79. ELSE(UNIX AND NOT APPLE)
  80. SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  81. ENDIF(UNIX AND NOT APPLE)
  82. ENDIF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  83. ENDIF(${LUA_LIBRARY_lua} MATCHES "framework")
  84. INCLUDE(FindPackageHandleStandardArgs)
  85. # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
  86. # all listed variables are TRUE
  87. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
  88. MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES)