Skip to content

Fix CoreML-enabled static build on macOS - #27960

Merged
yuslepukhin merged 1 commit into
microsoft:mainfrom
umireon:umireon/fix-export-coreml-proto
Jun 23, 2026
Merged

Fix CoreML-enabled static build on macOS#27960
yuslepukhin merged 1 commit into
microsoft:mainfrom
umireon:umireon/fix-export-coreml-proto

Conversation

@umireon

@umireon umireon commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

sroussey commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@edgchen1

Copy link
Copy Markdown
Contributor

will try to close and reopen to restart CI builds

@edgchen1 edgchen1 closed this Jun 16, 2026
@edgchen1 edgchen1 reopened this Jun 16, 2026
@yuslepukhin
yuslepukhin merged commit 9db2150 into microsoft:main Jun 23, 2026
90 of 92 checks passed
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.

5 participants