cmake_modules/FindLua.cmake
branchhedgeroid
changeset 15515 7030706266df
parent 12767 5134c07ce32c
equal deleted inserted replaced
7861:bc7b6aa5d67a 15515:7030706266df
     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 
    17 
    10 if (ANDROID)
    18 find_path(LUA_INCLUDE_DIR lua.h
    11     SET(LUA_DEFAULT "liblua5.1.so")
    19                           PATHS /usr/include /usr/local/include /usr/pkg/include
    12 else (ANDROID)
    20                           PATH_SUFFIXES lua5.1 lua51 lua-5.1)
    13     IF(WIN32)
    21 find_library(LUA_LIBRARY NAMES liblua lua51 lua5.1 lua-5.1 lua
    14         SET(LUA_DEFAULT lua.dll)
    22                          PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib)
    15     ELSE(WIN32)
       
    16         IF(APPLE)
       
    17             SET(LUA_DEFAULT lua)
       
    18         ELSE(APPLE)
       
    19             #locate the system's lua library
       
    20             FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib)
       
    21             IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND")
       
    22 	        set(LUA_DEFAULT lua)
       
    23             ELSE()
       
    24                 set(LUA_FOUND true)
       
    25                 message(STATUS "LibLua 5.1 found at ${LUA_DEFAULT}")
       
    26                 #remove the path (fpc doesn't like it - why?)
       
    27                 GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME)
       
    28             ENDIF()
       
    29         ENDIF(APPLE)
       
    30     ENDIF(WIN32)
       
    31 ENDIF(ANDROID)
       
    32 
    23 
    33 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)
    34 
    26