forked from FluidSynth/fluidsynth
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathFindPortAudio.cmake
More file actions
66 lines (51 loc) · 1.9 KB
/
FindPortAudio.cmake
File metadata and controls
66 lines (51 loc) · 1.9 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#[=======================================================================[.rst:
FindPortAudio
-------
Finds the PortAudio library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``PortAudio::PortAudio``
The PortAudio library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``PortAudio_FOUND``
True if the system has the PortAudio library.
``PortAudio_VERSION``
The version of the PortAudio library which was found.
#]=======================================================================]
# Use pkg-config if available
find_package(PkgConfig QUIET)
pkg_check_modules(PC_PORTAUDIO QUIET portaudio-2.0)
# Find the headers and library
find_path(
PortAudio_INCLUDE_DIR
NAMES "portaudio.h"
HINTS "${PC_PORTAUDIO_INCLUDEDIR}")
find_library(
PortAudio_LIBRARY
NAMES "portaudio"
HINTS "${PC_PORTAUDIO_LIBDIR}")
# Handle transitive dependencies
if(PC_PORTAUDIO_FOUND)
get_target_properties_from_pkg_config("${PortAudio_LIBRARY}" "PC_PORTAUDIO"
"_portaudio")
else()
set(_portaudio_link_libraries "ALSA::ALSA" ${MATH_LIBRARY} "Threads::Threads")
endif()
# Forward the result to CMake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
PortAudio REQUIRED_VARS "PortAudio_LIBRARY" "PortAudio_INCLUDE_DIR")
if(PortAudio_FOUND AND NOT TARGET PortAudio::PortAudio)
add_library(PortAudio::PortAudio UNKNOWN IMPORTED)
set_target_properties(
PortAudio::PortAudio
PROPERTIES IMPORTED_LOCATION "${PortAudio_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${_portaudio_compile_options}"
INTERFACE_INCLUDE_DIRECTORIES "${PortAudio_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${_portaudio_link_libraries}"
INTERFACE_LINK_DIRECTORIES "${_portaudio_link_directories}")
endif()
mark_as_advanced(PortAudio_INCLUDE_DIR PortAudio_LIBRARY)