|
| 1 | +#[=======================================================================[.rst: |
| 2 | +FindOboe |
| 3 | +-------- |
| 4 | +
|
| 5 | +Finds the Oboe library. |
| 6 | +
|
| 7 | +Imported Targets |
| 8 | +^^^^^^^^^^^^^^^^ |
| 9 | +
|
| 10 | +This module provides the following imported targets, if found: |
| 11 | +
|
| 12 | +``Oboe::Oboe`` |
| 13 | + The Oboe library |
| 14 | +
|
| 15 | +#]=======================================================================] |
| 16 | + |
| 17 | +# Prefer finding the libraries from pkgconfig rather than find_library. This is |
| 18 | +# required to build with PipeWire's reimplementation of the Oboe library. |
| 19 | +# |
| 20 | +# This also enables using PortAudio with the Oboe port in vcpkg. That only |
| 21 | +# builds OboeWeakAPI (not the Oboe server) which dynamically loads the real |
| 22 | +# Oboe library and forwards API calls to it. OboeWeakAPI requires linking `dl` |
| 23 | +# in addition to Oboe, as specified in the pkgconfig file in vcpkg. |
| 24 | +find_package(PkgConfig QUIET) |
| 25 | +if(PkgConfig_FOUND) |
| 26 | + pkg_check_modules(Oboe Oboe) |
| 27 | +endif() |
| 28 | + |
| 29 | +find_path( |
| 30 | + Oboe_INCLUDE_DIR |
| 31 | + NAMES oboe/Oboe.h |
| 32 | + HINTS ${PC_Oboe_INCLUDE_DIRS} |
| 33 | + DOC "Oboe include directory" |
| 34 | +) |
| 35 | +mark_as_advanced(Oboe_INCLUDE_DIR) |
| 36 | + |
| 37 | +find_library( |
| 38 | + Oboe_LIBRARY |
| 39 | + NAMES oboe |
| 40 | + HINTS ${PC_Oboe_LIBRARY_DIRS} |
| 41 | + DOC "Oboe library" |
| 42 | +) |
| 43 | +mark_as_advanced(Oboe_LIBRARY) |
| 44 | + |
| 45 | +if(DEFINED PC_Oboe_VERSION AND NOT PC_Oboe_VERSION STREQUAL "") |
| 46 | + set(Oboe_VERSION "${PC_Oboe_VERSION}") |
| 47 | +endif() |
| 48 | + |
| 49 | +include(FindPackageHandleStandardArgs) |
| 50 | +find_package_handle_standard_args( |
| 51 | + Oboe |
| 52 | + REQUIRED_VARS Oboe_LIBRARY Oboe_INCLUDE_DIR |
| 53 | + VERSION_VAR Oboe_VERSION |
| 54 | +) |
| 55 | + |
| 56 | +if(Oboe_FOUND) |
| 57 | + set(Oboe_LIBRARIES "${Oboe_LIBRARY}") |
| 58 | + set(Oboe_INCLUDE_DIRS "${Oboe_INCLUDE_DIR}") |
| 59 | + set(Oboe_DEFINITIONS ${PC_Oboe_CFLAGS_OTHER}) |
| 60 | + |
| 61 | + if(NOT TARGET Oboe::Oboe) |
| 62 | + add_library(Oboe::Oboe UNKNOWN IMPORTED) |
| 63 | + set_target_properties( |
| 64 | + Oboe::Oboe |
| 65 | + PROPERTIES |
| 66 | + IMPORTED_LOCATION "${Oboe_LIBRARY}" |
| 67 | + INTERFACE_COMPILE_OPTIONS "${PC_Oboe_CFLAGS_OTHER}" |
| 68 | + INTERFACE_INCLUDE_DIRECTORIES "${Oboe_INCLUDE_DIR}" |
| 69 | + ) |
| 70 | + endif() |
| 71 | +endif() |
0 commit comments