Fixed: Clear song info when all songs are done playing.
[ryzomcore.git] / CMakeModules / FindLuabind.cmake
blobdae1dbd99f83ed7788413f08dc0436d78b68acc6
1 # - Locate Luabind library
2 # This module defines
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.
6 INCLUDE(FindHelpers)
8 MACRO(FIND_CORRECT_LUA_VERSION)
9   # Check Lua version linked to Luabind under Linux
10   IF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
11     INCLUDE(CheckDepends)
13     # check for Lua 5.3
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)
18       IF(LUALIB_FOUND)
19         MESSAGE(STATUS "Luabind is using Lua 5.3")
20         FIND_PACKAGE(Lua53 REQUIRED)
21         BREAK()
22       ENDIF()
23     ENDFOREACH()
25     IF(NOT LUALIB_FOUND)
26       # check for Lua 5.2
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)
31         IF(LUALIB_FOUND)
32           MESSAGE(STATUS "Luabind is using Lua 5.2")
33           FIND_PACKAGE(Lua52 REQUIRED)
34           BREAK()
35         ENDIF()
36       ENDFOREACH()
37     ENDIF()
39     IF(NOT LUALIB_FOUND)
40       # check for Lua 5.1
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)
45         IF(LUALIB_FOUND)
46           MESSAGE(STATUS "Luabind is using Lua 5.1")
47           FIND_PACKAGE(Lua51 REQUIRED)
48           BREAK()
49         ENDIF()
50       ENDFOREACH()
51     ENDIF()
53     IF(NOT LUALIB_FOUND)
54       # check for Lua 5.0
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)
59         IF(LUALIB_FOUND)
60           MESSAGE(STATUS "Luabind is using Lua 5.0")
61           FIND_PACKAGE(Lua50 REQUIRED)
62           BREAK()
63         ENDIF()
64       ENDFOREACH()
65     ENDIF()
67     IF(NOT LUALIB_FOUND)
68       MESSAGE(FATAL_ERROR "Can't determine Lua version used by Luabind")
69     ENDIF()
70   ELSE()
71     # TODO: find a way to detect Lua version
72     IF(WITH_LUA53)
73       FIND_PACKAGE(Lua53 REQUIRED)
74     ELSEIF(WITH_LUA52)
75       FIND_PACKAGE(Lua52 REQUIRED)
76     ELSEIF(WITH_LUA51)
77       FIND_PACKAGE(Lua51 REQUIRED)
78     ELSE()
79       FIND_PACKAGE(Lua50 REQUIRED)
80     ENDIF()
81   ENDIF()
82 ENDMACRO()
84 IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
85   # in cache already
86   SET(Luabind_FIND_QUIETLY TRUE)
87 ENDIF()
89 SET(LIBRARY_NAME_RELEASE)
90 SET(LIBRARY_NAME_DEBUG)
92 IF(WITH_LUA53)
93   IF(WITH_STLPORT)
94     LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua53)
95     LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua53d)
96   ENDIF()
98   LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua53)
99   LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua53d)
100 ENDIF()
102 IF(WITH_LUA52)
103   IF(WITH_STLPORT)
104     LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
105     LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
106   ENDIF()
108   LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
109   LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)
110 ENDIF()
112 IF(WITH_LUA51)
113   IF(WITH_STLPORT)
114     LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua51)
115     LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua51d)
116   ENDIF()
118   LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51)
119   LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d)
120 ENDIF()
122 IF(WITH_LUA50)
123   IF(WITH_STLPORT)
124     LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50)
125     LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d)
126   ENDIF()
128   LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50)
129   LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d)
130 ENDIF()
132 IF(WITH_STLPORT)
133   LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport)
134   LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd)
135 ENDIF()
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)
151     # Normal case
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})
158   ENDIF()
159 ENDIF()
161 IF(LUABIND_FOUND)
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")
167   ENDIF()
169   FIND_CORRECT_LUA_VERSION()
171   IF(NOT Luabind_FIND_QUIETLY)
172     MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}")
173   ENDIF()
174 ELSE()
175   IF(NOT Luabind_FIND_QUIETLY)
176     MESSAGE(STATUS "Warning: Unable to find Luabind!")
177   ENDIF()
178 ENDIF()
180 MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS)