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 HUNTER_ADD_PACKAGE(Lua)
74 FIND_PACKAGE(Lua CONFIG REQUIRED)
75 SET(LUA_LIBRARIES Lua::lua_lib)
77 FIND_PACKAGE(Lua54 REQUIRED)
79 FIND_PACKAGE(Lua53 REQUIRED)
81 FIND_PACKAGE(Lua52 REQUIRED)
83 FIND_PACKAGE(Lua51 REQUIRED)
85 FIND_PACKAGE(Lua50 REQUIRED)
90 IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
92 SET(Luabind_FIND_QUIETLY TRUE)
95 SET(LIBRARY_NAME_RELEASE)
96 SET(LIBRARY_NAME_DEBUG)
100 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua54)
101 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua54d)
104 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua54)
105 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua54d)
109 LIST(APPEND LIBRARY_NAME_RELEASE luabind luabind09)
110 LIST(APPEND LIBRARY_NAME_DEBUG luabindd luabind09-d)
115 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua53)
116 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua53d)
119 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua53)
120 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua53d)
125 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
126 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
129 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
130 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)
135 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua51)
136 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua51d)
139 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51)
140 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d)
145 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50)
146 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d)
149 LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50)
150 LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d)
154 LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport)
155 LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd)
158 # generic libraries names
159 LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind)
160 LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
162 FIND_PACKAGE_HELPER(Luabind luabind/luabind.hpp RELEASE ${LIBRARY_NAME_RELEASE} DEBUG ${LIBRARY_NAME_DEBUG})
164 FIND_PACKAGE(Boost REQUIRED)
166 IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
167 IF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
168 # Case where both Release and Debug versions are provided
169 SET(LUABIND_FOUND TRUE)
170 SET(LUABIND_LIBRARIES optimized ${LUABIND_LIBRARY_RELEASE} debug ${LUABIND_LIBRARY_DEBUG})
171 ELSEIF(LUABIND_LIBRARY_RELEASE)
173 SET(LUABIND_FOUND TRUE)
174 SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_RELEASE})
175 ELSEIF(LUABIND_LIBRARY_DEBUG)
176 # Case where Luabind is compiled from sources (debug version is compiled by default)
177 SET(LUABIND_FOUND TRUE)
178 SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG})
183 SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
184 # Check if luabind/version.hpp exists
185 FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR})
186 IF(LUABIND_VERSION_FILE)
187 SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION")
190 FIND_CORRECT_LUA_VERSION()
192 IF(NOT Luabind_FIND_QUIETLY)
193 MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}")
196 IF(NOT Luabind_FIND_QUIETLY)
197 MESSAGE(STATUS "Warning: Unable to find Luabind!")
201 MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS)