-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Create CMake option onnxruntime_USE_VCPKG
#21348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think cmake is a great choice. Besides, we might decouple the work. You may create a vcpkg config file, then install all the packages via "vcpkg install", then let cmake search installed packages there when running ONNX Runtime's build.py script. Then in theory you don't need to modify any ONNX Runtime's cmake file. No matter which way you choose to go, we always greatly appreciate your contribution. |
|
36919b0 New GitHub Actions jobs for vcpkg build 6227f5f Trying to merge |
* Detect protoc path for build.py * Run vcpkg for each build.py run Reorganized vcpkg install folder and CMake build directory
onnxruntime_USE_VCPKG
* CUDA build will be tried next time... * Remove onnxruntime_vcpkg_deps.cmake
|
Updated note and title. Dropped CUDA feature support in this PR. |
* add dropped changes
|
/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline |
|
/azp run Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed |
|
Azure Pipelines successfully started running 9 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 9 pipeline(s). |
|
We probably need to wait for the next absl release. |
|
|
* cmake: use eigen from FetchContent * ONNX will be used with FetchContent Current vcpkg upstream doesn't support onnx 1.16.0+. Here, we will mix FetchContent and vcpkg-supported find_package
|
/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline |
|
/azp run Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CUDA CI Pipeline |
1 similar comment
|
/azp run Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CUDA CI Pipeline |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
Azure Pipelines successfully started running 7 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 7 pipeline(s). |
|
/azp run Windows GPU DML CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline |
|
Azure Pipelines successfully started running 7 pipeline(s). |
|
Thank you! |
|
Thank you, @snnn. I will submit another PR if microsoft/vcpkg needs it. |
### Description Changes vcpkg manifest and configuration file (vcpkg.json & vcpkg-configuration.json) * Update vcpkg version to https://github.com/microsoft/vcpkg/releases/tag/2024.12.16 * Use protobuf 3.21.12(= `v21.12`) to sync with [cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt) * Resolve #22750 * Add `onnx` to vcpkg manifest so `find_package(ONNX)` and `find_dependency(Protobuf)` can work as expected. * Currently, It uses 1.16.2 * v1.17.0 will become available after microsoft/vcpkg#42942 However, `onnx` in vcpkg doesn't configure `ONNX_DISABLE_STATIC_REGISTRATION` build option. * microsoft/vcpkg#38879 * Create "cmake/vcpkg-triplets/" folder and triplet files which use `VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option * This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI steps, which is a bit inconvenient. I will try to find simple way to get same result ### Motivation and Context * Help #23158 * "ONNX is not consumed from vcpkg" * "Mismatch protobuf version. When vcpkg is enabled , we should not fetch protoc from Github which may cause version mismatches." * microsoft/vcpkg#43126 * #21348
### Description Changes vcpkg manifest and configuration file (vcpkg.json & vcpkg-configuration.json) * Update vcpkg version to https://github.com/microsoft/vcpkg/releases/tag/2024.12.16 * Use protobuf 3.21.12(= `v21.12`) to sync with [cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt) * Resolve #22750 * Add `onnx` to vcpkg manifest so `find_package(ONNX)` and `find_dependency(Protobuf)` can work as expected. * Currently, It uses 1.16.2 * v1.17.0 will become available after microsoft/vcpkg#42942 However, `onnx` in vcpkg doesn't configure `ONNX_DISABLE_STATIC_REGISTRATION` build option. * microsoft/vcpkg#38879 * Create "cmake/vcpkg-triplets/" folder and triplet files which use `VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option * This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI steps, which is a bit inconvenient. I will try to find simple way to get same result ### Motivation and Context * Help #23158 * "ONNX is not consumed from vcpkg" * "Mismatch protobuf version. When vcpkg is enabled , we should not fetch protoc from Github which may cause version mismatches." * microsoft/vcpkg#43126 * #21348
### Description Changes vcpkg manifest and configuration file (vcpkg.json & vcpkg-configuration.json) * Update vcpkg version to https://github.com/microsoft/vcpkg/releases/tag/2024.12.16 * Use protobuf 3.21.12(= `v21.12`) to sync with [cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt) * Resolve microsoft#22750 * Add `onnx` to vcpkg manifest so `find_package(ONNX)` and `find_dependency(Protobuf)` can work as expected. * Currently, It uses 1.16.2 * v1.17.0 will become available after microsoft/vcpkg#42942 However, `onnx` in vcpkg doesn't configure `ONNX_DISABLE_STATIC_REGISTRATION` build option. * microsoft/vcpkg#38879 * Create "cmake/vcpkg-triplets/" folder and triplet files which use `VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option * This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI steps, which is a bit inconvenient. I will try to find simple way to get same result ### Motivation and Context * Help microsoft#23158 * "ONNX is not consumed from vcpkg" * "Mismatch protobuf version. When vcpkg is enabled , we should not fetch protoc from Github which may cause version mismatches." * microsoft/vcpkg#43126 * microsoft#21348
### Description Changes vcpkg manifest and configuration file (vcpkg.json & vcpkg-configuration.json) * Update vcpkg version to https://github.com/microsoft/vcpkg/releases/tag/2024.12.16 * Use protobuf 3.21.12(= `v21.12`) to sync with [cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt) * Resolve #22750 * Add `onnx` to vcpkg manifest so `find_package(ONNX)` and `find_dependency(Protobuf)` can work as expected. * Currently, It uses 1.16.2 * v1.17.0 will become available after microsoft/vcpkg#42942 However, `onnx` in vcpkg doesn't configure `ONNX_DISABLE_STATIC_REGISTRATION` build option. * microsoft/vcpkg#38879 * Create "cmake/vcpkg-triplets/" folder and triplet files which use `VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option * This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI steps, which is a bit inconvenient. I will try to find simple way to get same result ### Motivation and Context * Help #23158 * "ONNX is not consumed from vcpkg" * "Mismatch protobuf version. When vcpkg is enabled , we should not fetch protoc from Github which may cause version mismatches." * microsoft/vcpkg#43126 * #21348
### Description Changes vcpkg manifest and configuration file (vcpkg.json & vcpkg-configuration.json) * Update vcpkg version to https://github.com/microsoft/vcpkg/releases/tag/2024.12.16 * Use protobuf 3.21.12(= `v21.12`) to sync with [cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt) * Resolve #22750 * Add `onnx` to vcpkg manifest so `find_package(ONNX)` and `find_dependency(Protobuf)` can work as expected. * Currently, It uses 1.16.2 * v1.17.0 will become available after microsoft/vcpkg#42942 However, `onnx` in vcpkg doesn't configure `ONNX_DISABLE_STATIC_REGISTRATION` build option. * microsoft/vcpkg#38879 * Create "cmake/vcpkg-triplets/" folder and triplet files which use `VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option * This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI steps, which is a bit inconvenient. I will try to find simple way to get same result ### Motivation and Context * Help #23158 * "ONNX is not consumed from vcpkg" * "Mismatch protobuf version. When vcpkg is enabled , we should not fetch protoc from Github which may cause version mismatches." * microsoft/vcpkg#43126 * #21348
### Description See the [example repository](https://github.com/jordanozang/onnxruntime_minimal_static) for a minimal example of using the static CMake Config. - Add libraries built during the static onnxruntime build (onnxruntime_common, onnxruntime_mlas, etc.) to the onnxruntime export set. Additionally, add an onnxruntime::onnxruntime interface target that behaves much the same as that target in the shared build case. ``find_package(onnxruntime REQUIRED)`` ``target_link_libraries(example PRIVATE onnxruntime::onnxruntime)`` should now work. - Minor modifications to ensure that dependency targets like Boost::mp11 are treated as imported targets and not part of the build interface. - Static webgpu builds will currently not generate this CMake export ### Motivation and Context - Resolves Issue #21351 - Builds on Pull Request #21348
### Description See the [example repository](https://github.com/jordanozang/onnxruntime_minimal_static) for a minimal example of using the static CMake Config. - Add libraries built during the static onnxruntime build (onnxruntime_common, onnxruntime_mlas, etc.) to the onnxruntime export set. Additionally, add an onnxruntime::onnxruntime interface target that behaves much the same as that target in the shared build case. ``find_package(onnxruntime REQUIRED)`` ``target_link_libraries(example PRIVATE onnxruntime::onnxruntime)`` should now work. - Minor modifications to ensure that dependency targets like Boost::mp11 are treated as imported targets and not part of the build interface. - Static webgpu builds will currently not generate this CMake export ### Motivation and Context - Resolves Issue microsoft#21351 - Builds on Pull Request microsoft#21348
Changes
onnxruntime_USE_VCPKG. It will be used in the vcpkg portEspecially ONNX, Protobuf, and Flatbuffers version can be different
onnxruntime_external_deps.cmakeFetchContent_Declareto tryfind_package.See https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
FetchContent_DeclareandFetchContent_MakeAvailable(oronnxruntime_fetchcontent_makeavailable) to closer lines.It was too hard to navigate the entire file to search related sections...
IMPORTEDtargets like build targets (e.g.ONNX::onnx-->onnx)x64-windowsandx64-osx--use_vcpkgoption: it needsCMAKE_TOOLCHAIN_FILEwith vcpkg.cmake toolchain script--compile_no_warning_as_erroris recommended because library version differences will cause unexpected compiler warningspython ./tools/ci_build/build.py \ --compile_no_warning_as_error \ --use_vcpkg \ --cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ --cmake_extra_defines "VCPKG_TARGET_TRIPLET=..."Vcpkgfor Windows and macOSSimilar to the CMakePresets.json usage
Motivation and Context
Future Works?
More feature coverage with the vcpkg supported libraries