Skip to content

Commit ebe422c

Browse files
committed
Skip stub gen when cross-compiling, Find system libsoxr properly
1 parent 9046710 commit ebe422c

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

CMakeLists.txt

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,35 @@ nanobind_add_module(soxr_ext STABLE_ABI NB_STATIC
6565
${CSOXR_VER_C}
6666
)
6767

68-
nanobind_add_stub(soxr_ext_stub
69-
MODULE soxr_ext
70-
OUTPUT soxr_ext.pyi
71-
PYTHON_PATH $<TARGET_FILE_DIR:soxr_ext>
72-
DEPENDS soxr_ext
73-
)
68+
if (NOT CMAKE_CROSSCOMPILING)
69+
# nanobind's stub generation requires importing the module, so skip it when cross-compiling
70+
nanobind_add_stub(soxr_ext_stub
71+
MODULE soxr_ext
72+
OUTPUT soxr_ext.pyi
73+
PYTHON_PATH $<TARGET_FILE_DIR:soxr_ext>
74+
DEPENDS soxr_ext
75+
)
7476

75-
target_link_libraries(soxr_ext PRIVATE
76-
soxr
77-
)
77+
install(FILES ${CMAKE_BINARY_DIR}/soxr_ext.pyi DESTINATION soxr)
78+
endif ()
7879

7980
# Install directive for scikit-build-core
8081
install(TARGETS soxr_ext LIBRARY DESTINATION soxr)
81-
install(FILES ${CMAKE_BINARY_DIR}/soxr_ext.pyi DESTINATION soxr)
8282

83-
if (NOT USE_SYSTEM_LIBSOXR)
83+
if (USE_SYSTEM_LIBSOXR)
84+
# Find system libsoxr
85+
find_library(SOXR_LIBRARY NAMES soxr)
86+
find_path(SOXR_INCLUDE_DIR soxr.h)
87+
88+
message (STATUS "Building with external libsoxr")
89+
message(SOXR_LIBRARY="${SOXR_LIBRARY}")
90+
message(SOXR_INCLUDE_DIR="${SOXR_INCLUDE_DIR}")
91+
92+
target_link_libraries(soxr_ext PRIVATE ${SOXR_LIBRARY})
93+
target_include_directories(soxr_ext PRIVATE ${SOXR_INCLUDE_DIR})
94+
95+
else ()
96+
target_link_libraries(soxr_ext PRIVATE soxr)
8497
target_include_directories(soxr_ext PRIVATE
8598
src
8699
libsoxr/src

0 commit comments

Comments
 (0)