Skip to content

Commit 54f1ebf

Browse files
SeaOtocinclusfacebook-github-bot
authored andcommitted
{Build} Add CMake support for OPUS build
Summary: Enable optional OPUS compilation - Add a CMake preprocessor `BUILD_WITH_OPUS` - If required: - Add CMake rules to fetch OPUS library - Enable `OPUS_IS_AVAILABLE` CPP - Update `pixi run build` to compile with OPUS support by default to ease CI and testing long term support of the feature Differential Revision: D68632323 Privacy Context Container: L1163201
1 parent ecb5db3 commit 54f1ebf

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ add_subdirectory(vrs)
7070

7171
OPTION(BUILD_TOOLS "Build all of the tools" ON)
7272
OPTION(BUILD_SAMPLES "Build sample code and sample apps" ON)
73+
OPTION(BUILD_WITH_OPUS "Build VRS to support OPUS" OFF)
7374

7475
if (BUILD_TOOLS)
7576
# Add the vrs command line utility

cmake/LibrariesSetup.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ find_package(PNG REQUIRED)
3333
find_package(JPEG REQUIRED)
3434
find_package(TurboJpeg REQUIRED)
3535

36+
if (BUILD_WITH_OPUS)
37+
include(FetchContent)
38+
FetchContent_Declare(
39+
opus
40+
URL https://downloads.xiph.org/releases/opus/opus-1.5.2.tar.gz
41+
URL_HASH SHA256=65c1d2f78b9f2fb20082c38cbe47c951ad5839345876e46941612ee87f9a7ce1
42+
)
43+
FetchContent_MakeAvailable(opus)
44+
message("BUILD WITH OPUS: ON")
45+
endif()
46+
47+
3648
# Setup unit test infra, but only if unit tests are enabled
3749
if (UNIT_TESTS)
3850
enable_testing()

pixi.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ version = "1.1.0"
2727
# Note: extra CLI argument after `pixi run TASK` are passed to the task cmd.
2828
clean = { cmd = "rm -rf build" }
2929
print-env = { cmd = "echo $PATH" }
30-
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=Release"
30+
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_OPUS:BOOL=ON"
3131
build = { cmd = "cmake --build build --config Release --target all", depends_on = [
3232
"prepare",
3333
] }
@@ -36,7 +36,7 @@ vrs = { cmd = "build/tools/vrs/vrs", depends_on = ["build"]}
3636

3737
[target.win-64.tasks] # Deal with windows specifics (prepare and build)
3838
cmake-generator = "cmake --help"
39-
prepare = "cmake -G 'Visual Studio 16 2019' -B build -S . -DCMAKE_BUILD_TYPE=Release"
39+
prepare = "cmake -G 'Visual Studio 16 2019' -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_OPUS:BOOL=ON"
4040
build = { cmd = "cmake --build build --config Release -- /m", depends_on = [
4141
"prepare",
4242
] }

vrs/utils/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ target_link_libraries(vrs_utils
3636
rapidjson::rapidjson
3737
vrs_logging
3838
)
39+
40+
if (BUILD_WITH_OPUS)
41+
target_link_libraries(vrs_utils PRIVATE opus)
42+
target_compile_definitions(vrs_utils PRIVATE OPUS_IS_AVAILABLE)
43+
endif()
44+
3945
target_include_directories(vrs_utils
4046
INTERFACE
4147
$<BUILD_INTERFACE:${VRS_SOURCE_DIR}>

0 commit comments

Comments
 (0)