summaryrefslogtreecommitdiffstats
path: root/cmake/Findopusfile.cmake
diff options
context:
space:
mode:
authorAnonymous Maarten <anonymous.maarten@gmail.com>2020-12-06 19:12:35 +0100
committershfil <filip.gawin@zoho.com>2021-01-11 11:24:25 +0100
commit8d0b4ede684df25e142b94fede4cbb15e4f6fb57 (patch)
tree92446485905b957c546b265f939b8ee06ca5d656 /cmake/Findopusfile.cmake
parentaudio: only use #pragma comment(lib, "xxx.lib") on MSVC (diff)
downloadre3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.tar
re3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.tar.gz
re3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.tar.bz2
re3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.tar.lz
re3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.tar.xz
re3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.tar.zst
re3-8d0b4ede684df25e142b94fede4cbb15e4f6fb57.zip
Diffstat (limited to '')
-rw-r--r--cmake/Findopusfile.cmake67
1 files changed, 67 insertions, 0 deletions
diff --git a/cmake/Findopusfile.cmake b/cmake/Findopusfile.cmake
new file mode 100644
index 00000000..43d285eb
--- /dev/null
+++ b/cmake/Findopusfile.cmake
@@ -0,0 +1,67 @@
+# - Try to find opusfile
+#
+# Once done this will define
+#
+# OPUSFILE_FOUND - system has opusfile
+# OPUSFILE_INCLUDE_DIRS - the opusfile include directories
+# OPUSFILE_LIBRARIES - Link these to use opusfile
+# OPUSFILE_CFLAGS - Compile options to use opusfile
+# opusfile::opusfile - Imported library of opusfile
+#
+
+# FIXME: opusfile does not ship an official opusfile cmake script,
+# rename this file/variables/target when/if it has.
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_search_module(PKG_OPUSFILE "opusfile")
+endif()
+
+find_path(OPUSFILE_INCLUDE_DIR
+ NAMES
+ opusfile.h
+ PATH_SUFFIXES
+ opusfile
+ HINTS
+ ${PKG_OPUSFILE_INCLUDE_DIRS}
+ PATHS
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+find_library(OPUSFILE_LIBRARY
+ NAMES
+ opusfile
+ HINTS
+ ${PKG_OPUSFILE_LIBRARIES}
+ PATHS
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+)
+
+set(OPUSFILE_CFLAGS "${PKG_OPUSFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of opusfile")
+
+set(OPUSFILE_INCLUDE_DIRS "${OPUSFILE_INCLUDE_DIR}")
+set(OPUSFILE_LIBRARIES "${OPUSFILE_LIBRARY}")
+
+if (OPUSFILE_INCLUDE_DIRS AND OPUSFILE_LIBRARIES)
+set(OPUSFILE_FOUND TRUE)
+endif (OPUSFILE_INCLUDE_DIRS AND OPUSFILE_LIBRARIES)
+
+
+# handle the QUIETLY and REQUIRED arguments and set Opusfile_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(opusfile DEFAULT_MSG OPUSFILE_INCLUDE_DIRS OPUSFILE_LIBRARIES)
+
+if(NOT TARGET opusfile::opusfile)
+ add_library(__opusfile INTERFACE)
+ target_compile_options(__opusfile INTERFACE ${OPUSFILE_CFLAGS})
+ target_include_directories(__opusfile INTERFACE ${OPUSFILE_INCLUDE_DIRS})
+ target_link_libraries(__opusfile INTERFACE ${OPUSFILE_LIBRARIES})
+ add_library(opusfile::opusfile ALIAS __opusfile)
+endif()