Fixed: Clear song info when all songs are done playing.
[ryzomcore.git] / CMakeModules / FindNeL.cmake
blob96dd90b83a26d5e2a256f5520a0d67c77e2bf659
1 # NEL_DIR can be specified as root directory\r
2 \r
3 # Returned variables\r
4 # NELDRIVER_XXX_BINARY_DEBUG\r
5 # NELDRIVER_XXX_BINARY_RELEASE\r
6 # NELDRIVER_XXX_LIBRARY_DEBUG\r
7 # NELDRIVER_XXX_LIBRARY_RELEASE\r
8 # NELDRIVER_XXX_FOUND\r
9 # NEL_DEFINITIONS\r
10 # NEL_INCLUDE_DIR\r
11 # NEL_INCLUDE_DIRS\r
12 # NEL_LIBRARIES\r
13 # NELXXX_FOUND\r
14 # NELXXX_LIBRARIES\r
16 INCLUDE(FindHelpers)\r
18 # Init all variables we'll set\r
19 SET(NEL_LIBRARIES)\r
20 SET(NEL_INCLUDE_DIR)\r
21 SET(NEL_INCLUDE_DIRS)\r
22 SET(NEL_VERSION)\r
23 SET(NEL_STATIC)\r
24 SET(NEL_STATIC_DRIVERS)\r
25 SET(NEL_VERSION_MAJOR)\r
26 SET(NEL_VERSION_MINOR)\r
27 SET(NEL_VERSION_PATCH)\r
28 SET(NEL_REVISION)\r
29 SET(NEL_VERSION)\r
31 SET(NEL_MODULES_FOUND)\r
32 SET(NEL_MODULES_AVAILABLE 3d georges gui ligo logic net pacs sound) # cegui pipeline\r
34 SET(NEL_DRIVERS_FOUND)\r
35 SET(NEL_DRIVERS_AVAILABLE opengl opengles direct3d dsound fmod openal xaudio2)\r
37 SET(NELMISC_FIND_REQUIRED ${NeL_FIND_REQUIRED})\r
39 # Force search of NELMISC\r
40 FIND_PACKAGE_HELPER(nelmisc nel/misc/types_nl.h RELEASE nelmisc_r nelmisc DEBUG nelmisc_d DIR ${NEL_DIR} VERBOSE QUIET)\r
42 IF(NELMISC_FOUND)\r
43   # define NEL_DIR if not specified\r
44   IF(NOT NEL_DIR)\r
45     GET_FILENAME_COMPONENT(NEL_DIR ${NELMISC_INCLUDE_DIR}/.. ABSOLUTE)\r
46   ENDIF()\r
48   # Aliases for include directory\r
49   SET(NEL_INCLUDE_DIR ${NELMISC_INCLUDE_DIR})\r
50   SET(NEL_INCLUDE_DIRS ${NEL_INCLUDE_DIR})\r
52   MESSAGE(STATUS "Found NeL headers in ${NEL_INCLUDE_DIR}")\r
54   GET_FILENAME_COMPONENT(NEL_LIBRARY_DIR ${NELMISC_LIBRARY} DIRECTORY)\r
56   MESSAGE(STATUS "Found NeL library in ${NEL_LIBRARY_DIR}")\r
58   # TODO: implement static version checks for Windows\r
60   # static libraries\r
61   IF(UNIX)\r
62     GET_FILENAME_COMPONENT(_LIBEXT ${NELMISC_LIBRARY} EXT)\r
64     IF(_LIBEXT STREQUAL ".a")\r
65       SET(NEL_STATIC ON)\r
66       MESSAGE(STATUS "NeL is using static libraries")\r
67     ENDIF()\r
68   ENDIF()\r
70   IF(WIN32)\r
71     SET(NELDRIVER_DIRS_TO_CHECK\r
72       ${NEL_DIR}/bin${LIB_SUFFIX}\r
73       ${NEL_DIR}\r
74     )\r
75   ELSE()\r
76     SET(NELDRIVER_DIRS_TO_CHECK\r
77       /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel\r
78       /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
79       /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel\r
80       /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
81       /usr/lib/nel\r
82       /usr/lib\r
83     )\r
84   ENDIF()\r
86   # check for static drivers\r
87   FOREACH(_DRIVER ${NEL_DRIVERS_AVAILABLE})\r
88     IF(WIN32)\r
89       SET(_DRIVER_RELASE_FILE "nel_drv_${_DRIVER}_win_r")\r
90       SET(_DRIVER_DEBUG_FILE "nel_drv_${_DRIVER}_win_d")\r
91       SET(_DRIVER_SHARED_EXT dll)\r
92       SET(_DRIVER_STATIC_EXT lib)\r
93     ELSE()\r
94       SET(_DRIVER_RELEASE_FILE "nel_drv_${_DRIVER}")\r
95       SET(_DRIVER_DEBUG_FILE)\r
96       SET(_DRIVER_SHARED_EXT so)\r
97       SET(_DRIVER_STATIC_EXT a)\r
98     ENDIF()\r
100     STRING(TOUPPER ${_DRIVER} _UPDRIVER)\r
102     FOREACH(_DIR ${NELDRIVER_DIRS_TO_CHECK})\r
103       SET(_FOUND OFF)\r
105       IF(_DRIVER_RELASE_FILE)\r
106         SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}")\r
107         IF(EXISTS ${_FILE})\r
108           SET(NELDRIVER_${_UPDRIVER}_BINARY_RELEASE ${_FILE})\r
110           MESSAGE(STATUS "Found NeL release shared driver ${_DRIVER}: ${_FILE}")\r
112           SET(NEL_STATIC_DRIVERS OFF)\r
114           IF(NOT NEL_DRIVER_DIR)\r
115             SET(NEL_DRIVER_DIR ${_DIR})\r
116           ENDIF()\r
117         ENDIF()\r
119         SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}")\r
120         IF(EXISTS ${_FILE})\r
121           SET(NELDRIVER_${_UPDRIVER}_LIBRARY_RELEASE ${_FILE})\r
123           MESSAGE(STATUS "Found NeL release static driver ${_DRIVER}: ${_FILE}")\r
125           SET(NEL_STATIC_DRIVERS ON)\r
127           IF(NOT NEL_DRIVER_DIR)\r
128             SET(NEL_DRIVER_DIR ${_DIR})\r
129           ENDIF()\r
130         ENDIF()\r
131       ENDIF()\r
133       IF(_DRIVER_DEBUG_FILE)\r
134         SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}")\r
135         IF(EXISTS ${_FILE})\r
136           SET(NELDRIVER_${_UPDRIVER}_BINARY_DEBUG ${_FILE})\r
138           MESSAGE(STATUS "Found NeL debug shared driver ${_DRIVER}: ${_FILE}")\r
140           SET(NEL_STATIC_DRIVERS OFF)\r
142           IF(NOT NEL_DRIVER_DIR)\r
143             SET(NEL_DRIVER_DIR ${_DIR})\r
144           ENDIF()\r
145         ENDIF()\r
147         SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}")\r
148         IF(EXISTS ${_FILE})\r
149           SET(NELDRIVER_${_UPDRIVER}_LIBRARY_DEBUG ${_FILE})\r
151           MESSAGE(STATUS "Found NeL debug static driver ${_DRIVER}: ${_FILE}")\r
153           SET(NEL_STATIC_DRIVERS ON)\r
155           IF(NOT NEL_DRIVER_DIR)\r
156             SET(NEL_DRIVER_DIR ${_DIR})\r
157           ENDIF()\r
158         ENDIF()\r
160         IF(_FOUND)\r
161           SET(NELDRIVER_${_UPDRIVER}_FOUND ON)\r
162           LIST(APPEND NEL_DRIVERS_FOUND ${_DRIVER})\r
163         ENDIF()\r
164       ENDIF()\r
165     ENDFOREACH()\r
166   ENDFOREACH()\r
168   MESSAGE(STATUS "Found NeL driver in ${NEL_DRIVER_DIR}")\r
170   PARSE_VERSION_OTHER(${NEL_INCLUDE_DIR}/nel/misc/version_nl.h NL_VERSION_MAJOR NL_VERSION_MINOR NL_VERSION_PATCH NL_REVISION)\r
172   SET(NEL_VERSION_MAJOR ${NL_VERSION_MAJOR})\r
173   SET(NEL_VERSION_MINOR ${NL_VERSION_MINOR})\r
174   SET(NEL_VERSION_PATCH ${NL_VERSION_PATCH})\r
175   SET(NEL_REVISION ${NL_REVISION})\r
177   IF(NOT NEL_VERSION)\r
178     IF(NEL_VERSION_MAJOR OR NEL_VERSION_MINOR} OR NEL_VERSION_PATCH)\r
179       SET(NEL_VERSION "${NEL_VERSION_MAJOR}.${NEL_VERSION_MINOR}.${NEL_VERSION_PATCH}")\r
180     ELSE()\r
181       SET(NEL_VERSION "0.5.0")\r
182     ENDIF()\r
184     IF(NEL_REVISION)\r
185       SET(NEL_VERSION "${NEL_VERSION}.${NEL_REVISION}")\r
186     ENDIF()\r
187   ENDIF()\r
189   FIND_PACKAGE(PNG REQUIRED)\r
190   IF(PNG_FOUND)\r
191     LIST(APPEND NELMISC_LIBRARIES ${PNG_LIBRARIES})\r
192   ENDIF()\r
194   FIND_PACKAGE(Jpeg REQUIRED)\r
195   IF(JPEG_FOUND)\r
196     LIST(APPEND NELMISC_LIBRARIES ${JPEG_LIBRARY})\r
197   ENDIF()\r
199   FIND_PACKAGE(GIF)\r
201   IF(GIF_FOUND)\r
202     LIST(APPEND NELMISC_LIBRARIES ${GIF_LIBRARY})\r
203   ENDIF()\r
205   FIND_LIBXML2()\r
207   IF(LIBXML2_FOUND)\r
208     LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES})\r
209   ENDIF()\r
211   IF(CMAKE_DL_LIBS)\r
212     LIST(APPEND NELMISC_LIBRARIES ${CMAKE_DL_LIBS})\r
213   ENDIF()\r
215   FIND_PACKAGE(Threads)\r
217   IF(Threads_FOUND)\r
218     LIST(APPEND NELMISC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})\r
219   ENDIF()\r
220   \r
221   IF(UNIX AND NOT APPLE)\r
222     LIST(APPEND NELMISC_LIBRARIES rt)\r
223   ENDIF()\r
225   LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc)\r
227   LIST(APPEND NEL_MODULES_FOUND misc)\r
228   LIST(APPEND NEL_LIBRARIES ${NELMISC_LIBRARIES})\r
229 ENDIF()\r
231 IF(NOT NeL_FIND_COMPONENTS)\r
232   SET(NeL_FIND_COMPONENTS ${NEL_MODULES_AVAILABLE})\r
234   # We can skip not installed modules\r
235   SET(NeL_FIND_REQUIRED OFF)\r
236 ENDIF()\r
238 FOREACH(COMPONENT ${NeL_FIND_COMPONENTS})\r
239   SET(_NAME NeL${COMPONENT})\r
240   STRING(TOUPPER ${_NAME} _UPNAME)\r
242   # module is required\r
243   SET(${_NAME}_FIND_REQUIRED ${NeL_FIND_REQUIRED})\r
245   IF(COMPONENT STREQUAL "3d")\r
246     SET(HEADER_FILE shape.h)\r
247 #  ELSEIF(COMPONENT STREQUAL "cegui")\r
248 #    SET(HEADER_FILE shape.h)\r
249   ELSEIF(COMPONENT STREQUAL "georges")\r
250     SET(HEADER_FILE form.h)\r
251   ELSEIF(COMPONENT STREQUAL "gui")\r
252     SET(HEADER_FILE reflect.h)\r
253   ELSEIF(COMPONENT STREQUAL "ligo")\r
254     SET(HEADER_FILE primitive.h)\r
255   ELSEIF(COMPONENT STREQUAL "logic")\r
256     SET(HEADER_FILE logic_state.h)\r
257   ELSEIF(COMPONENT STREQUAL "net")\r
258     SET(HEADER_FILE sock.h)\r
259   ELSEIF(COMPONENT STREQUAL "pacs")\r
260     SET(HEADER_FILE primitive_block.h)\r
261 #  ELSEIF(COMPONENT STREQUAL "pipeline")\r
262 #    SET(HEADER_FILE shape.h)\r
263   ELSEIF(COMPONENT STREQUAL "sound")\r
264     SET(HEADER_FILE shape.h)\r
265   ELSE()\r
266     SET(HEADER_FILE)\r
267   ENDIF()\r
269   # display if a component has a wrong name\r
270   IF(NOT HEADER_FILE)\r
271     MESSAGE(STATUS "NeL module ${COMPONENT} not supported, ignoring it...")\r
272     CONTINUE()\r
273   ENDIF()\r
275   FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE}\r
276     RELEASE nel${COMPONENT}_r nel${COMPONENT}\r
277     DEBUG nel${COMPONENT}_d\r
278     DIR ${NEL_DIR}\r
279     QUIET)\r
281   IF(${_UPNAME}_FOUND)\r
282     LIST(APPEND NEL_MODULES_FOUND ${COMPONENT})\r
284     # all NeL libraries depend on nelmisc in static\r
285     IF(NEL_STATIC)\r
286       LIST(APPEND ${_UPNAME}_LIBRARIES ${NELMISC_LIBRARIES})\r
287     ENDIF()\r
289     IF(COMPONENT STREQUAL "3d")\r
290       IF(NEL_STATIC)\r
291         # 3rd party dependencies\r
292         FIND_PACKAGE(Freetype REQUIRED)\r
293         IF(FREETYPE_FOUND)\r
294           LIST(APPEND ${_UPNAME}_LIBRARIES ${FREETYPE_LIBRARIES})\r
295         ENDIF()\r
297         # Append static 3D drivers\r
298         IF(NEL_STATIC_DRIVERS)\r
299           # Direct3D driver (only under Windows)\r
300           IF(WIN32)\r
301             IF(NELDRIVER_DIRECT3D_LIBRARY_DEBUG)\r
302               LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_DIRECT3D_LIBRARY_DEBUG})\r
303             ENDIF()\r
305             IF(NELDRIVER_DIRECT3D_LIBRARY_RELEASE)\r
306               LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_DIRECT3D_LIBRARY_RELEASE})\r
307             ENDIF()\r
308           ENDIF()\r
310           # OpenGL driver\r
311           IF(NELDRIVER_OPENGL_LIBRARY_DEBUG)\r
312             LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_OPENGL_LIBRARY_DEBUG})\r
313           ENDIF()\r
315           IF(NELDRIVER_OPENGL_LIBRARY_RELEASE)\r
316             LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_OPENGL_LIBRARY_RELEASE})\r
317           ENDIF()\r
318         ENDIF()\r
319       ENDIF()\r
320     ELSEIF(COMPONENT STREQUAL "gui")\r
321       FIND_PACKAGE(Luabind REQUIRED)\r
323       IF(LUABIND_FOUND)\r
324         LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES})\r
325       ENDIF()\r
327       FIND_LIBCURL()\r
329       IF(CURL_FOUND)\r
330         LIST(APPEND ${_UPNAME}_LIBRARIES ${CURL_LIBRARIES})\r
331         LIST(APPEND ${_UPNAME}_DEFINITIONS ${CURL_DEFINITIONS})\r
332       ENDIF()\r
334       # TODO: remove complately OpenSSL requirement on Windows\r
336       # Only used by libcurl under Linux\r
337       FIND_PACKAGE(OpenSSL REQUIRED)\r
339       IF(WIN32)\r
340         LIST(APPEND OPENSSL_LIBRARIES Crypt32.lib)\r
341       ENDIF()\r
343       # Only Linux version of libcurl depends on OpenSSL\r
344       LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})\r
345       LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})\r
347       LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS})\r
348     ELSEIF(COMPONENT STREQUAL "sound")\r
349       FIND_PACKAGE(Ogg REQUIRED)\r
351       IF(OGG_FOUND)\r
352         LIST(APPEND ${_UPNAME}_LIBRARIES ${OGG_LIBRARY})\r
353       ENDIF()\r
355       FIND_PACKAGE(Vorbis REQUIRED)\r
357       IF(VORBIS_FOUND)\r
358         LIST(APPEND ${_UPNAME}_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})\r
359       ENDIF()\r
361       IF(NEL_STATIC)\r
362         # Link to snd_lowlevel\r
363         FIND_LIBRARY_HELPER(nelsnd_lowlevel RELEASE nelsnd_lowlevel_r DEBUG nelsnd_lowlevel_d DIR ${NEL_DIR} REQUIRED)\r
365         IF(NELSND_LOWLEVEL_LIBRARIES)\r
366           MESSAGE(STATUS "Found NeL sound lowlevel ${NELSND_LOWLEVEL_LIBRARIES}")\r
368           LIST(APPEND NELSOUND_LIBRARIES ${NELSND_LOWLEVEL_LIBRARIES})\r
370           IF(NEL_STATIC_DRIVERS)\r
371             # DirectSound, XAudio2 and FMod drivers (only under Windows)\r
372             IF(WIN32)\r
373               # DirectSound\r
374               IF(NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG)\r
375                 LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG})\r
376               ENDIF()\r
378               IF(NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE)\r
379                 LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE})\r
380               ENDIF()\r
382               # FMod\r
383               IF(NELDRIVER_FMOD_LIBRARY_DEBUG)\r
384                 LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_FMOD_LIBRARY_DEBUG})\r
385               ENDIF()\r
387               IF(NELDRIVER_FMOD_LIBRARY_RELEASE)\r
388                 LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_FMOD_LIBRARY_RELEASE})\r
389               ENDIF()\r
391               # XAudio2\r
392               IF(NELDRIVER_XAUDIO2_LIBRARY_DEBUG)\r
393                 LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_XAUDIO2_LIBRARY_DEBUG})\r
394               ENDIF()\r
396               IF(NELDRIVER_XAUDIO2_LIBRARY_RELEASE)\r
397                 LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_XAUDIO2_LIBRARY_RELEASE})\r
398               ENDIF()\r
399             ENDIF()\r
401             # OpenAL driver\r
402             IF(NELDRIVER_OPENAL_LIBRARY_DEBUG)\r
403               LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_OPENAL_LIBRARY_DEBUG})\r
404             ENDIF()\r
406             IF(NELDRIVER_OPENAL_LIBRARY_RELEASE)\r
407               LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_OPENAL_LIBRARY_RELEASE})\r
408             ENDIF()\r
409           ENDIF()\r
410         ENDIF()\r
411       ENDIF()\r
412     ENDIF()\r
414     LIST(APPEND NEL_LIBRARIES ${${_UPNAME}_LIBRARIES})\r
415   ENDIF()\r
416 ENDFOREACH()\r
418 MESSAGE_VERSION_PACKAGE_HELPER(NeL ${NEL_VERSION} ${NEL_MODULES_FOUND})\r