cmake: Add FindOgg find module

On some system, its libogg package may not have a cmake module for libogg, so let's add one for finding where libogg is located at.
This commit is contained in:
SteelT 2024-02-24 21:28:47 -05:00
parent db49975d67
commit 292aa10275

View file

@ -0,0 +1,35 @@
include(LibFindMacros)
libfind_pkg_check_modules(Ogg_PKGCONF ogg)
find_path(Ogg_INCLUDE_DIR
NAMES ogg/ogg.h
PATHS
${Ogg_PKGCONF_INCLUDE_DIRS}
"/usr/include"
"/usr/local/include"
)
find_library(Ogg_LIBRARY
NAMES ogg
PATHS
${Ogg_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ogg
REQUIRED_VARS Ogg_LIBRARY Ogg_INCLUDE_DIR)
if(Ogg_FOUND AND NOT TARGET Ogg::ogg)
add_library(Ogg::ogg UNKNOWN IMPORTED)
set_target_properties(
Ogg::ogg
PROPERTIES
IMPORTED_LOCATION "${Ogg_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}"
)
endif()
mark_as_advanced(Ogg_LIBRARY Ogg_INCLUDE_DIR)