# https://stackoverflow.com/questions/51907755/building-a-pybind11-module-with-cpp-and-cuda-sources-using-cmake cmake_minimum_required(VERSION 3.15) set(CMAKE_POLICY_VERSION_MINIMUM 3.5) project(python-samplerate) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(PYBIND11_FINDPYTHON ON) ################################################### # no external dependencies for Debian ################################################### # # adds the external dependencies # add_subdirectory(external) set(PYBIND11_FINDPYTHON ON) find_package(pybind11 CONFIG REQUIRED) pybind11_add_module(python-samplerate src/samplerate.cpp) ################################################### # here is the path to C headers provided by the package python3-samplerate ################################################### # # target_include_directories(python-samplerate PRIVATE ./external/libsamplerate/include) target_include_directories(python-samplerate PRIVATE /usr/lib/python3/dist-packages/pybind11/include/) if(MSVC) target_compile_options(python-samplerate PRIVATE /EHsc /MP /bigobj) set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT WIN32)) target_compile_options(python-samplerate PRIVATE -std=c++14 -O3 -Wall -Wextra -fPIC) endif() ### stick the package and libsamplerate version into the module target_compile_definitions(python-samplerate PUBLIC LIBSAMPLERATE_VERSION="${LIBSAMPLERATE_VERSION}" PRIVATE $<$:VERSION_INFO="${PACKAGE_VERSION_INFO}"> ) ### Final target setup set_target_properties( python-samplerate PROPERTIES PREFIX "" OUTPUT_NAME "samplerate" LINKER_LANGUAGE C ) target_link_libraries(python-samplerate PUBLIC samplerate)