Skip to content

Commit 61bc68f

Browse files
committed
Make building own libsamplerate and pybind11 optional
And make it not default. Fixes: GH-24
1 parent d737def commit 61bc68f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1010

1111
cmake_policy(SET CMP0094 NEW)
1212

13-
# adds the external dependencies
14-
add_subdirectory(external)
13+
14+
option(USE_SYSTEM_LIBRARIES "Use system libsamplerate and pybind instead of building separate versions" OFF)
15+
if(USE_SYSTEM_LIBRARIES)
16+
find_package(pybind11 REQUIRED)
17+
else()
18+
# adds the external dependencies
19+
add_subdirectory(external)
20+
endif()
1521

1622
pybind11_add_module(python-samplerate src/samplerate.cpp)
1723

18-
target_include_directories(python-samplerate PRIVATE ./external/libsamplerate/include)
24+
if(USE_SYSTEM_LIBRARIES)
25+
find_package(PkgConfig REQUIRED)
26+
pkg_check_modules(SAMPLERATE REQUIRED IMPORTED_TARGET GLOBAL samplerate)
27+
target_link_libraries(python-samplerate PUBLIC PkgConfig::SAMPLERATE)
28+
else()
29+
target_include_directories(python-samplerate PRIVATE ./external/libsamplerate/include)
30+
target_link_libraries(python-samplerate PUBLIC samplerate)
31+
endif()
1932

2033
if(MSVC)
2134
target_compile_options(python-samplerate PRIVATE /EHsc /MP /bigobj)
@@ -43,4 +56,3 @@ set_target_properties(
4356
LINKER_LANGUAGE C
4457
)
4558

46-
target_link_libraries(python-samplerate PUBLIC samplerate)

0 commit comments

Comments
 (0)