1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
# 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 $<$<BOOL:${PACKAGE_VERSION_INFO}>: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)
|