Skip to content

Commit

Permalink
libsndfile: clear cxx settings, add test for C API
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Oct 23, 2023
1 parent 3706291 commit 1b53aa2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
4 changes: 3 additions & 1 deletion recipes/libsndfile/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def config_options(self):
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -64,7 +66,7 @@ def requirements(self):
self.requires("vorbis/1.3.7")
self.requires("flac/1.4.2")
self.requires("opus/1.4")
if self.options.get_safe("with_mpeg", False):
if self.options.get_safe("with_mpeg"):
self.requires("mpg123/1.31.2")
self.requires("libmp3lame/3.100")

Expand Down
9 changes: 6 additions & 3 deletions recipes/libsndfile/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)
project(test_package LANGUAGES C CXX)

find_package(SndFile REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE SndFile::sndfile)
add_executable(${PROJECT_NAME}_c test_package.c)
target_link_libraries(${PROJECT_NAME}_c PRIVATE SndFile::sndfile)

add_executable(${PROJECT_NAME}_cxx test_package.cpp)
target_link_libraries(${PROJECT_NAME}_cxx PRIVATE SndFile::sndfile)
4 changes: 3 additions & 1 deletion recipes/libsndfile/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ def build(self):

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
bin_path = os.path.join(self.cpp.build.bindir, "test_package_c")
self.run(bin_path, env="conanrun")
bin_path = os.path.join(self.cpp.build.bindir, "test_package_cxx")
self.run(bin_path, env="conanrun")
14 changes: 14 additions & 0 deletions recipes/libsndfile/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "sndfile.h"

#include <stdio.h>

int main(int argc, char *argv[]) {
if (argc < 2) {
puts("Usage: example <file.wav>\n");
return 0;
}
SF_INFO sfinfo;
SNDFILE *infile = sf_open (argv[1], SFM_READ, &sfinfo);
printf("Sample rate: %d\n", sfinfo.samplerate);
return 0;
}
6 changes: 3 additions & 3 deletions recipes/libsndfile/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
int main(int argc, char *argv[]) {
if (argc < 2) {
std::cout << "Usage: example <file.wav>\n";
} else {
SndfileHandle handle(argv[1]);
std::cout << "Sample rate: " << handle.samplerate() << "\n";
return 0;
}
SndfileHandle handle(argv[1]);
std::cout << "Sample rate: " << handle.samplerate() << "\n";
return 0;
}
4 changes: 3 additions & 1 deletion recipes/libsndfile/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ def build(self):

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
bin_path = os.path.join("bin", "test_package_c")
self.run(bin_path, run_environment=True)
bin_path = os.path.join("bin", "test_package_cxx")
self.run(bin_path, run_environment=True)

0 comments on commit 1b53aa2

Please sign in to comment.