You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
5.2 KiB
CMake
181 lines
5.2 KiB
CMake
15 years ago
|
# - Locate Luabind library
|
||
|
# This module defines
|
||
15 years ago
|
# LUABIND_LIBRARIES, the libraries to link against
|
||
15 years ago
|
# LUABIND_FOUND, if false, do not try to link to LUABIND
|
||
|
# LUABIND_INCLUDE_DIR, where to find headers.
|
||
5 years ago
|
INCLUDE(FindHelpers)
|
||
15 years ago
|
|
||
11 years ago
|
MACRO(FIND_CORRECT_LUA_VERSION)
|
||
|
# Check Lua version linked to Luabind under Linux
|
||
|
IF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
|
||
|
INCLUDE(CheckDepends)
|
||
|
|
||
9 years ago
|
# check for Lua 5.3
|
||
9 years ago
|
SET(LUA53_LIBRARIES liblua5.3 liblua-5.3 liblua.so.5.3)
|
||
9 years ago
|
|
||
9 years ago
|
FOREACH(_LIB ${LUA53_LIBRARIES})
|
||
9 years ago
|
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
|
||
9 years ago
|
IF(LUALIB_FOUND)
|
||
|
MESSAGE(STATUS "Luabind is using Lua 5.3")
|
||
|
FIND_PACKAGE(Lua53 REQUIRED)
|
||
|
BREAK()
|
||
|
ENDIF()
|
||
|
ENDFOREACH()
|
||
11 years ago
|
|
||
9 years ago
|
IF(NOT LUALIB_FOUND)
|
||
9 years ago
|
# check for Lua 5.2
|
||
9 years ago
|
SET(LUA52_LIBRARIES liblua5.2 liblua-5.2 liblua.so.5.2)
|
||
9 years ago
|
|
||
9 years ago
|
FOREACH(_LIB ${LUA52_LIBRARIES})
|
||
9 years ago
|
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
|
||
9 years ago
|
IF(LUALIB_FOUND)
|
||
|
MESSAGE(STATUS "Luabind is using Lua 5.2")
|
||
|
FIND_PACKAGE(Lua52 REQUIRED)
|
||
|
BREAK()
|
||
|
ENDIF()
|
||
|
ENDFOREACH()
|
||
|
ENDIF()
|
||
11 years ago
|
|
||
9 years ago
|
IF(NOT LUALIB_FOUND)
|
||
|
# check for Lua 5.1
|
||
|
SET(LUA51_LIBRARIES liblua5.1 liblua-5.1 liblua.so.5.1)
|
||
11 years ago
|
|
||
9 years ago
|
FOREACH(_LIB ${LUA51_LIBRARIES})
|
||
9 years ago
|
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
|
||
11 years ago
|
IF(LUALIB_FOUND)
|
||
9 years ago
|
MESSAGE(STATUS "Luabind is using Lua 5.1")
|
||
|
FIND_PACKAGE(Lua51 REQUIRED)
|
||
9 years ago
|
BREAK()
|
||
9 years ago
|
ENDIF()
|
||
9 years ago
|
ENDFOREACH()
|
||
|
ENDIF()
|
||
|
|
||
|
IF(NOT LUALIB_FOUND)
|
||
|
# check for Lua 5.0
|
||
|
SET(LUA50_LIBRARIES liblua5.0 liblua-5.0 liblua.so.5.0)
|
||
|
|
||
|
FOREACH(_LIB ${LUA50_LIBRARIES})
|
||
9 years ago
|
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
|
||
9 years ago
|
IF(LUALIB_FOUND)
|
||
|
MESSAGE(STATUS "Luabind is using Lua 5.0")
|
||
|
FIND_PACKAGE(Lua50 REQUIRED)
|
||
|
BREAK()
|
||
|
ENDIF()
|
||
|
ENDFOREACH()
|
||
|
ENDIF()
|
||
|
|
||
|
IF(NOT LUALIB_FOUND)
|
||
|
MESSAGE(FATAL_ERROR "Can't determine Lua version used by Luabind")
|
||
9 years ago
|
ENDIF()
|
||
|
ELSE()
|
||
11 years ago
|
# TODO: find a way to detect Lua version
|
||
9 years ago
|
IF(WITH_LUA53)
|
||
|
FIND_PACKAGE(Lua53 REQUIRED)
|
||
|
ELSEIF(WITH_LUA52)
|
||
11 years ago
|
FIND_PACKAGE(Lua52 REQUIRED)
|
||
|
ELSEIF(WITH_LUA51)
|
||
|
FIND_PACKAGE(Lua51 REQUIRED)
|
||
9 years ago
|
ELSE()
|
||
11 years ago
|
FIND_PACKAGE(Lua50 REQUIRED)
|
||
9 years ago
|
ENDIF()
|
||
|
ENDIF()
|
||
|
ENDMACRO()
|
||
11 years ago
|
|
||
15 years ago
|
IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
|
||
15 years ago
|
# in cache already
|
||
14 years ago
|
SET(Luabind_FIND_QUIETLY TRUE)
|
||
9 years ago
|
ENDIF()
|
||
15 years ago
|
|
||
10 years ago
|
SET(LIBRARY_NAME_RELEASE)
|
||
|
SET(LIBRARY_NAME_DEBUG)
|
||
|
|
||
9 years ago
|
IF(WITH_LUA53)
|
||
|
IF(WITH_STLPORT)
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua53)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua53d)
|
||
|
ENDIF()
|
||
|
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua53)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua53d)
|
||
|
ENDIF()
|
||
|
|
||
10 years ago
|
IF(WITH_LUA52)
|
||
|
IF(WITH_STLPORT)
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
|
||
9 years ago
|
ENDIF()
|
||
10 years ago
|
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)
|
||
|
ENDIF()
|
||
|
|
||
|
IF(WITH_LUA51)
|
||
|
IF(WITH_STLPORT)
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua51)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua51d)
|
||
9 years ago
|
ENDIF()
|
||
10 years ago
|
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d)
|
||
|
ENDIF()
|
||
|
|
||
|
IF(WITH_LUA50)
|
||
|
IF(WITH_STLPORT)
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d)
|
||
9 years ago
|
ENDIF()
|
||
10 years ago
|
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d)
|
||
|
ENDIF()
|
||
14 years ago
|
|
||
14 years ago
|
IF(WITH_STLPORT)
|
||
10 years ago
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd)
|
||
8 years ago
|
ENDIF()
|
||
15 years ago
|
|
||
10 years ago
|
# generic libraries names
|
||
|
LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind)
|
||
|
LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
|
||
|
|
||
5 years ago
|
FIND_PACKAGE_HELPER(Luabind luabind/luabind.hpp RELEASE ${LIBRARY_NAME_RELEASE} DEBUG ${LIBRARY_NAME_DEBUG})
|
||
15 years ago
|
|
||
14 years ago
|
FIND_PACKAGE(Boost REQUIRED)
|
||
|
|
||
|
IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
|
||
14 years ago
|
IF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
|
||
|
# Case where both Release and Debug versions are provided
|
||
14 years ago
|
SET(LUABIND_FOUND TRUE)
|
||
14 years ago
|
SET(LUABIND_LIBRARIES optimized ${LUABIND_LIBRARY_RELEASE} debug ${LUABIND_LIBRARY_DEBUG})
|
||
|
ELSEIF(LUABIND_LIBRARY_RELEASE)
|
||
|
# Normal case
|
||
|
SET(LUABIND_FOUND TRUE)
|
||
|
SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_RELEASE})
|
||
|
ELSEIF(LUABIND_LIBRARY_DEBUG)
|
||
|
# Case where Luabind is compiled from sources (debug version is compiled by default)
|
||
|
SET(LUABIND_FOUND TRUE)
|
||
|
SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG})
|
||
8 years ago
|
ENDIF()
|
||
9 years ago
|
ENDIF()
|
||
15 years ago
|
|
||
|
IF(LUABIND_FOUND)
|
||
14 years ago
|
SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
|
||
14 years ago
|
# Check if luabind/version.hpp exists
|
||
|
FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR})
|
||
|
IF(LUABIND_VERSION_FILE)
|
||
14 years ago
|
SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION")
|
||
9 years ago
|
ENDIF()
|
||
11 years ago
|
|
||
|
FIND_CORRECT_LUA_VERSION()
|
||
|
|
||
14 years ago
|
IF(NOT Luabind_FIND_QUIETLY)
|
||
15 years ago
|
MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}")
|
||
8 years ago
|
ENDIF()
|
||
9 years ago
|
ELSE()
|
||
14 years ago
|
IF(NOT Luabind_FIND_QUIETLY)
|
||
15 years ago
|
MESSAGE(STATUS "Warning: Unable to find Luabind!")
|
||
9 years ago
|
ENDIF()
|
||
8 years ago
|
ENDIF()
|
||
15 years ago
|
|
||
14 years ago
|
MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS)
|