Skip to content

Fix CoreML-enabled static build on macOS#27960

Open
umireon wants to merge 1 commit intomicrosoft:mainfrom
umireon:umireon/fix-export-coreml-proto
Open

Fix CoreML-enabled static build on macOS#27960
umireon wants to merge 1 commit intomicrosoft:mainfrom
umireon:umireon/fix-export-coreml-proto

Conversation

@umireon
Copy link
Copy Markdown

@umireon umireon commented Apr 3, 2026

Description

The coreml_proto target must be properly exported to onnxruntimeTargets. Its include directories must not contain any paths from the build tree during the install phase.

Motivation and Context

This change fixes a build failure on macOS when attempting to create a static library of ONNX Runtime with the CoreML Execution Provider (EP) using the following command:

./build.sh --use_coreml --cmake_extra_defines CMAKE_POLICY_VERSION_MINIMUM=3.5

Note: CMAKE_POLICY_VERSION_MINIMUM=3.5 is required for modern macOS environment. The current version of CMake available on Homebrew is 4.3.1, and it won't allow cmake_minimum_required(3.5). It seems that ignoring cmake_minimum_required(3.5) in the ONNX Runtime tree is not harmful.

The build fails because coreml_proto has no export sets specified and it violates CMake's requirement that exported targets must not reference paths from the build tree when installed. Currently, coreml_proto depends on ${CMAKE_CURRENT_BINARY_DIR} to locate generated Protobuf definitions. I suppose these definitions are required only during the build phase and not needed for the installation.

This change set resolves it by:

  • Exporting coreml_proto to ${PROJECT_NAME}Targets.
  • Replacing ${CMAKE_CURRENT_BINARY_DIR} with $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>.

@umireon umireon marked this pull request as ready for review April 3, 2026 04:25
Copilot AI review requested due to automatic review settings April 3, 2026 04:25
@umireon umireon changed the title Fix CoreML-enabled static build Fix CoreML-enabled static build on macOS Apr 3, 2026
The `coreml_proto` target must be properly exported to `onnxruntimeTargets`. Its include directories must not contain any paths from the build tree during the install phase.

Signed-off-by: Kaito Udagawa <umireon@kaito.tokyo>
@umireon umireon force-pushed the umireon/fix-export-coreml-proto branch from 13fde9b to f243ded Compare April 3, 2026 04:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes macOS static builds with the CoreML Execution Provider by making the coreml_proto target compliant with CMake install/export requirements (no build-tree include paths in the install interface) and ensuring it is exported alongside other ONNX Runtime targets.

Changes:

  • Export coreml_proto via ${PROJECT_NAME}Targets so static builds can install/export dependent targets cleanly.
  • Restrict coreml_proto’s generated-header include path to build-time only using $<BUILD_INTERFACE:...> to avoid build-tree paths during installation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sroussey
Copy link
Copy Markdown
Contributor

sroussey commented Apr 3, 2026

Is this related to why onnx-runtime-node dropped support for MacOS x86-64 a few releases ago?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants