From 71ad31ceee9a82d95629295a2c6d3db1993094de Mon Sep 17 00:00:00 2001 From: jathu Date: Thu, 20 Mar 2025 17:39:19 -0700 Subject: [PATCH 1/4] split targets --- backends/apple/coreml/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 42e561e083d..d849a1eb4b7 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,16 @@ install( INCLUDES DESTINATION ${_common_include_directories} ) + +if(EXECUTORCH_BUILD_COREML) + add_subdirectory(${EXECUTORCH_ROOT}/third-party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11) + + 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) + target_link_libraries(executorchcoreml PRIVATE coreml_inmemoryfs) +endif() From bb755a12f88d6ea7c9a5160be74a25be95c0f11d Mon Sep 17 00:00:00 2001 From: jathu Date: Fri, 21 Mar 2025 07:49:57 -0700 Subject: [PATCH 2/4] address comments --- backends/apple/coreml/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index d849a1eb4b7..268d2c88b05 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -25,8 +25,6 @@ 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 From 4c09e91b5c6a040b4417935d787549bce326bc05 Mon Sep 17 00:00:00 2001 From: jathu Date: Fri, 21 Mar 2025 08:18:37 -0700 Subject: [PATCH 3/4] address comments --- backends/apple/coreml/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 268d2c88b05..93c8833a7c5 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 @@ -230,7 +232,8 @@ install( DESTINATION ${_common_include_directories} ) -if(EXECUTORCH_BUILD_COREML) +# We only care about building the pybinding when building for macOS wheels. +if(EXECUTORCH_BUILD_COREML AND EXECUTORCH_BUILD_PYBIND) add_subdirectory(${EXECUTORCH_ROOT}/third-party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11) pybind11_add_module(executorchcoreml SHARED runtime/inmemoryfs/inmemory_filesystem_py.cpp) @@ -239,6 +242,5 @@ if(EXECUTORCH_BUILD_COREML) 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) - target_link_libraries(executorchcoreml PRIVATE coreml_inmemoryfs) + target_link_libraries(executorchcoreml PRIVATE coreml_util coreml_inmemoryfs) endif() From 588fa4009edcb444fadc3d28c37a187b0f7a6f92 Mon Sep 17 00:00:00 2001 From: jathu Date: Tue, 25 Mar 2025 09:04:07 -0700 Subject: [PATCH 4/4] address pybind include comment --- backends/apple/coreml/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 93c8833a7c5..06807279978 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -234,7 +234,9 @@ install( # We only care about building the pybinding when building for macOS wheels. if(EXECUTORCH_BUILD_COREML AND EXECUTORCH_BUILD_PYBIND) - add_subdirectory(${EXECUTORCH_ROOT}/third-party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11) + 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)