Add support for Vcpkg manifest mode

https://vcpkg.readthedocs.io/en/latest/users/manifests/
This commit is contained in:
evpobr 2021-11-21 14:18:47 +05:00
parent 739bc8cdac
commit 0c10913b92
5 changed files with 94 additions and 18 deletions

View File

@ -189,11 +189,6 @@ jobs:
if: startsWith(matrix.os,'ubuntu')
run: sudo apt-get update -y && sudo apt-get install -y autogen ninja-build libogg-dev libvorbis-dev libflac-dev libopus-dev libasound2-dev libsqlite3-dev libspeex-dev libmp3lame-dev libmpg123-dev
- name: Install Windows dependencies
if: startsWith(matrix.os,'windows')
run: |
vcpkg install libvorbis libflac opus sqlite3 speex mp3lame mpg123 --triplet ${{matrix.triplet}}
- name: Configure, build and test with Autotools
env:
CC: ${{ matrix.cc }}

View File

@ -37,6 +37,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add support for decoding MPEG III Audio in WAV files.
* `SECURITY.md` file to give people instructions for reporting security
vulnerabilities, thanks @zidingz.
* Support for [Vcpkg manifest mode](https://vcpkg.readthedocs.io/en/latest/users/manifests/).
If you have problems with manifest mode, disable it with `VCPKG_MANIFEST_MODE`
switch.
### Changed

View File

@ -15,6 +15,26 @@ if (POLICY CMP0091)
endif ()
endif ()
option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON)
if (ENABLE_EXTERNAL_LIBS)
list (APPEND VCPKG_MANIFEST_FEATURES "external-libs")
endif ()
option (ENABLE_MPEG "Enable MPEG codecs" ON)
if (ENABLE_MPEG)
list (APPEND VCPKG_MANIFEST_FEATURES "mpeg")
endif ()
option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF)
if (ENABLE_EXPERIMENTAL)
list (APPEND VCPKG_MANIFEST_FEATURES "speex")
endif ()
option (BUILD_REGTEST "Build regtest" OFF)
if (BUILD_REGTEST)
list (APPEND VCPKG_MANIFEST_FEATURES "regtest")
endif ()
project(libsndfile VERSION 1.1.0)
#
@ -54,7 +74,6 @@ endif ()
option (BUILD_PROGRAMS "Build programs" ON)
option (BUILD_EXAMPLES "Build examples" ON)
option (ENABLE_CPACK "Enable CPack support" ON)
option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF)
option (ENABLE_BOW_DOCS "Enable black-on-white html docs" OFF)
if (MSVC AND (DEFINED ENABLE_STATIC_RUNTIME))
option (ENABLE_STATIC_RUNTIME "Enable static runtime" ${ENABLE_STATIC_RUNTIME})
@ -75,10 +94,16 @@ endif ()
include(SndFileChecks)
if (ENABLE_EXTERNAL_LIBS AND NOT (Vorbis_FOUND OR FLAC_FOUND OR OPUS_FOUND))
set (ENABLE_EXTERNAL_LIBS OFF)
endif()
if(ENABLE_MPEG AND (NOT HAVE_MPEG_LIBS))
set (ENABLE_MPEG OFF)
endif()
if (BUILD_REGTEST AND (NOT SQLITE3_FOUND))
set (BUILD_REGTEST OFF)
endif()
cmake_dependent_option (BUILD_REGTEST "Build regtest" ON "SQLITE3_FOUND" OFF)
cmake_dependent_option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON "Vorbis_FOUND;FLAC_FOUND;OPUS_FOUND" OFF)
cmake_dependent_option (ENABLE_MPEG "Enable MPEG codecs" ON "HAVE_MPEG_LIBS" OFF)
cmake_dependent_option (ENABLE_CPU_CLIP "Enable tricky cpu specific clipper" ON "CPU_CLIPS_POSITIVE;CPU_CLIPS_NEGATIVE" OFF)
if (NOT ENABLE_CPU_CLIP)
set (CPU_CLIPS_POSITIVE FALSE)

View File

@ -273,22 +273,35 @@ have standard option `CMAKE_MSVC_RUNTIME_LIBRARY` now.
Second advice is about Ogg, Vorbis FLAC and Opus support. Searching external
libraries under Windows is a little bit tricky. The best way is to use
[Vcpkg](https://github.com/Microsoft/vcpkg). You need to install static libogg,
libvorbis, libflac and libopus libraries:
[Vcpkg](https://github.com/Microsoft/vcpkg).
vcpkg install libogg:x64-windows-static libvorbis:x64-windows-static
libflac:x64-windows-static opus:x64-windows-static libogg:x86-windows-static
libvorbis:x86-windows-static libflac:x86-windows-static opus:x86-windows-static
mp3lame:x86-windows-static mpg123:x86-windows-static
Then and add this parameter to cmake command line:
Install Vcpkg and then add this parameter to cmake command line:
-DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake
You also need to set `VCPKG_TARGET_TRIPLET` because you use static libraries:
You also need to set `VCPKG_TARGET_TRIPLET` if you want to use static libraries:
-DVCPKG_TARGET_TRIPLET=x64-windows-static
Then you need to install static libogg, libvorbis, libflac, libopus, mpg123 and
mp3lame Vcpkg packages.
After 1.1.0beta2 you don't need to install dependencies manually. Libsndfile
now supports [Vcpkg manifest mode](https://vcpkg.readthedocs.io/en/latest/users/manifests/)
and all dependencies are installed automatically.
However, you can turn off the manifest mode and return to the classic mode using
the `VCPKG_MANIFEST_MODE` parameter from the command line:
-DVCPKG_MANIFEST_MODE=OFF
In classic mode, you need to install the required libraries manually:
vcpkg install libvorbis:x64-windows-static libflac:x64-windows-static
opus:x64-windows-static mp3lame:x86-windows-static mpg123:x86-windows-static
libvorbis:x86-windows-static libflac:x86-windows-static
opus:x86-windows-static mp3lame:x86-windows-static mpg123:x86-windows-static
**Note**: Use must use the same CRT library for external libraries and the
libsndfile library itself. For `*-static` triplets Vcpkg uses
[static CRT](https://vcpkg.readthedocs.io/en/latest/users/triplets/).

39
vcpkg.json Normal file
View File

@ -0,0 +1,39 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "libsndfile",
"description": "A library for reading and writing audio files",
"version-semver": "1.1.0-beta.2",
"default-features": [
"external-libs",
"mpeg"
],
"features": {
"external-libs": {
"description": "Enable FLAC, Vorbis, and Opus codecs",
"dependencies": [
"libvorbis",
"libflac",
"opus"
]
},
"mpeg": {
"description": "Enable MPEG codecs",
"dependencies": [
"mpg123",
"mp3lame"
]
},
"regtest": {
"description": "Build regtest",
"dependencies": [
"sqlite3"
]
},
"experimental": {
"description": "Enable experimental code",
"dependencies": [
"speex"
]
}
}
}