From f8bbb2569f589a2ae4d8e5fd2851e4c87ac3e6c4 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sat, 5 Oct 2024 12:25:02 +0200 Subject: [PATCH] add findoboe cmake module --- .azure/azure-pipelines-android.yml | 2 +- cmake_admin/Findoboe.cmake | 84 ++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 cmake_admin/Findoboe.cmake diff --git a/.azure/azure-pipelines-android.yml b/.azure/azure-pipelines-android.yml index dcf67544d..c12380d8c 100644 --- a/.azure/azure-pipelines-android.yml +++ b/.azure/azure-pipelines-android.yml @@ -39,7 +39,7 @@ variables: GETTEXT_VERSION: '0.22.5' GLIB_VERSION: '2.72' GLIB_EXTRAVERSION: '4' - OBOE_VERSION: '1.5.0' + OBOE_VERSION: '1.9.0' SNDFILE_VERSION: '1.2.2' INSTPATCH_VERSION: '1.1.6' VORBIS_VERSION: '1.3.7' diff --git a/cmake_admin/Findoboe.cmake b/cmake_admin/Findoboe.cmake new file mode 100644 index 000000000..c951b7dff --- /dev/null +++ b/cmake_admin/Findoboe.cmake @@ -0,0 +1,84 @@ +#[=======================================================================[.rst: +FindOboe +------- + +Finds the Oboe library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``oboe::oboe`` + The Oboe library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Oboe_FOUND`` + True if the system has the Oboe library. + +For compatibility with upstream, the following variables are also set: + +``Oboe_INCLUDE_DIR`` +``Oboe_INCLUDE_DIRS`` +``Oboe_LIBRARY`` +``Oboe_LIBRARIES`` +``OBOE_INCLUDE_DIR`` +``OBOE_INCLUDE_DIRS`` +``OBOE_LIBRARY`` +``OBOE_LIBRARIES`` +``OBOE_FOUND`` + +#]=======================================================================] + +# Use pkg-config if available +find_package(PkgConfig QUIET) +pkg_check_modules(PC_OBOE QUIET oboe-1.0) + +# Find the headers and library +find_path( + Oboe_INCLUDE_DIR + NAMES "oboe/Oboe.h" + HINTS "${PC_OBOE_INCLUDEDIR}") + +find_library( + _oboe_library + NAMES "oboe" + HINTS "${PC_OBOE_LIBDIR}") + +# Extract additional flags if pkg-config is available +if(PC_OBOE_FOUND) + get_target_properties_from_pkg_config("${_oboe_library}" "PC_OBOE" "_oboe") +endif() + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Oboe REQUIRED_VARS "_oboe_library" + "Oboe_INCLUDE_DIR") + +# Create the target +if(Oboe_FOUND AND NOT TARGET oboe::oboe) + add_library(oboe::oboe UNKNOWN IMPORTED) + set_target_properties( + oboe::oboe + PROPERTIES IMPORTED_LOCATION "${_oboe_library}" + INTERFACE_COMPILE_OPTIONS "${_oboe_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${Oboe_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_oboe_link_libraries}" + INTERFACE_LINK_DIRECTORIES "${_oboe_link_directories}") + + # Set additional variables for compatibility with upstream config + set(Oboe_INCLUDE_DIRS "${Oboe_INCLUDE_DIR}") + set(Oboe_LIBRARY oboe::oboe) + set(Oboe_LIBRARIES oboe::oboe) + set(OBOE_INCLUDE_DIR "${${Oboe_INCLUDE_DIR}}") + set(OBOE_INCLUDE_DIRS "${${Oboe_INCLUDE_DIR}}") + set(OBOE_LIBRARY oboe::oboe) + set(OBOE_LIBRARIES oboe::oboe) + set(OBOE_FOUND TRUE) +endif() + +mark_as_advanced(_oboe_library)