| 1 |
#[=======================================================================[.rst: |
| 2 |
FindVorbis |
| 3 |
------- |
| 4 |
|
| 5 |
Finds the Vorbis libraries. |
| 6 |
|
| 7 |
Imported Targets |
| 8 |
^^^^^^^^^^^^^^^^ |
| 9 |
|
| 10 |
This module provides the following imported targets, if found: |
| 11 |
|
| 12 |
``Vorbis::vorbis`` |
| 13 |
The base encoder and decoder library |
| 14 |
``Vorbis::vorbisenc`` |
| 15 |
The high-level encoder library |
| 16 |
``Vorbis::vorbisfile`` |
| 17 |
The high-level decoder library |
| 18 |
|
| 19 |
Result Variables |
| 20 |
^^^^^^^^^^^^^^^^ |
| 21 |
|
| 22 |
This will define the following variables: |
| 23 |
|
| 24 |
``Vorbis_FOUND`` |
| 25 |
True if the system has all the requested components. |
| 26 |
``Vorbis_Vorbis_FOUND`` |
| 27 |
True if vorbis is found |
| 28 |
``Vorbis_Enc_FOUND`` |
| 29 |
True if vorbisenc is found |
| 30 |
``Vorbis_File_FOUND`` |
| 31 |
True if vorbisfile is found |
| 32 |
|
| 33 |
Cache Variables |
| 34 |
^^^^^^^^^^^^^^^ |
| 35 |
|
| 36 |
The following cache variables may also be set: |
| 37 |
|
| 38 |
``Vorbis_INCLUDE_DIR`` |
| 39 |
The directory containing ``vorbis/vorbis.h``. |
| 40 |
``Vorbis_Vorbis_DLL`` |
| 41 |
The path to the vorbis Windows runtime. |
| 42 |
``Vorbis_Enc_DLL`` |
| 43 |
The path to the vorbisenc Windows runtime. |
| 44 |
``Vorbis_File_DLL`` |
| 45 |
The path to the vorbisfile Windows runtime. |
| 46 |
``Vorbis_Vorbis_LIBRARY`` |
| 47 |
The path to the vorbis library. |
| 48 |
``Vorbis_Enc_LIBRARY`` |
| 49 |
The path to the vorbisenc library. |
| 50 |
``Vorbis_File_LIBRARY`` |
| 51 |
The path to the vorbisfile library. |
| 52 |
|
| 53 |
#]=======================================================================] |
| 54 |
|
| 55 |
find_package(PkgConfig QUIET) |
| 56 |
pkg_check_modules(PC_vorbis IMPORTED_TARGET vorbis) |
| 57 |
pkg_check_modules(PC_vorbisenc IMPORTED_TARGET vorbisenc) |
| 58 |
pkg_check_modules(PC_vorbisfile IMPORTED_TARGET vorbisfile) |
| 59 |
|
| 60 |
if(PC_vorbis_FOUND AND PC_vorbisenc_FOUND AND PC_vorbisfile_FOUND) |
| 61 |
if(NOT TARGET Vorbis::vorbis) |
| 62 |
add_library(Vorbis::vorbis ALIAS PkgConfig::PC_vorbis) |
| 63 |
set(Vorbis_Vorbis_FOUND TRUE) |
| 64 |
endif() |
| 65 |
if(NOT TARGET Vorbis::vorbisenc) |
| 66 |
add_library(Vorbis::vorbisenc ALIAS PkgConfig::PC_vorbisenc) |
| 67 |
set(Vorbis_Enc_FOUND TRUE) |
| 68 |
endif() |
| 69 |
if(NOT TARGET Vorbis::vorbisfile) |
| 70 |
add_library(Vorbis::vorbisfile ALIAS PkgConfig::PC_vorbisfile) |
| 71 |
set(Vorbis_File_FOUND TRUE) |
| 72 |
endif() |
| 73 |
set(Vorbis_FOUND TRUE) |
| 74 |
set(Vorbis_VERSION ${PC_Vorbis_VERSION}) |
| 75 |
return() |
| 76 |
endif() |
| 77 |
|
| 78 |
find_path( |
| 79 |
Vorbis_INCLUDE_DIR |
| 80 |
NAMES vorbis/codec.h |
| 81 |
) |
| 82 |
|
| 83 |
find_file( |
| 84 |
Vorbis_Vorbis_DLL |
| 85 |
NAMES vorbis.dll libvorbis.dll libvorbis-0.dll |
| 86 |
PATH_SUFFIXES bin |
| 87 |
) |
| 88 |
|
| 89 |
find_file( |
| 90 |
Vorbis_Enc_DLL |
| 91 |
NAMES vorbisenc.dll libvorbisenc.dll libvorbisenc-2.dll |
| 92 |
PATH_SUFFIXES bin |
| 93 |
) |
| 94 |
|
| 95 |
find_file( |
| 96 |
Vorbis_File_DLL |
| 97 |
NAMES vorbisfile.dll libvorbisfile.dll libvorbisfile-3.dll |
| 98 |
PATH_SUFFIXES bin |
| 99 |
) |
| 100 |
|
| 101 |
find_library( |
| 102 |
Vorbis_Vorbis_LIBRARY |
| 103 |
NAMES vorbis |
| 104 |
) |
| 105 |
|
| 106 |
find_library( |
| 107 |
Vorbis_Enc_LIBRARY |
| 108 |
NAMES vorbisenc |
| 109 |
) |
| 110 |
|
| 111 |
find_library( |
| 112 |
Vorbis_File_LIBRARY |
| 113 |
NAMES vorbisfile |
| 114 |
) |
| 115 |
|
| 116 |
if(Vorbis_Vorbis_DLL OR Vorbis_Vorbis_LIBRARY MATCHES ".so|.dylib") |
| 117 |
set(_vorbis_library_type SHARED) |
| 118 |
else() |
| 119 |
set(_vorbis_library_type STATIC) |
| 120 |
endif() |
| 121 |
|
| 122 |
if(Vorbis_Enc_DLL OR Vorbis_Enc_LIBRARY MATCHES ".so|.dylib") |
| 123 |
set(_vorbisenc_library_type SHARED) |
| 124 |
else() |
| 125 |
set(_vorbisenc_library_type STATIC) |
| 126 |
endif() |
| 127 |
|
| 128 |
if(Vorbis_File_DLL OR Vorbis_File_LIBRARY MATCHES ".so|.dylib") |
| 129 |
set(_vorbisfile_library_type SHARED) |
| 130 |
else() |
| 131 |
set(_vorbisfile_library_type STATIC) |
| 132 |
endif() |
| 133 |
|
| 134 |
find_library(_has_math_lib NAMES m) |
| 135 |
if(_has_math_lib) |
| 136 |
list(APPEND _vorbis_link_libraries m) |
| 137 |
endif() |
| 138 |
include(CMakeFindDependencyMacro) |
| 139 |
find_dependency(Ogg) |
| 140 |
list(APPEND _vorbis_link_libraries Ogg::ogg) |
| 141 |
set(_vorbisenc_link_libraries Vorbis::vorbis) |
| 142 |
set(_vorbisfile_link_libraries Vorbis::vorbis) |
| 143 |
|
| 144 |
foreach(_component "Vorbis" "Enc" "File") |
| 145 |
if(Vorbis_${_component}_LIBRARY) |
| 146 |
set(Vorbis_${_component}_FOUND "TRUE") |
| 147 |
else() |
| 148 |
set(Vorbis_${_component}_FOUND "FALSE") |
| 149 |
endif() |
| 150 |
endforeach() |
| 151 |
|
| 152 |
include(FindPackageHandleStandardArgs) |
| 153 |
find_package_handle_standard_args( |
| 154 |
Vorbis |
| 155 |
REQUIRED_VARS "Vorbis_File_LIBRARY" |
| 156 |
"Vorbis_Vorbis_LIBRARY" |
| 157 |
"Vorbis_INCLUDE_DIR" |
| 158 |
HANDLE_COMPONENTS |
| 159 |
) |
| 160 |
|
| 161 |
if(Vorbis_Vorbis_FOUND AND NOT TARGET Vorbis::vorbis) |
| 162 |
add_library(Vorbis::vorbis ${_vorbis_library_type} IMPORTED) |
| 163 |
set_target_properties( |
| 164 |
Vorbis::vorbis |
| 165 |
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}" |
| 166 |
INTERFACE_LINK_LIBRARIES "${_vorbis_link_libraries}" |
| 167 |
) |
| 168 |
if(Vorbis_Vorbis_DLL) |
| 169 |
set_target_properties( |
| 170 |
Vorbis::vorbis |
| 171 |
PROPERTIES IMPORTED_LOCATION "${Vorbis_Vorbis_DLL}" |
| 172 |
IMPORTED_IMPLIB "${Vorbis_Vorbis_LIBRARY}" |
| 173 |
) |
| 174 |
else() |
| 175 |
set_target_properties( |
| 176 |
Vorbis::vorbis |
| 177 |
PROPERTIES IMPORTED_LOCATION "${Vorbis_Vorbis_LIBRARY}" |
| 178 |
) |
| 179 |
endif() |
| 180 |
endif() |
| 181 |
|
| 182 |
if(Vorbis_Enc_FOUND AND NOT TARGET Vorbis::vorbisenc) |
| 183 |
add_library(Vorbis::vorbisenc ${_vorbisenc_library_type} IMPORTED) |
| 184 |
set_target_properties( |
| 185 |
Vorbis::vorbisenc |
| 186 |
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}" |
| 187 |
INTERFACE_LINK_LIBRARIES "${_vorbisenc_link_libraries}" |
| 188 |
) |
| 189 |
if(Vorbis_Enc_DLL) |
| 190 |
set_target_properties( |
| 191 |
Vorbis::vorbisenc |
| 192 |
PROPERTIES IMPORTED_LOCATION "${Vorbis_Enc_DLL}" |
| 193 |
IMPORTED_IMPLIB "${Vorbis_Enc_LIBRARY}" |
| 194 |
) |
| 195 |
else() |
| 196 |
set_target_properties( |
| 197 |
Vorbis::vorbisenc |
| 198 |
PROPERTIES IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}" |
| 199 |
) |
| 200 |
endif() |
| 201 |
endif() |
| 202 |
|
| 203 |
if(Vorbis_File_FOUND AND NOT TARGET Vorbis::vorbisfile) |
| 204 |
add_library(Vorbis::vorbisfile ${_vorbisfile_library_type} IMPORTED) |
| 205 |
set_target_properties( |
| 206 |
Vorbis::vorbisfile |
| 207 |
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}" |
| 208 |
INTERFACE_LINK_LIBRARIES "${_vorbisfile_link_libraries}" |
| 209 |
) |
| 210 |
if(Vorbis_File_DLL) |
| 211 |
set_target_properties( |
| 212 |
Vorbis::vorbisfile |
| 213 |
PROPERTIES IMPORTED_LOCATION "${Vorbis_File_DLL}" |
| 214 |
IMPORTED_IMPLIB "${Vorbis_File_LIBRARY}" |
| 215 |
) |
| 216 |
else() |
| 217 |
set_target_properties( |
| 218 |
Vorbis::vorbisfile |
| 219 |
PROPERTIES IMPORTED_LOCATION "${Vorbis_File_LIBRARY}" |
| 220 |
) |
| 221 |
endif() |
| 222 |
endif() |
| 223 |
|
| 224 |
mark_as_advanced( |
| 225 |
Vorbis_INCLUDE_DIR |
| 226 |
Vorbis_Vorbis_DLL |
| 227 |
Vorbis_Enc_DLL |
| 228 |
Vorbis_File_DLL |
| 229 |
Vorbis_Vorbis_LIBRARY |
| 230 |
Vorbis_Enc_LIBRARY |
| 231 |
Vorbis_File_LIBRARY |
| 232 |
) |