@@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
project(sonus-consumer LANGUAGES CXX)
|
||||
|
||||
foreach(dependency miniaudio OpenSSL SQLite3 raylib)
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_${dependency} TRUE)
|
||||
endforeach()
|
||||
find_package(sonus CONFIG REQUIRED)
|
||||
get_target_property(sonus_links sonus::sonus INTERFACE_LINK_LIBRARIES)
|
||||
if(sonus_links MATCHES "miniaudio|OpenSSL|SQLite|raylib")
|
||||
message(FATAL_ERROR "Sonus exposes a private dependency: ${sonus_links}")
|
||||
endif()
|
||||
foreach(dependency modulus::miniaudio modulus::openssl modulus::sqlite modulus::raylib)
|
||||
if(TARGET ${dependency})
|
||||
message(FATAL_ERROR "Sonus discovered an unrelated bridge: ${dependency}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
option(SONUS_TEST_INSTALLED_CONFIG "Check installed Modulus component discovery" OFF)
|
||||
if(SONUS_TEST_INSTALLED_CONFIG)
|
||||
find_package(modulus CONFIG REQUIRED OPTIONAL_COMPONENTS miniaudio unsupported)
|
||||
if(modulus_miniaudio_FOUND OR modulus_unsupported_FOUND)
|
||||
message(FATAL_ERROR "Unavailable optional components must not be found")
|
||||
endif()
|
||||
find_package(modulus CONFIG QUIET COMPONENTS unsupported)
|
||||
if(modulus_FOUND)
|
||||
message(FATAL_ERROR "An unknown required component must reject the package")
|
||||
endif()
|
||||
find_package(modulus CONFIG REQUIRED)
|
||||
endif()
|
||||
|
||||
add_executable(sonus-consumer main.cpp)
|
||||
target_link_libraries(sonus-consumer PRIVATE sonus::sonus)
|
||||
target_compile_features(sonus-consumer PRIVATE cxx_std_23)
|
||||
enable_testing()
|
||||
add_test(NAME sonus-consumer COMMAND sonus-consumer)
|
||||
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
|
||||
import conan
|
||||
import conan.tools.build
|
||||
import conan.tools.cmake
|
||||
|
||||
|
||||
class sonus_test_package(conan.ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "CMakeToolchain"
|
||||
test_type = "explicit"
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def layout(self):
|
||||
conan.tools.cmake.cmake_layout(self)
|
||||
|
||||
def build(self):
|
||||
cmake = conan.tools.cmake.CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if conan.tools.build.can_run(self):
|
||||
self.run(os.path.join(self.cpp.build.bindirs[0], "sonus-consumer"), env="conanrun")
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <sonus.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
auto main() -> int {
|
||||
auto config = sonus::audio_config{};
|
||||
config.no_device = true;
|
||||
auto engine = sonus::engine::create(config);
|
||||
if (!engine || !engine->set_master_volume(0.5F) || !engine->start_metronome({})) {
|
||||
return 1;
|
||||
}
|
||||
auto samples = std::vector<std::float32_t>(512U * engine->channels());
|
||||
if (!engine->render(samples.data(), 512U)) {
|
||||
return 2;
|
||||
}
|
||||
if (std::none_of(samples.begin(), samples.end(), [](auto value) { return value != 0.0F; })) {
|
||||
return 3;
|
||||
}
|
||||
engine->stop_metronome();
|
||||
return engine->metronome_active() ? 4 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user