Skip to content

Make building own libsamplerate and pybind11 optional #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

cmake_policy(SET CMP0094 NEW)

# adds the external dependencies
add_subdirectory(external)

option(USE_SYSTEM_LIBRARIES "Use system libsamplerate and pybind instead of building separate versions" OFF)
if(USE_SYSTEM_LIBRARIES)
find_package(pybind11 REQUIRED)
else()
# adds the external dependencies
add_subdirectory(external)
endif()

pybind11_add_module(python-samplerate src/samplerate.cpp)

target_include_directories(python-samplerate PRIVATE ./external/libsamplerate/include)
if(USE_SYSTEM_LIBRARIES)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SAMPLERATE REQUIRED IMPORTED_TARGET GLOBAL samplerate)
target_link_libraries(python-samplerate PUBLIC PkgConfig::SAMPLERATE)
else()
target_include_directories(python-samplerate PRIVATE ./external/libsamplerate/include)
target_link_libraries(python-samplerate PUBLIC samplerate)
endif()

if(MSVC)
target_compile_options(python-samplerate PRIVATE /EHsc /MP /bigobj)
Expand Down Expand Up @@ -43,4 +56,3 @@ set_target_properties(
LINKER_LANGUAGE C
)

target_link_libraries(python-samplerate PUBLIC samplerate)
Loading