diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 42e561e083d..06807279978 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -25,6 +25,8 @@ endif() option(COREML_BUILD_EXECUTOR_RUNNER "Build CoreML executor runner." OFF) +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) + # inmemoryfs sources set(INMEMORYFS_SOURCES runtime/inmemoryfs/inmemory_filesystem.cpp @@ -229,3 +231,18 @@ install( INCLUDES DESTINATION ${_common_include_directories} ) + +# We only care about building the pybinding when building for macOS wheels. +if(EXECUTORCH_BUILD_COREML AND EXECUTORCH_BUILD_PYBIND) + if(NOT TARGET pybind11::pybind11) + add_subdirectory(${EXECUTORCH_ROOT}/third-party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11) + endif() + + pybind11_add_module(executorchcoreml SHARED runtime/inmemoryfs/inmemory_filesystem_py.cpp) + + target_compile_options(executorchcoreml PRIVATE -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) + if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + target_compile_options(executorchcoreml PRIVATE -g) + endif() + target_link_libraries(executorchcoreml PRIVATE coreml_util coreml_inmemoryfs) +endif()