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