FindLua50.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #.rst:
  2. # FindLua50
  3. # ---------
  4. #
  5. #
  6. #
  7. # Locate Lua library This module defines
  8. #
  9. # ::
  10. #
  11. # LUA50_FOUND, if false, do not try to link to Lua
  12. # LUA_LIBRARIES, both lua and lualib
  13. # LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
  14. #
  15. #
  16. #
  17. # Note that the expected include convention is
  18. #
  19. # ::
  20. #
  21. # #include "lua.h"
  22. #
  23. # and not
  24. #
  25. # ::
  26. #
  27. # #include <lua/lua.h>
  28. #
  29. # This is because, the lua location is not standardized and may exist in
  30. # locations other than lua/
  31. #=============================================================================
  32. # Copyright 2007-2009 Kitware, Inc.
  33. #
  34. # Distributed under the OSI-approved BSD License (the "License");
  35. # see accompanying file Copyright.txt for details.
  36. #
  37. # This software is distributed WITHOUT ANY WARRANTY; without even the
  38. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  39. # See the License for more information.
  40. #=============================================================================
  41. # (To distribute this file outside of CMake, substitute the full
  42. # License text for the above reference.)
  43. find_path(LUA_INCLUDE_DIR lua.h
  44. HINTS
  45. ENV LUA_DIR
  46. PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
  47. PATHS
  48. ~/Library/Frameworks
  49. /Library/Frameworks
  50. /sw # Fink
  51. /opt/local # DarwinPorts
  52. /opt/csw # Blastwave
  53. /opt
  54. )
  55. find_library(LUA_LIBRARY_lua
  56. NAMES lua50 lua5.0 lua-5.0 lua5 lua
  57. HINTS
  58. ENV LUA_DIR
  59. PATH_SUFFIXES lib
  60. PATHS
  61. ~/Library/Frameworks
  62. /Library/Frameworks
  63. /sw
  64. /opt/local
  65. /opt/csw
  66. /opt
  67. )
  68. # In an OS X framework, lualib is usually included as part of the framework
  69. # (like GLU in OpenGL.framework)
  70. if(${LUA_LIBRARY_lua} MATCHES "framework")
  71. set( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
  72. else()
  73. find_library(LUA_LIBRARY_lualib
  74. NAMES lualib50 lualib5.0 lualib5 lualib
  75. HINTS
  76. ENV LUALIB_DIR
  77. ENV LUA_DIR
  78. PATH_SUFFIXES lib
  79. PATHS
  80. /sw
  81. /opt/local
  82. /opt/csw
  83. /opt
  84. )
  85. if(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
  86. # include the math library for Unix
  87. if(UNIX AND NOT APPLE)
  88. find_library(MATH_LIBRARY_FOR_LUA m)
  89. set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  90. # For Windows and Mac, don't need to explicitly include the math library
  91. else()
  92. set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
  93. endif()
  94. endif()
  95. endif()
  96. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  97. # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
  98. # all listed variables are TRUE
  99. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
  100. mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES)