cmake_modules/FindLua51.cmake
changeset 2804 31c6c36c5d34
parent 2803 1f446fc5c8ec
child 2805 36a8cebb91e8
equal deleted inserted replaced
2803:1f446fc5c8ec 2804:31c6c36c5d34
     1 # Find the Lua 5.1 includes and library
       
     2 #
       
     3 # LUA51_INCLUDE_DIR - where to find lua.h
       
     4 # LUA51_LIBRARIES - List of fully qualified libraries to link against
       
     5 # LUA51_FOUND - Set to TRUE if found
       
     6 
       
     7 # Copyright (c) 2007, Pau Garcia i Quiles, <pgquiles@elpauer.org>
       
     8 #
       
     9 # Redistribution and use is allowed according to the terms of the BSD license.
       
    10 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
       
    11 
       
    12 IF(LUA51_INCLUDE_DIR AND LUA51_LIBRARIES)
       
    13     SET(LUA51_FIND_QUIETLY TRUE)
       
    14 ENDIF(LUA51_INCLUDE_DIR AND LUA51_LIBRARIES)
       
    15 
       
    16 FIND_PATH(LUA51_INCLUDE_DIR lua5.1/lua.h)
       
    17 
       
    18 FIND_LIBRARY(LUA51_LIBRARIES NAMES lua5.1)
       
    19 
       
    20 IF(LUA51_INCLUDE_DIR AND LUA51_LIBRARIES)
       
    21    SET(LUA51_FOUND TRUE)
       
    22    INCLUDE(CheckLibraryExists)
       
    23    CHECK_LIBRARY_EXISTS(${LUA51_LIBRARIES} lua_close "" LUA51_NEED_PREFIX)
       
    24 ELSE(LUA51_INCLUDE_DIR AND LUA51_LIBRARIES)
       
    25    SET(LUA51_FOUND FALSE)
       
    26    MESSAGE("D'oh")
       
    27 ENDIF (LUA51_INCLUDE_DIR AND LUA51_LIBRARIES)
       
    28 
       
    29 IF(LUA51_FOUND)
       
    30   IF (NOT LUA51_FIND_QUIETLY)
       
    31     MESSAGE(STATUS "Found Lua 5.1 library: ${LUA51_LIBRARIES}")
       
    32     MESSAGE(STATUS "Found Lua 5.1 headers: ${LUA51_INCLUDE_DIR}")
       
    33   ENDIF (NOT LUA51_FIND_QUIETLY)
       
    34 ELSE(LUA51_FOUND)
       
    35   IF(LUA51_FIND_REQUIRED)
       
    36     MESSAGE(FATAL_ERROR "Could NOT find Lua 5.1")
       
    37   ENDIF(LUA51_FIND_REQUIRED)
       
    38 ENDIF(LUA51_FOUND)
       
    39 
       
    40 MARK_AS_ADVANCED(LUA51_INCLUDE_DIR LUA51_LIBRARIES)