1 # - Locate Luabind library
3 # LUABIND_LIBRARIES, the libraries to link against
4 # LUABIND_FOUND, if false, do not try to link to LUABIND
5 # LUABIND_INCLUDE_DIR, where to find headers.
8 MACRO(FIND_CORRECT_LUA_VERSION)
9 # Check Lua version linked to Luabind under Linux
10 IF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
14 SET(LUA53_LIBRARIES liblua5.3 liblua-5.3 liblua.so.5.3)
16 FOREACH(_LIB ${LUA53_LIBRARIES})
17 CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
19 MESSAGE(STATUS "Luabind is using Lua 5.3")
20 FIND_PACKAGE(Lua53 REQUIRED)
27 SET(LUA52_LIBRARIES liblua5.2 liblua-5.2 liblua.so.5.2)
29 FOREACH(_LIB ${LUA52_LIBRARIES})
30 CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
32 MESSAGE(STATUS "Luabind is using Lua 5.2")
33 FIND_PACKAGE(Lua52 REQUIRED)
41 SET(LUA51_LIBRARIES liblua5.1 liblua-5.1 liblua.so.5.1)
43 FOREACH(_LIB ${LUA51_LIBRARIES})
44 CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
46 MESSAGE(STATUS "Luabind is using Lua 5.1")
47 FIND_PACKAGE(Lua51 REQUIRED)
55 SET(LUA50_LIBRARIES liblua5.0 liblua-5.0 liblua.so.5.0)
57 FOREACH(_LIB ${LUA50_LIBRARIES})
58 CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
60 MESSAGE(STATUS "Luabind is using Lua 5.0")
61 FIND_PACKAGE(Lua50 REQUIRED)
68 MESSAGE(FATAL_ERROR "Can't determine Lua version used by Luabind")
71 # TODO: find a way to detect Lua version
73 FIND_PACKAGE(Lua53 REQUIRED)
75 FIND_PACKAGE(Lua52 REQUIRED)
77 FIND_PACKAGE(Lua51 REQUIRED)
79 FIND_PACKAGE(Lua50 REQUIRED)
84 IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
86 SET(Luabind_FIND_QUIETLY TRUE)
89 SET(LIBRARY_NAME_RELEASE)
90 SET(LIBRARY_NAME_DEBUG)
94 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua53)
95 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua53d)
98 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua53)
99 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua53d)
104 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
105 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
108 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
109 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)
114 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua51)
115 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua51d)
118 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51)
119 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d)
124 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50)
125 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d)
128 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50)
129 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d)
133 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport)
134 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd)
137 # generic libraries names
138 LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind)
139 LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
141 FIND_PACKAGE_HELPER(Luabind luabind/luabind.hpp RELEASE ${LIBRARY_NAME_RELEASE} DEBUG ${LIBRARY_NAME_DEBUG})
143 FIND_PACKAGE(Boost REQUIRED)
145 IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
146 IF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
147 # Case where both Release and Debug versions are provided
148 SET(LUABIND_FOUND TRUE)
149 SET(LUABIND_LIBRARIES optimized ${LUABIND_LIBRARY_RELEASE} debug ${LUABIND_LIBRARY_DEBUG})
150 ELSEIF(LUABIND_LIBRARY_RELEASE)
152 SET(LUABIND_FOUND TRUE)
153 SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_RELEASE})
154 ELSEIF(LUABIND_LIBRARY_DEBUG)
155 # Case where Luabind is compiled from sources (debug version is compiled by default)
156 SET(LUABIND_FOUND TRUE)
157 SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG})
162 SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
163 # Check if luabind/version.hpp exists
164 FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR})
165 IF(LUABIND_VERSION_FILE)
166 SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION")
169 FIND_CORRECT_LUA_VERSION()
171 IF(NOT Luabind_FIND_QUIETLY)
172 MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}")
175 IF(NOT Luabind_FIND_QUIETLY)
176 MESSAGE(STATUS "Warning: Unable to find Luabind!")
180 MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS)