Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
b306c6a2
Commit
b306c6a2
authored
Sep 10, 2025
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pkg-config for libvorbis and libopus detection.
parent
9e1f02b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
26 deletions
+46
-26
CMakeLists.txt
CMakeLists.txt
+46
-26
No files found.
CMakeLists.txt
View file @
b306c6a2
...
@@ -345,15 +345,21 @@ endfunction()
...
@@ -345,15 +345,21 @@ endfunction()
# vorbisfile
# vorbisfile
#
#
# The vorbisfile target is required for miniaudio_libvorbis. If the vorbisfile target has already been
# The vorbisfile target is required for miniaudio_libvorbis. If the vorbisfile target has already been
# defined we'll just use that. Otherwise we'll try to
find_library()
. If that fails, as a last resort
# defined we'll just use that. Otherwise we'll try to
use pkg-config
. If that fails, as a last resort
# we'll allow building it from source from the external/vorbis directory.
# we'll allow building it from source from the external/vorbis directory.
if
(
NOT MINIAUDIO_NO_LIBVORBIS
)
if
(
NOT MINIAUDIO_NO_LIBVORBIS
)
if
(
NOT TARGET vorbisfile
)
if
(
NOT TARGET vorbisfile
)
find_library
(
LIBVORBISFILE NAMES vorbisfile
)
# Try pkg-config first
if
(
LIBVORBISFILE
)
find_package
(
PkgConfig QUIET
)
message
(
STATUS
"Found libvorbisfile:
${
LIBVORBISFILE
}
"
)
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
PC_VORBISFILE vorbisfile
)
endif
()
if
(
PC_VORBISFILE_FOUND
)
message
(
STATUS
"Found vorbisfile via pkg-config:
${
PC_VORBISFILE_LIBRARIES
}
"
)
set
(
HAS_LIBVORBIS TRUE
)
set
(
HAS_LIBVORBIS TRUE
)
else
()
else
()
# Fallback to building from source.
add_libvorbis_subdirectory
()
add_libvorbis_subdirectory
()
if
(
NOT TARGET vorbisfile
)
if
(
NOT TARGET vorbisfile
)
message
(
STATUS
"libvorbisfile not found. miniaudio_libvorbis will be excluded."
)
message
(
STATUS
"libvorbisfile not found. miniaudio_libvorbis will be excluded."
)
...
@@ -369,27 +375,20 @@ endif()
...
@@ -369,27 +375,20 @@ endif()
# opusfile
# opusfile
#
#
# This is the same as vorbisfile above.
# This is the same as vorbisfile above
, but for opusfile
.
if
(
NOT MINIAUDIO_NO_LIBOPUS
)
if
(
NOT MINIAUDIO_NO_LIBOPUS
)
if
(
NOT TARGET opusfile
)
if
(
NOT TARGET opusfile
)
find_library
(
LIBOPUSFILE NAMES opusfile
)
# Try pkg-config first
if
(
LIBOPUSFILE
)
find_package
(
PkgConfig QUIET
)
message
(
STATUS
"Found libopusfile:
${
LIBOPUSFILE
}
"
)
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
PC_OPUSFILE opusfile
)
# opusfile is very annoying because they do "#include <opus_multistream.h>" in opusfile.h which results
endif
()
# in an error unless we explicitly add the include path to the opus include directory.
find_path
(
OPUSFILE_INCLUDE_DIR
NAMES opus/opusfile.h
DOC
"Directory containing opusfile.h"
)
if
(
OPUSFILE_INCLUDE_DIR
)
if
(
PC_OPUSFILE_FOUND
)
message
(
STATUS
"Found opusfile.h in
${
OPUSFILE_INCLUDE_DIR
}
"
)
message
(
STATUS
"Found opusfile via pkg-config:
${
PC_OPUSFILE_LIBRARIES
}
"
)
set
(
HAS_LIBOPUS TRUE
)
set
(
HAS_LIBOPUS TRUE
)
else
()
message
(
STATUS
"Could not find opusfile.h. miniaudio_libopus will be excluded."
)
endif
()
else
()
else
()
# Fallback to building from source.
add_libopusfile_subdirectory
()
add_libopusfile_subdirectory
()
if
(
NOT TARGET opusfile
)
if
(
NOT TARGET opusfile
)
message
(
STATUS
"libopusfile not found. miniaudio_libopus will be excluded."
)
message
(
STATUS
"libopusfile not found. miniaudio_libopus will be excluded."
)
...
@@ -519,8 +518,11 @@ add_library(libvorbis_interface INTERFACE)
...
@@ -519,8 +518,11 @@ add_library(libvorbis_interface INTERFACE)
if
(
HAS_LIBVORBIS
)
if
(
HAS_LIBVORBIS
)
if
(
TARGET vorbisfile
)
if
(
TARGET vorbisfile
)
target_link_libraries
(
libvorbis_interface INTERFACE vorbisfile
)
target_link_libraries
(
libvorbis_interface INTERFACE vorbisfile
)
else
()
elseif
(
PC_VORBISFILE_FOUND
)
target_link_libraries
(
libvorbis_interface INTERFACE
${
LIBVORBISFILE
}
)
target_link_libraries
(
libvorbis_interface INTERFACE
${
PC_VORBISFILE_LIBRARIES
}
)
target_include_directories
(
libvorbis_interface INTERFACE
${
PC_VORBISFILE_INCLUDE_DIRS
}
)
target_link_directories
(
libvorbis_interface INTERFACE
${
PC_VORBISFILE_LIBRARY_DIRS
}
)
target_compile_options
(
libvorbis_interface INTERFACE
${
PC_VORBISFILE_CFLAGS_OTHER
}
)
endif
()
endif
()
endif
()
endif
()
...
@@ -543,9 +545,11 @@ add_library(libopus_interface INTERFACE)
...
@@ -543,9 +545,11 @@ add_library(libopus_interface INTERFACE)
if
(
HAS_LIBOPUS
)
if
(
HAS_LIBOPUS
)
if
(
TARGET opusfile
)
if
(
TARGET opusfile
)
target_link_libraries
(
libopus_interface INTERFACE opusfile
)
target_link_libraries
(
libopus_interface INTERFACE opusfile
)
else
()
elseif
(
PC_OPUSFILE_FOUND
)
target_link_libraries
(
libopus_interface INTERFACE
${
LIBOPUSFILE
}
)
target_link_libraries
(
libopus_interface INTERFACE
${
PC_OPUSFILE_LIBRARIES
}
)
target_include_directories
(
libopus_interface INTERFACE
${
OPUSFILE_INCLUDE_DIR
}
/opus
)
target_include_directories
(
libopus_interface INTERFACE
${
PC_OPUSFILE_INCLUDE_DIRS
}
)
target_link_directories
(
libopus_interface INTERFACE
${
PC_OPUSFILE_LIBRARY_DIRS
}
)
target_compile_options
(
libopus_interface INTERFACE
${
PC_OPUSFILE_CFLAGS_OTHER
}
)
endif
()
endif
()
endif
()
endif
()
...
@@ -819,6 +823,22 @@ else()
...
@@ -819,6 +823,22 @@ else()
endif
()
endif
()
string
(
JOIN
", "
MINIAUDIO_PC_REQUIRES_PRIVATE
${
LINKED_LIBS
}
)
string
(
JOIN
", "
MINIAUDIO_PC_REQUIRES_PRIVATE
${
LINKED_LIBS
}
)
# Add vorbisfile and opusfile to pkg-config dependencies if found via pkg-config
set
(
PC_REQUIRES_PRIVATE_LIST
)
if
(
PC_VORBISFILE_FOUND AND HAS_LIBVORBIS
)
list
(
APPEND PC_REQUIRES_PRIVATE_LIST
"vorbisfile"
)
endif
()
if
(
PC_OPUSFILE_FOUND AND HAS_LIBOPUS
)
list
(
APPEND PC_REQUIRES_PRIVATE_LIST
"opusfile"
)
endif
()
if
(
PC_REQUIRES_PRIVATE_LIST
)
if
(
MINIAUDIO_PC_REQUIRES_PRIVATE
)
string
(
APPEND MINIAUDIO_PC_REQUIRES_PRIVATE
", "
)
endif
()
string
(
JOIN
", "
PC_REQUIRES_STR
${
PC_REQUIRES_PRIVATE_LIST
}
)
string
(
APPEND MINIAUDIO_PC_REQUIRES_PRIVATE
"
${
PC_REQUIRES_STR
}
"
)
endif
()
list
(
TRANSFORM COMMON_LINK_LIBRARIES PREPEND
"-l"
)
list
(
TRANSFORM COMMON_LINK_LIBRARIES PREPEND
"-l"
)
string
(
JOIN
" "
MINIAUDIO_PC_LIBS_PRIVATE
${
COMMON_LINK_LIBRARIES
}
)
string
(
JOIN
" "
MINIAUDIO_PC_LIBS_PRIVATE
${
COMMON_LINK_LIBRARIES
}
)
list
(
TRANSFORM COMPILE_DEFINES PREPEND
"-D"
)
list
(
TRANSFORM COMPILE_DEFINES PREPEND
"-D"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment