File tree Expand file tree Collapse file tree 1 file changed +30
-13
lines changed
Expand file tree Collapse file tree 1 file changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -41,18 +41,35 @@ else()
4141endif ()
4242target_link_libraries (pylibremidi PUBLIC libremidi readerwriterqueue Boost::headers Boost::variant2 Boost::container )
4343
44- nanobind_add_stub (
45- pylibremidi_stub
46- MODULE pylibremidi
47- OUTPUT pylibremidi.pyi
48- PYTHON_PATH $<TARGET_FILE_DIR :pylibremidi >
49- DEPENDS pylibremidi
50- )
51-
5244install (TARGETS pylibremidi LIBRARY DESTINATION .)
5345
54- install (
55- FILES ${CMAKE_CURRENT_BINARY_DIR} /pylibremidi.pyi
56- DESTINATION .
57- OPTIONAL
58- )
46+ # Stub generation requires importing the module, so skip when cross-compiling
47+ # (e.g., building x86_64 on ARM64 macOS or vice versa)
48+ set (CAN_RUN_STUB_GENERATOR TRUE )
49+ if (APPLE )
50+ execute_process (COMMAND uname -m OUTPUT_VARIABLE HOST_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE )
51+ if (CMAKE_OSX_ARCHITECTURES)
52+ set (TARGET_ARCH "${CMAKE_OSX_ARCHITECTURES} " )
53+ else ()
54+ set (TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR} " )
55+ endif ()
56+ if (NOT HOST_ARCH STREQUAL TARGET_ARCH)
57+ set (CAN_RUN_STUB_GENERATOR FALSE )
58+ endif ()
59+ endif ()
60+
61+ if (CAN_RUN_STUB_GENERATOR)
62+ nanobind_add_stub (
63+ pylibremidi_stub
64+ MODULE pylibremidi
65+ OUTPUT pylibremidi.pyi
66+ PYTHON_PATH $<TARGET_FILE_DIR :pylibremidi >
67+ DEPENDS pylibremidi
68+ )
69+
70+ install (
71+ FILES ${CMAKE_CURRENT_BINARY_DIR} /pylibremidi.pyi
72+ DESTINATION .
73+ OPTIONAL
74+ )
75+ endif ()
You can’t perform that action at this time.
0 commit comments