-
-
Notifications
You must be signed in to change notification settings - Fork 536
/
Copy pathFindOpusfile.cmake
43 lines (36 loc) · 1.45 KB
/
FindOpusfile.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# - Try to find the Opusfile library
# Once done this will define:
#
# OPUSFILE_FOUND - system has Opusfile
# OPUSFILE_INCLUDE_DIR - the Opusfile include directory
# OPUSFILE_LIBRARY - The Opusfile library
#
# Plus the Opus::opusfile target
#
include (CheckLibraryExists)
find_path(OPUSFILE_INCLUDE_DIR opusfile.h PATH_SUFFIXES opus)
# opusfile.h includes "opus_multistream.h" instead of "opus/opus_multistream.h"
# so we must include the path to opus_multistream.h
find_path(OPUS_MULTISTREAM_DIR opus_multistream.h PATH_SUFFIXES opus)
find_library(OPUSFILE_LIBRARY NAMES opusfile)
if (NOT TARGET Ogg::ogg)
find_package(Ogg REQUIRED)
endif()
if (NOT TARGET Opus::opus)
find_package(Opus REQUIRED)
endif()
mark_as_advanced(OPUSFILE_INCLUDE_DIR OPUSFILE_LIBRARY)
list(APPEND _opusfile_interface_include_directories "${OPUSFILE_INCLUDE_DIR}")
list(APPEND _opusfile_interface_include_directories "${OPUS_MULTISTREAM_DIR}")
list(APPEND _opusfile_link_libraries "Ogg::ogg" "Opus::opus")
add_library(Opus::opusfile UNKNOWN IMPORTED)
set_target_properties(Opus::opusfile
PROPERTIES
IMPORTED_LOCATION "${OPUSFILE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${_opusfile_interface_include_directories}"
INTERFACE_LINK_LIBRARIES "${_opusfile_link_libraries}"
)
unset(_opusfile_interface_include_directories)
unset(_opusfile_link_libraries)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Opusfile REQUIRED_VARS OPUSFILE_LIBRARY OPUSFILE_INCLUDE_DIR)