1 # Find the Lua library |
1 # Find liblua |
2 # -------------------- |
2 # |
3 # On Android/Windows/OSX this just defines the name of the library that |
3 # Once done this will define |
4 # will be compiled from our bundled sources |
4 # LUA_FOUND - system has Lua |
5 # On Linux it will try to load the system library and fallback to compiling |
5 # LUA_INCLUDE_DIR - the Lua include directory |
6 # the bundled one when nothing is found |
6 # LUA_LIBRARY - The library needed to use Lua |
|
7 # Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com> |
|
8 # |
|
9 # Distributed under the OSI-approved BSD License (the "License"); |
|
10 # see accompanying file Copyright.txt for details. |
|
11 # |
|
12 # This software is distributed WITHOUT ANY WARRANTY; without even the |
|
13 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14 # See the License for more information. |
7 |
15 |
8 set(LUA_FOUND false) |
16 include(FindPackageHandleStandardArgs) |
9 set(LUA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/liblua) |
|
10 |
17 |
11 if (ANDROID) |
18 find_path(LUA_INCLUDE_DIR lua.h |
12 SET(LUA_DEFAULT "liblua5.1.so") |
19 PATHS /usr/include /usr/local/include /usr/pkg/include |
13 else (ANDROID) |
20 PATH_SUFFIXES lua5.1) |
14 IF(WIN32) |
21 find_library(LUA_LIBRARY NAMES lua51 lua5.1 lua-5.1 lua |
15 SET(LUA_DEFAULT lua.dll) |
22 PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib) |
16 ELSE(WIN32) |
|
17 IF(APPLE) |
|
18 SET(LUA_DEFAULT lua) |
|
19 ELSE(APPLE) |
|
20 #locate the system's lua library |
|
21 FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib) |
|
22 IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND") |
|
23 set(LUA_DEFAULT lua) |
|
24 ELSE() |
|
25 set(LUA_FOUND true) |
|
26 message(STATUS "LibLua 5.1 found at ${LUA_DEFAULT}") |
|
27 find_path(LUA_INCLUDE_DIR lua.h) |
|
28 #remove the path (fpc doesn't like it - why?) |
|
29 GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME) |
|
30 ENDIF() |
|
31 ENDIF(APPLE) |
|
32 ENDIF(WIN32) |
|
33 ENDIF(ANDROID) |
|
34 |
23 |
35 SET(LUA_LIBRARY ${LUA_DEFAULT} CACHE STRING "Lua library to link to; file name without path only!") |
24 find_package_handle_standard_args(Lua DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR) |
|
25 mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY) |
36 |
26 |
37 |
|