1 ### SuperTux - Removed unused vorbisenc library |
|
2 |
|
3 # - Try to find the OggVorbis libraries |
1 # - Try to find the OggVorbis libraries |
4 # Once done this will define |
2 # Once done this will define |
5 # |
3 # |
6 # OGGVORBIS_FOUND - system has OggVorbis |
4 # OGGVORBIS_FOUND - system has both Ogg and Vorbis |
7 # OGGVORBIS_VERSION - set either to 1 or 2 |
5 # OGGVORBIS_VERSION - set either to 1 or 2 |
8 # OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory |
6 # OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory |
9 # OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis |
7 # OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis |
10 # OGG_LIBRARY - The Ogg library |
8 # |
11 # VORBIS_LIBRARY - The Vorbis library |
9 # OGG_LIBRARY - The Ogg library |
12 # VORBISFILE_LIBRARY - The VorbisFile library |
10 # OGG_INCLUDE_DIR - The Ogg include directory |
|
11 # VORBIS_LIBRARY - The Vorbis library |
|
12 # VORBIS_INCLUDE_DIR - The Vorbis include directory |
|
13 # VORBISFILE_LIBRARY - The VorbisFile library |
|
14 # |
13 # Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se> |
15 # Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se> |
|
16 # Copyright (c) 2013, Vittorio Giovara, <vittorio.giovara@gmail.com> |
14 # |
17 # |
15 # Redistribution and use is allowed according to the terms of the BSD license. |
18 # Redistribution and use is allowed according to the terms of the BSD license. |
16 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
19 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
17 |
20 |
|
21 ### sommer [SuperTux] |
|
22 ## - Removed unused vorbisenc library |
|
23 ## - reversed order of libraries, so that cmake 2.4.5 for Windows generates an MSYS Makefile that will link correctly |
|
24 |
|
25 ### koda [Hedgewars] |
|
26 ## - split ogg and vorbis lookup |
|
27 ## - special case for framework handling |
|
28 ## - standard variables handling |
|
29 |
18 |
30 |
19 include (CheckLibraryExists) |
31 include (CheckLibraryExists) |
20 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) |
32 include (FindPackageHandleStandardArgs) |
21 |
33 |
22 find_library(OGG_LIBRARY NAMES ogg) |
34 find_path(OGG_INCLUDE_DIR ogg.h PATH_SUFFIXES ogg) |
23 find_library(VORBIS_LIBRARY NAMES vorbis) |
35 find_path(VORBIS_INCLUDE_DIR vorbisfile.h PATH_SUFFIXES vorbis) |
|
36 |
|
37 find_library(OGG_LIBRARY NAMES Ogg ogg) |
|
38 find_library(VORBIS_LIBRARY NAMES Vorbis vorbis) |
24 find_library(VORBISFILE_LIBRARY NAMES vorbisfile) |
39 find_library(VORBISFILE_LIBRARY NAMES vorbisfile) |
25 if(APPLE AND NOT VORBISFILE_LIBRARY) |
40 |
26 # [koda] (for Hedgewars) frameworks don't come with libvorbisfile |
41 set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) |
27 set(VORBISFILE_LIBRARY "${VORBIS_LIBRARY}") |
42 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) |
|
43 check_library_exists(${VORBIS_LIBRARY} vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) |
|
44 set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) |
|
45 |
|
46 if(HAVE_LIBVORBISENC2) |
|
47 set(OGGVORBIS_VERSION 2) |
|
48 else(HAVE_LIBVORBISENC2) |
|
49 set(OGGVORBIS_VERSION 1) |
|
50 endif(HAVE_LIBVORBISENC2) |
|
51 |
|
52 if(${OGG_LIBRARY} MATCHES ".framework" AND ${VORBIS_LIBRARY} MATCHES ".framework") |
|
53 set(VORBISFILE_LIBRARY "") #vorbisfile will appear as NOTFOUND and discarded |
|
54 set(fphsa_vorbis_list VORBIS_LIBRARY) |
|
55 else() |
|
56 set(fphsa_vorbis_list VORBISFILE_LIBRARY VORBIS_LIBRARY) |
28 endif() |
57 endif() |
29 |
58 |
30 if (OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) |
59 find_package_handle_standard_args(OggVorbis DEFAULT_MSG ${fphsa_vorbis_list} OGG_LIBRARY |
31 set(OGGVORBIS_FOUND TRUE) |
60 OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR) |
32 # [sommer] (for SuperTux) reversed order of libraries, so that cmake 2.4.5 for Windows generates an MSYS Makefile that will link correctly |
61 unset(fphsa_vorbis_list) |
33 # set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) |
|
34 set(OGGVORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) |
|
35 set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) |
|
36 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) |
|
37 check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) |
|
38 set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) |
|
39 if (HAVE_LIBVORBISENC2) |
|
40 set (OGGVORBIS_VERSION 2) |
|
41 else (HAVE_LIBVORBISENC2) |
|
42 set (OGGVORBIS_VERSION 1) |
|
43 endif (HAVE_LIBVORBISENC2) |
|
44 else () |
|
45 set(OGGVORBIS_VERSION) |
|
46 set(OGGVORBIS_FOUND FALSE) |
|
47 endif () |
|
48 if (OGGVORBIS_FOUND) |
|
49 if (NOT OggVorbis_FIND_QUIETLY) |
|
50 message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}") |
|
51 endif (NOT OggVorbis_FIND_QUIETLY) |
|
52 else (OGGVORBIS_FOUND) |
|
53 if (OggVorbis_FIND_REQUIRED) |
|
54 message(FATAL_ERROR "Could NOT find OggVorbis libraries") |
|
55 else (OggVorbis_FIND_REQUIRED) |
|
56 if (NOT OggVorbis_FIND_QUIETLY) |
|
57 message(STATUS "Could NOT find OggVorbis libraries") |
|
58 endif (NOT OggVorbis_FIND_QUIETLY) |
|
59 endif(OggVorbis_FIND_REQUIRED) |
|
60 endif (OGGVORBIS_FOUND) |
|
61 |
62 |
|
63 set(OGGVORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) |
|
64 set(OGGVORBIS_INCLUDE_DIR ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR}) |
|
65 |
|
66 mark_as_advanced(OGGVORBIS_VERSION OGGVORBIS_INCLUDE_DIR OGGVORBIS_LIBRARIES |
|
67 OGG_LIBRARY OGG_INCLUDE_DIR VORBIS_LIBRARY VORBIS_INCLUDE_DIR VORBISFILE_LIBRARY) |
|
68 |