FindLua52.cmake 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Locate Lua library
  2. # This module defines
  3. # LUA52_FOUND, if false, do not try to link to Lua
  4. # LUA_LIBRARIES
  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. #=============================================================================
  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 distribute 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/lua52 include/lua5.2 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
  40. NAMES lua52 lua5.2 lua-5.2 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. IF(LUA_LIBRARY)
  55. # include the math library for Unix
  56. IF(UNIX AND NOT APPLE)
  57. FIND_LIBRARY(LUA_MATH_LIBRARY m)
  58. SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
  59. # For Windows and Mac, don't need to explicitly include the math library
  60. ELSE(UNIX AND NOT APPLE)
  61. SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
  62. ENDIF(UNIX AND NOT APPLE)
  63. ENDIF(LUA_LIBRARY)
  64. INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  65. # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
  66. # all listed variables are TRUE
  67. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua52 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
  68. MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)