summaryrefslogtreecommitdiffstats
path: root/cmake/Findmpg123.cmake
diff options
context:
space:
mode:
authorAnonymous Maarten <anonymous.maarten@gmail.com>2020-12-06 13:54:06 +0100
committershfil <filip.gawin@zoho.com>2021-01-11 11:24:25 +0100
commit2ff9270279e11ad559f0b71bf7212788b325f619 (patch)
tree199ed518b7c14dca76349fc3a5fe3c3315956b2d /cmake/Findmpg123.cmake
parentaudio: only use #pragma comment(lib, xxx.lib) on MSVC (diff)
downloadre3-2ff9270279e11ad559f0b71bf7212788b325f619.tar
re3-2ff9270279e11ad559f0b71bf7212788b325f619.tar.gz
re3-2ff9270279e11ad559f0b71bf7212788b325f619.tar.bz2
re3-2ff9270279e11ad559f0b71bf7212788b325f619.tar.lz
re3-2ff9270279e11ad559f0b71bf7212788b325f619.tar.xz
re3-2ff9270279e11ad559f0b71bf7212788b325f619.tar.zst
re3-2ff9270279e11ad559f0b71bf7212788b325f619.zip
Diffstat (limited to '')
-rw-r--r--cmake/Findmpg123.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/cmake/Findmpg123.cmake b/cmake/Findmpg123.cmake
new file mode 100644
index 00000000..365d65ff
--- /dev/null
+++ b/cmake/Findmpg123.cmake
@@ -0,0 +1,40 @@
+# - Find mpg123
+# Find the native mpg123 includes and library
+#
+# mpg123_INCLUDE_DIR - Where to find mpg123.h
+# mpg123_LIBRARIES - List of libraries when using mpg123.
+# mpg123_CFLAGS - Compile options to use mpg123
+# mpg123_FOUND - True if mpg123 found.
+# MPG123::libmpg123 - Imported library of libmpg123
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_search_module(PKG_MPG123 mpg123)
+endif()
+
+find_path(mpg123_INCLUDE_DIR mpg123.h
+ HINTS ${PKG_MPG123_INCLUDE_DIRS}
+ PATHS "${mpg123_DIR}"
+ PATH_SUFFIXES include
+)
+
+find_library(mpg123_LIBRARIES NAMES mpg123 mpg123-0
+ HINTS ${PKG_MPG123_LIBRARIES}
+ PATHS "${mpg123_DIR}"
+ PATH_SUFFIXES lib
+)
+
+set(mpg123_CFLAGS "${PKG_MPG123_CFLAGS_OTHER}" CACHE STRING "CFLAGS of mpg123")
+
+# handle the QUIETLY and REQUIRED arguments and set mpg123_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(mpg123 DEFAULT_MSG mpg123_LIBRARIES mpg123_INCLUDE_DIR)
+
+if(NOT TARGET MPG123::libmpg123)
+ add_library(__libmpg123 INTERFACE)
+ target_compile_options(__libmpg123 INTERFACE ${mpg123_CFLAGS})
+ target_include_directories(__libmpg123 INTERFACE ${mpg123_INCLUDE_DIR})
+ target_link_libraries(__libmpg123 INTERFACE ${mpg123_LIBRARIES})
+ add_library(MPG123::libmpg123 ALIAS __libmpg123)
+endif()