mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-29 23:06:41 +00:00
Create CMake option onnxruntime_USE_VCPKG (#21348)
### Changes
1. CMake option `onnxruntime_USE_VCPKG`. It will be used in the vcpkg
port
* Unit test may fail because this option leads to a mixture of
unexpected external library versions.
Especially ONNX, Protobuf, and Flatbuffers version can be different
2. Overhaul of `onnxruntime_external_deps.cmake`
* Make `FetchContent_Declare` to try `find_package`.
See
https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
* Relocated `FetchContent_Declare` and `FetchContent_MakeAvailable`(or
`onnxruntime_fetchcontent_makeavailable`) to closer lines.
It was too hard to navigate the entire file to search related
sections...
* Alias `IMPORTED` targets like build targets (e.g. `ONNX::onnx` -->
`onnx`)
```cmake
# The script uses `find_package` with the changes.
# In this case, use vcpkg to search dependencies
# See https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
include(external/onnxruntime_external_deps.cmake)
```
3. Create CMakePresets.json and presets to [run vcpkg in manifest
mode](https://learn.microsoft.com/en-us/vcpkg/concepts/manifest-mode)
* Currently, it's NOT for training build
* Main triplets are `x64-windows` and `x64-osx`
```pwsh
Push-Location "cmake"
cmake --preset "x64-windows-vcpkg"
cmake --build --preset "x64-windows-vcpkg-debug"
Pop-Location
```
```bash
pushd "cmake"
cmake --preset "x64-osx-vcpkg"
cmake --build --preset "x64-osx-vcpkg-debug"
popd
```
4. Updated tools/ci_build/build.py
* `--use_vcpkg` option: it needs `CMAKE_TOOLCHAIN_FILE` with
[vcpkg.cmake toolchain
script](https://github.com/microsoft/vcpkg/blob/master/scripts/buildsystems/vcpkg.cmake)
* `--compile_no_warning_as_error` is recommended because library version
differences will cause unexpected compiler warnings
```bash
python ./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=..."
```
5. Created Job `Vcpkg` for Windows and macOS
* Show how to setup and use vcpkg.
Similar to the CMakePresets.json usage
### Motivation and Context
* Help #7150
* Help https://github.com/microsoft/vcpkg/pull/36850
* https://github.com/luncliff/vcpkg-registry/pull/212
* https://github.com/microsoft/vcpkg/pull/39881
* https://github.com/luncliff/vcpkg-registry/pull/215
* https://github.com/luncliff/vcpkg-registry/pull/216
* https://github.com/luncliff/vcpkg-registry/pull/227
*
https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
*
https://github.com/microsoft/vcpkg/blob/master/scripts/buildsystems/vcpkg.cmake
### Future Works?
More feature coverage with the vcpkg supported libraries
* CUDA feature support
* Training feature support
This commit is contained in:
parent
c5418f35d4
commit
f633caa0b1
13 changed files with 665 additions and 156 deletions
84
.github/workflows/mac.yml
vendored
84
.github/workflows/mac.yml
vendored
|
|
@ -58,6 +58,90 @@ jobs:
|
|||
--use_xnnpack \
|
||||
--use_binskim_compliant_compile_flags
|
||||
|
||||
Vcpkg:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ env.python_version }}
|
||||
|
||||
- name: "Run vcpkg(x64-osx)"
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
vcpkgDirectory: "${{ runner.temp }}/vcpkg"
|
||||
vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: "cmake/vcpkg.json"
|
||||
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
|
||||
env:
|
||||
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
|
||||
VCPKG_DEFAULT_TRIPLET: "x64-osx"
|
||||
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching
|
||||
|
||||
- name: "Run compile_schema.py"
|
||||
run: |
|
||||
# Runner's host triplet should be x64-osx or arm64-osx
|
||||
export FLATC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-osx/tools/flatbuffers"
|
||||
export PATH="$FLATC_DIR:$PATH"
|
||||
flatc --version
|
||||
python onnxruntime/core/flatbuffers/schema/compile_schema.py --flatc "$(which flatc)"
|
||||
|
||||
- name: "Detect protoc"
|
||||
id: protoc-detect
|
||||
run: |
|
||||
export PROTOC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-osx/tools/protobuf"
|
||||
export PATH="$PROTOC_DIR:$PATH"
|
||||
protoc --version
|
||||
echo "protoc_path=$(which protoc)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: "Run build.py(x64-osx)"
|
||||
run: |
|
||||
python ./tools/ci_build/build.py \
|
||||
--build_dir "build/x64-osx" \
|
||||
--skip_submodule_sync \
|
||||
--skip_tests \
|
||||
--compile_no_warning_as_error \
|
||||
--parallel \
|
||||
--path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" \
|
||||
--osx_arch x86_64 \
|
||||
--use_vcpkg \
|
||||
--cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
|
||||
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=x64-osx" \
|
||||
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \
|
||||
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
|
||||
shell: bash
|
||||
|
||||
- name: "Run vcpkg(arm64-osx)"
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
vcpkgDirectory: "${{ runner.temp }}/vcpkg"
|
||||
vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: "cmake/vcpkg.json"
|
||||
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
|
||||
env:
|
||||
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
|
||||
VCPKG_DEFAULT_TRIPLET: "arm64-osx"
|
||||
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching
|
||||
|
||||
- name: "Run build.py(arm64-osx)"
|
||||
run: |
|
||||
python ./tools/ci_build/build.py \
|
||||
--build_dir "build/arm64-osx" \
|
||||
--skip_submodule_sync \
|
||||
--skip_tests \
|
||||
--compile_no_warning_as_error \
|
||||
--parallel \
|
||||
--path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" \
|
||||
--osx_arch arm64 \
|
||||
--use_vcpkg \
|
||||
--cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
|
||||
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=arm64-osx" \
|
||||
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \
|
||||
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
|
||||
shell: bash
|
||||
|
||||
Objective-C-StaticAnalysis:
|
||||
runs-on: macos-14
|
||||
|
||||
|
|
|
|||
87
.github/workflows/windows.yml
vendored
87
.github/workflows/windows.yml
vendored
|
|
@ -42,3 +42,90 @@ jobs:
|
|||
# The build machine doesn't have a GPU. So the value of CMAKE_CUDA_ARCHITECTURES doesn't matter.
|
||||
- name: Build code
|
||||
run: python tools\ci_build\build.py --windows_sdk_version 10.0.22621.0 --enable_training --build_java --config Debug --build_dir D:\b --skip_submodule_sync --build_csharp --update --build --parallel --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_pybind --use_cuda --cuda_home=${{ github.workspace }}\cuda_sdk\v12.2 --enable_cuda_profiling --cmake_extra_defines CMAKE_CUDA_ARCHITECTURES=75
|
||||
|
||||
Vcpkg:
|
||||
runs-on: "windows-latest"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11.x'
|
||||
architecture: 'x64'
|
||||
|
||||
- name: "Run vcpkg(x64-windows)"
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
vcpkgDirectory: "C:/vcpkg" # use VCPKG_INSTALLATION_ROOT of the image
|
||||
doNotUpdateVcpkg: true
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: "cmake/vcpkg.json"
|
||||
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
|
||||
env:
|
||||
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
|
||||
VCPKG_DEFAULT_TRIPLET: "x64-windows"
|
||||
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching
|
||||
|
||||
- name: "Run compile_schema.py"
|
||||
run: |
|
||||
# Runner's host triplet should be x64-windows or arm64-windows
|
||||
$FLATC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-windows/tools/flatbuffers"
|
||||
$env:PATH="$FLATC_DIR;$env:PATH"
|
||||
flatc --version
|
||||
$FLATC_PATH = Join-Path "$FLATC_DIR" "flatc.exe"
|
||||
python onnxruntime/core/flatbuffers/schema/compile_schema.py --flatc "$FLATC_PATH"
|
||||
shell: pwsh
|
||||
|
||||
- name: "Detect protoc"
|
||||
id: protoc-detect
|
||||
run: |
|
||||
$PROTOC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-windows/tools/protobuf"
|
||||
$env:PATH="$PROTOC_DIR;$env:PATH"
|
||||
protoc --version
|
||||
$PROTOC_PATH = Join-Path "$PROTOC_DIR" "protoc.exe"
|
||||
"protoc_path=$PROTOC_PATH" >> $env:GITHUB_OUTPUT
|
||||
shell: pwsh
|
||||
|
||||
- name: "Run build.py(x64-windows)"
|
||||
run: |
|
||||
python tools\ci_build\build.py `
|
||||
--build_dir "cmake_build/x64-windows" `
|
||||
--skip_submodule_sync `
|
||||
--skip_tests `
|
||||
--compile_no_warning_as_error `
|
||||
--parallel `
|
||||
--path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" `
|
||||
--use_vcpkg `
|
||||
--cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
|
||||
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=x64-windows" `
|
||||
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" `
|
||||
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
|
||||
shell: pwsh
|
||||
|
||||
- name: "Run vcpkg(arm64-windows)"
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
vcpkgDirectory: "C:/vcpkg" # use VCPKG_INSTALLATION_ROOT of the image
|
||||
doNotUpdateVcpkg: true
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: "cmake/vcpkg.json"
|
||||
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
|
||||
env:
|
||||
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
|
||||
VCPKG_DEFAULT_TRIPLET: "arm64-windows"
|
||||
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching
|
||||
|
||||
- name: "Run build.py(arm64-windows)"
|
||||
run: |
|
||||
python tools\ci_build\build.py `
|
||||
--build_dir "cmake_build/arm64-windows" --arm64 `
|
||||
--skip_submodule_sync `
|
||||
--skip_tests `
|
||||
--compile_no_warning_as_error `
|
||||
--parallel `
|
||||
--path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" `
|
||||
--use_vcpkg `
|
||||
--cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
|
||||
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=arm64-windows" `
|
||||
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" `
|
||||
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
|
||||
shell: pwsh
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ include(CheckLanguage)
|
|||
include(CMakeDependentOption)
|
||||
include(FetchContent)
|
||||
include(CheckFunctionExists)
|
||||
include(GNUInstallDirs) # onnxruntime_providers_* require CMAKE_INSTALL_* variables
|
||||
|
||||
# TODO: update this once all system adapt c++20
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
|
|
@ -69,6 +70,7 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_
|
|||
endif()
|
||||
|
||||
# Options
|
||||
option(onnxruntime_USE_VCPKG "Build with the vcpkg package manager" OFF)
|
||||
option(onnxruntime_RUN_ONNX_TESTS "Enable ONNX Compatibility Testing" OFF)
|
||||
option(onnxruntime_GENERATE_TEST_REPORTS "Enable test report generation" OFF)
|
||||
option(onnxruntime_ENABLE_STATIC_ANALYSIS "Enable static analysis" OFF)
|
||||
|
|
@ -595,6 +597,7 @@ get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE)
|
|||
get_filename_component(REPO_ROOT "${REPO_ROOT}" ABSOLUTE)
|
||||
set(ONNXRUNTIME_INCLUDE_DIR ${REPO_ROOT}/include/onnxruntime)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/external)
|
||||
include(external/onnxruntime_external_deps.cmake)
|
||||
|
||||
set(ORT_WARNING_FLAGS)
|
||||
|
|
|
|||
192
cmake/CMakePresets.json
Normal file
192
cmake/CMakePresets.json
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
{
|
||||
"version": 6,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 25,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "vcpkg-manifest",
|
||||
"hidden": true,
|
||||
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"cacheVariables": {
|
||||
"VCPKG_INSTALLED_DIR": "${sourceParentDir}/.build"
|
||||
},
|
||||
"environment": {
|
||||
"VCPKG_FEATURE_FLGAS": "manifests,versions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "msvc-static-runtime",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"ONNX_USE_MSVC_STATIC_RUNTIME": true,
|
||||
"protobuf_MSVC_STATIC_RUNTIME": true,
|
||||
"gtest_force_shared_crt": false,
|
||||
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "unit-test",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"onnxruntime_RUN_ONNX_TESTS": true,
|
||||
"onnxruntime_BUILD_BENCHMARKS": true,
|
||||
"onnxruntime_BUILD_UNIT_TESTS": true,
|
||||
"onnxruntime_GENERATE_TEST_REPORTS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "x64-windows",
|
||||
"inherits": [
|
||||
"msvc-static-runtime",
|
||||
"unit-test"
|
||||
],
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "x64",
|
||||
"binaryDir": "${sourceParentDir}/cmake_build/x64-windows",
|
||||
"installDir": "${sourceParentDir}/cmake_build/out",
|
||||
"cacheVariables": {
|
||||
"onnxruntime_USE_XNNPACK": true,
|
||||
"onnxruntime_USE_DML": true,
|
||||
"onnxruntime_BUILD_SHARED_LIB": true,
|
||||
"CMAKE_CONFIGURATION_TYPES": "Debug;Release"
|
||||
},
|
||||
"vendor": {
|
||||
"microsoft.com/VisualStudioSettings/CMake/1.0": {
|
||||
"intelliSenseMode": "windows-msvc-x64"
|
||||
}
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "x64-windows-vcpkg",
|
||||
"inherits": [
|
||||
"unit-test",
|
||||
"vcpkg-manifest"
|
||||
],
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "x64",
|
||||
"binaryDir": "${sourceParentDir}/cmake_build/x64-windows",
|
||||
"installDir": "${sourceParentDir}/cmake_build/out",
|
||||
"cacheVariables": {
|
||||
"onnxruntime_USE_VCPKG": true,
|
||||
"onnxruntime_USE_XNNPACK": false,
|
||||
"onnxruntime_USE_DML": false,
|
||||
"onnxruntime_BUILD_SHARED_LIB": true,
|
||||
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
|
||||
"CMAKE_CONFIGURATION_TYPES": "Debug;Release",
|
||||
"VCPKG_INSTALL_OPTIONS": "--x-feature=tests",
|
||||
"VCPKG_TARGET_TRIPLET": "x64-windows"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "x64-osx",
|
||||
"inherits": [
|
||||
"unit-test"
|
||||
],
|
||||
"generator": "Xcode",
|
||||
"binaryDir": "${sourceParentDir}/cmake_build/x64-osx",
|
||||
"installDir": "${sourceParentDir}/cmake_build/out",
|
||||
"cacheVariables": {
|
||||
"CMAKE_OSX_ARCHITECTURES": "x86_64",
|
||||
"onnxruntime_BUILD_SHARED_LIB": true,
|
||||
"onnxruntime_USE_XNNPACK": false,
|
||||
"onnxruntime_USE_COREML": true,
|
||||
"onnxruntime_BUILD_OBJC": true,
|
||||
"onnxruntime_BUILD_APPLE_FRAMEWORK": true,
|
||||
"CMAKE_CONFIGURATION_TYPES": "Debug;Release"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "x64-osx-vcpkg",
|
||||
"inherits": [
|
||||
"x64-osx",
|
||||
"vcpkg-manifest"
|
||||
],
|
||||
"cacheVariables": {
|
||||
"onnxruntime_USE_VCPKG": true,
|
||||
"onnxruntime_USE_XNNPACK": false,
|
||||
"onnxruntime_USE_COREML": false,
|
||||
"onnxruntime_BUILD_OBJC": false,
|
||||
"onnxruntime_BUILD_APPLE_FRAMEWORK": false,
|
||||
"VCPKG_INSTALL_OPTIONS": "--x-feature=tests",
|
||||
"VCPKG_TARGET_TRIPLET": "x64-osx"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "x64-windows-debug",
|
||||
"configurePreset": "x64-windows",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "x64-windows-vcpkg-debug",
|
||||
"configurePreset": "x64-windows-vcpkg",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "x64-osx-debug",
|
||||
"configurePreset": "x64-osx",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "x64-osx-vcpkg-debug",
|
||||
"configurePreset": "x64-osx-vcpkg",
|
||||
"configuration": "Debug"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "x64-windows-debug",
|
||||
"configurePreset": "x64-windows",
|
||||
"configuration": "Debug",
|
||||
"output": {
|
||||
"verbosity": "default",
|
||||
"outputJUnitFile": "TEST-x64-windows-debug.xml",
|
||||
"outputLogFile": "TEST-x64-windows-debug.log",
|
||||
"outputOnFailure": true
|
||||
},
|
||||
"execution": {
|
||||
"noTestsAction": "error",
|
||||
"stopOnFailure": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "x64-windows-vcpkg-debug",
|
||||
"inherits": "x64-windows-debug",
|
||||
"configurePreset": "x64-windows-vcpkg"
|
||||
},
|
||||
{
|
||||
"name": "x64-osx-debug",
|
||||
"configurePreset": "x64-osx",
|
||||
"configuration": "Debug",
|
||||
"output": {
|
||||
"verbosity": "default",
|
||||
"outputJUnitFile": "TEST-x64-osx-debug.xml",
|
||||
"outputLogFile": "TEST-x64-osx-debug.log",
|
||||
"outputOnFailure": true
|
||||
},
|
||||
"execution": {
|
||||
"noTestsAction": "error",
|
||||
"stopOnFailure": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "x64-osx-vcpkg-debug",
|
||||
"inherits": "x64-osx-debug",
|
||||
"configurePreset": "x64-osx-vcpkg"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
cmake/external/abseil-cpp.cmake
vendored
4
cmake/external/abseil-cpp.cmake
vendored
|
|
@ -27,7 +27,7 @@ FetchContent_Declare(
|
|||
URL ${DEP_URL_abseil_cpp}
|
||||
URL_HASH SHA1=${DEP_SHA1_abseil_cpp}
|
||||
PATCH_COMMAND ${ABSL_PATCH_COMMAND}
|
||||
FIND_PACKAGE_ARGS 20240116 NAMES absl
|
||||
FIND_PACKAGE_ARGS NAMES absl
|
||||
)
|
||||
|
||||
onnxruntime_fetchcontent_makeavailable(abseil_cpp)
|
||||
|
|
@ -142,4 +142,4 @@ absl::throw_delegate
|
|||
absl::memory
|
||||
absl::charset
|
||||
absl::endian
|
||||
absl::config)
|
||||
absl::config)
|
||||
|
|
|
|||
340
cmake/external/onnxruntime_external_deps.cmake
vendored
340
cmake/external/onnxruntime_external_deps.cmake
vendored
|
|
@ -1,4 +1,4 @@
|
|||
message("Loading Dependencies URLs ...")
|
||||
message(STATUS "Loading Dependencies URLs ...")
|
||||
|
||||
include(external/helper_functions.cmake)
|
||||
|
||||
|
|
@ -27,7 +27,9 @@ foreach(ONNXRUNTIME_DEP IN LISTS ONNXRUNTIME_DEPS_LIST)
|
|||
endif()
|
||||
endforeach()
|
||||
|
||||
message("Loading Dependencies ...")
|
||||
message(STATUS "Loading Dependencies ...")
|
||||
include(FetchContent)
|
||||
|
||||
# ABSL should be included before protobuf because protobuf may use absl
|
||||
include(external/abseil-cpp.cmake)
|
||||
|
||||
|
|
@ -39,6 +41,7 @@ FetchContent_Declare(
|
|||
URL_HASH SHA1=${DEP_SHA1_re2}
|
||||
FIND_PACKAGE_ARGS NAMES re2
|
||||
)
|
||||
onnxruntime_fetchcontent_makeavailable(re2)
|
||||
|
||||
if (onnxruntime_BUILD_UNIT_TESTS)
|
||||
# WebAssembly threading support in Node.js is still an experimental feature and
|
||||
|
|
@ -65,6 +68,7 @@ if (onnxruntime_BUILD_UNIT_TESTS)
|
|||
URL_HASH SHA1=${DEP_SHA1_googletest}
|
||||
FIND_PACKAGE_ARGS 1.14.0...<2.0.0 NAMES GTest
|
||||
)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
endif()
|
||||
|
||||
if (onnxruntime_BUILD_BENCHMARKS)
|
||||
|
|
@ -77,50 +81,41 @@ if (onnxruntime_BUILD_BENCHMARKS)
|
|||
google_benchmark
|
||||
URL ${DEP_URL_google_benchmark}
|
||||
URL_HASH SHA1=${DEP_SHA1_google_benchmark}
|
||||
FIND_PACKAGE_ARGS NAMES benchmark
|
||||
)
|
||||
onnxruntime_fetchcontent_makeavailable(google_benchmark)
|
||||
endif()
|
||||
|
||||
if (NOT WIN32)
|
||||
FetchContent_Declare(
|
||||
FetchContent_Declare(
|
||||
google_nsync
|
||||
URL ${DEP_URL_google_nsync}
|
||||
URL_HASH SHA1=${DEP_SHA1_google_nsync}
|
||||
FIND_PACKAGE_ARGS NAMES nsync
|
||||
)
|
||||
endif()
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/external)
|
||||
FIND_PACKAGE_ARGS NAMES nsync unofficial-nsync
|
||||
)
|
||||
#nsync tests failed on Mac Build
|
||||
set(NSYNC_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
|
||||
onnxruntime_fetchcontent_makeavailable(google_nsync)
|
||||
|
||||
FetchContent_Declare(
|
||||
mimalloc
|
||||
URL ${DEP_URL_mimalloc}
|
||||
URL_HASH SHA1=${DEP_SHA1_mimalloc}
|
||||
)
|
||||
|
||||
|
||||
# Flatbuffers
|
||||
# We do not need to build flatc for iOS or Android Cross Compile
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATC" FORCE)
|
||||
endif()
|
||||
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "FLATBUFFERS_BUILD_TESTS" FORCE)
|
||||
set(FLATBUFFERS_INSTALL OFF CACHE BOOL "FLATBUFFERS_INSTALL" FORCE)
|
||||
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATHASH" FORCE)
|
||||
set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "FLATBUFFERS_BUILD_FLATLIB" FORCE)
|
||||
if(Patch_FOUND)
|
||||
set(ONNXRUNTIME_FLATBUFFERS_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/flatbuffers/flatbuffers.patch)
|
||||
else()
|
||||
set(ONNXRUNTIME_FLATBUFFERS_PATCH_COMMAND "")
|
||||
if (google_nsync_SOURCE_DIR)
|
||||
add_library(nsync::nsync_cpp ALIAS nsync_cpp)
|
||||
target_include_directories(nsync_cpp PUBLIC ${google_nsync_SOURCE_DIR}/public)
|
||||
endif()
|
||||
if(TARGET unofficial::nsync::nsync_cpp AND NOT TARGET nsync::nsync_cpp)
|
||||
message(STATUS "Aliasing unofficial::nsync::nsync_cpp to nsync::nsync_cpp")
|
||||
add_library(nsync::nsync_cpp ALIAS unofficial::nsync::nsync_cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#flatbuffers 1.11.0 does not have flatbuffers::IsOutRange, therefore we require 1.12.0+
|
||||
FetchContent_Declare(
|
||||
flatbuffers
|
||||
URL ${DEP_URL_flatbuffers}
|
||||
URL_HASH SHA1=${DEP_SHA1_flatbuffers}
|
||||
PATCH_COMMAND ${ONNXRUNTIME_FLATBUFFERS_PATCH_COMMAND}
|
||||
FIND_PACKAGE_ARGS 23.5.9 NAMES Flatbuffers
|
||||
)
|
||||
|
||||
if(onnxruntime_USE_MIMALLOC)
|
||||
FetchContent_Declare(
|
||||
mimalloc
|
||||
URL ${DEP_URL_mimalloc}
|
||||
URL_HASH SHA1=${DEP_SHA1_mimalloc}
|
||||
FIND_PACKAGE_ARGS NAMES mimalloc
|
||||
)
|
||||
FetchContent_MakeAvailable(mimalloc)
|
||||
endif()
|
||||
|
||||
#Protobuf depends on utf8_range
|
||||
FetchContent_Declare(
|
||||
|
|
@ -133,6 +128,10 @@ FetchContent_Declare(
|
|||
set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Build test suite" FORCE)
|
||||
set(utf8_range_ENABLE_INSTALL OFF CACHE BOOL "Configure installation" FORCE)
|
||||
|
||||
# The next line will generate an error message "fatal: not a git repository", but it is ok. It is from flatbuffers
|
||||
onnxruntime_fetchcontent_makeavailable(utf8_range)
|
||||
# protobuf's cmake/utf8_range.cmake has the following line
|
||||
include_directories(${utf8_range_SOURCE_DIR})
|
||||
|
||||
# Download a protoc binary from Internet if needed
|
||||
if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
|
||||
|
|
@ -146,12 +145,12 @@ if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
|
|||
FetchContent_Declare(protoc_binary URL ${DEP_URL_protoc_mac_universal} URL_HASH SHA1=${DEP_SHA1_protoc_mac_universal})
|
||||
FetchContent_Populate(protoc_binary)
|
||||
if(protoc_binary_SOURCE_DIR)
|
||||
message("Use prebuilt protoc")
|
||||
message(STATUS "Use prebuilt protoc")
|
||||
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc)
|
||||
set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
|
||||
endif()
|
||||
elseif (CMAKE_CROSSCOMPILING)
|
||||
message("CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
message(STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FetchContent_Declare(protoc_binary URL ${DEP_URL_protoc_win64} URL_HASH SHA1=${DEP_SHA1_protoc_win64})
|
||||
|
|
@ -162,7 +161,7 @@ if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
|
|||
endif()
|
||||
|
||||
if(protoc_binary_SOURCE_DIR)
|
||||
message("Use prebuilt protoc")
|
||||
message(STATUS "Use prebuilt protoc")
|
||||
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc.exe)
|
||||
set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
|
||||
endif()
|
||||
|
|
@ -179,7 +178,7 @@ if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
|
|||
endif()
|
||||
|
||||
if(protoc_binary_SOURCE_DIR)
|
||||
message("Use prebuilt protoc")
|
||||
message(STATUS "Use prebuilt protoc")
|
||||
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc)
|
||||
set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
|
||||
endif()
|
||||
|
|
@ -217,7 +216,7 @@ FetchContent_Declare(
|
|||
URL ${DEP_URL_protobuf}
|
||||
URL_HASH SHA1=${DEP_SHA1_protobuf}
|
||||
PATCH_COMMAND ${ONNXRUNTIME_PROTOBUF_PATCH_COMMAND}
|
||||
FIND_PACKAGE_ARGS 3.21.12 NAMES Protobuf
|
||||
FIND_PACKAGE_ARGS NAMES Protobuf protobuf
|
||||
)
|
||||
|
||||
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests" FORCE)
|
||||
|
|
@ -239,6 +238,51 @@ endif()
|
|||
include(protobuf_function)
|
||||
#protobuf end
|
||||
|
||||
onnxruntime_fetchcontent_makeavailable(Protobuf)
|
||||
if(Protobuf_FOUND)
|
||||
message(STATUS "Protobuf version: ${Protobuf_VERSION}")
|
||||
else()
|
||||
# Adjust warning flags
|
||||
if (TARGET libprotoc)
|
||||
if (NOT MSVC)
|
||||
target_compile_options(libprotoc PRIVATE "-w")
|
||||
endif()
|
||||
endif()
|
||||
if (TARGET protoc)
|
||||
add_executable(protobuf::protoc ALIAS protoc)
|
||||
if (UNIX AND onnxruntime_ENABLE_LTO)
|
||||
#https://github.com/protocolbuffers/protobuf/issues/5923
|
||||
target_link_options(protoc PRIVATE "-Wl,--no-as-needed")
|
||||
endif()
|
||||
if (NOT MSVC)
|
||||
target_compile_options(protoc PRIVATE "-w")
|
||||
endif()
|
||||
get_target_property(PROTOC_OSX_ARCH protoc OSX_ARCHITECTURES)
|
||||
if (PROTOC_OSX_ARCH)
|
||||
if (${CMAKE_HOST_SYSTEM_PROCESSOR} IN_LIST PROTOC_OSX_ARCH)
|
||||
message(STATUS "protoc can run")
|
||||
else()
|
||||
list(APPEND PROTOC_OSX_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
set_target_properties(protoc PROPERTIES OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
set_target_properties(libprotoc PROPERTIES OSX_ARCHITECTURES "${PROTOC_OSX_ARCH}")
|
||||
set_target_properties(libprotobuf PROPERTIES OSX_ARCHITECTURES "${PROTOC_OSX_ARCH}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (TARGET libprotobuf AND NOT MSVC)
|
||||
target_compile_options(libprotobuf PRIVATE "-w")
|
||||
endif()
|
||||
if (TARGET libprotobuf-lite AND NOT MSVC)
|
||||
target_compile_options(libprotobuf-lite PRIVATE "-w")
|
||||
endif()
|
||||
endif()
|
||||
if (onnxruntime_USE_FULL_PROTOBUF)
|
||||
set(PROTOBUF_LIB protobuf::libprotobuf)
|
||||
else()
|
||||
set(PROTOBUF_LIB protobuf::libprotobuf-lite)
|
||||
endif()
|
||||
|
||||
# date
|
||||
set(ENABLE_DATE_TESTING OFF CACHE BOOL "" FORCE)
|
||||
set(USE_SYSTEM_TZ_DB ON CACHE BOOL "" FORCE)
|
||||
|
||||
|
|
@ -254,7 +298,16 @@ FetchContent_Declare(
|
|||
mp11
|
||||
URL ${DEP_URL_mp11}
|
||||
URL_HASH SHA1=${DEP_SHA1_mp11}
|
||||
FIND_PACKAGE_ARGS NAMES Boost
|
||||
)
|
||||
onnxruntime_fetchcontent_makeavailable(mp11)
|
||||
if(NOT TARGET Boost::mp11)
|
||||
if(onnxruntime_USE_VCPKG)
|
||||
find_package(Boost REQUIRED)
|
||||
endif()
|
||||
message(STATUS "Aliasing Boost::headers to Boost::mp11")
|
||||
add_library(Boost::mp11 ALIAS Boost::headers)
|
||||
endif()
|
||||
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
set(JSON_Install OFF CACHE INTERNAL "")
|
||||
|
|
@ -265,6 +318,7 @@ FetchContent_Declare(
|
|||
URL_HASH SHA1=${DEP_SHA1_json}
|
||||
FIND_PACKAGE_ARGS 3.10 NAMES nlohmann_json
|
||||
)
|
||||
onnxruntime_fetchcontent_makeavailable(nlohmann_json)
|
||||
|
||||
#TODO: include clog first
|
||||
if (onnxruntime_ENABLE_CPUINFO)
|
||||
|
|
@ -301,20 +355,6 @@ else()
|
|||
set(CPUINFO_SUPPORTED FALSE)
|
||||
endif()
|
||||
|
||||
# xnnpack depends on clog
|
||||
# Android build should use the system's log library instead of clog
|
||||
if ((CPUINFO_SUPPORTED OR onnxruntime_USE_XNNPACK) AND NOT ANDROID)
|
||||
set(CLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(
|
||||
pytorch_clog
|
||||
URL ${DEP_URL_pytorch_cpuinfo}
|
||||
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
|
||||
SOURCE_SUBDIR deps/clog
|
||||
)
|
||||
set(ONNXRUNTIME_CLOG_PROJ pytorch_clog)
|
||||
set(ONNXRUNTIME_CLOG_TARGET_NAME clog)
|
||||
endif()
|
||||
|
||||
if (CPUINFO_SUPPORTED)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
set(IOS ON CACHE INTERNAL "")
|
||||
|
|
@ -333,7 +373,7 @@ if (CPUINFO_SUPPORTED)
|
|||
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE INTERNAL "")
|
||||
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE INTERNAL "")
|
||||
if(onnxruntime_target_platform STREQUAL "ARM64EC")
|
||||
message("Applying a patch for Windows ARM64EC in cpuinfo")
|
||||
message(STATUS "Applying a patch for Windows ARM64EC in cpuinfo")
|
||||
FetchContent_Declare(
|
||||
pytorch_cpuinfo
|
||||
URL ${DEP_URL_pytorch_cpuinfo}
|
||||
|
|
@ -350,20 +390,33 @@ if (CPUINFO_SUPPORTED)
|
|||
)
|
||||
endif()
|
||||
set(ONNXRUNTIME_CPUINFO_PROJ pytorch_cpuinfo)
|
||||
onnxruntime_fetchcontent_makeavailable(${ONNXRUNTIME_CPUINFO_PROJ})
|
||||
if(TARGET cpuinfo::cpuinfo AND NOT TARGET cpuinfo)
|
||||
message(STATUS "Aliasing cpuinfo::cpuinfo to cpuinfo")
|
||||
add_library(cpuinfo ALIAS cpuinfo::cpuinfo)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if (onnxruntime_BUILD_BENCHMARKS)
|
||||
onnxruntime_fetchcontent_makeavailable(google_benchmark)
|
||||
endif()
|
||||
|
||||
if (NOT WIN32)
|
||||
#nsync tests failed on Mac Build
|
||||
set(NSYNC_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
|
||||
onnxruntime_fetchcontent_makeavailable(google_nsync)
|
||||
if (google_nsync_SOURCE_DIR)
|
||||
add_library(nsync::nsync_cpp ALIAS nsync_cpp)
|
||||
target_include_directories(nsync_cpp PUBLIC ${google_nsync_SOURCE_DIR}/public)
|
||||
# xnnpack depends on clog
|
||||
# Android build should use the system's log library instead of clog
|
||||
if ((CPUINFO_SUPPORTED OR onnxruntime_USE_XNNPACK) AND NOT ANDROID)
|
||||
set(CLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(
|
||||
pytorch_clog
|
||||
URL ${DEP_URL_pytorch_cpuinfo}
|
||||
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
|
||||
SOURCE_SUBDIR deps/clog
|
||||
FIND_PACKAGE_ARGS NAMES cpuinfo
|
||||
)
|
||||
set(ONNXRUNTIME_CLOG_PROJ pytorch_clog)
|
||||
onnxruntime_fetchcontent_makeavailable(${ONNXRUNTIME_CLOG_PROJ})
|
||||
set(ONNXRUNTIME_CLOG_TARGET_NAME clog)
|
||||
# if cpuinfo is from find_package, use it with imported name
|
||||
if(TARGET cpuinfo::clog)
|
||||
set(ONNXRUNTIME_CLOG_TARGET_NAME cpuinfo::clog)
|
||||
elseif(onnxruntime_USE_VCPKG)
|
||||
# however, later cpuinfo versions may not contain clog. use cpuinfo
|
||||
set(ONNXRUNTIME_CLOG_TARGET_NAME cpuinfo::cpuinfo)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -383,21 +436,51 @@ else()
|
|||
FIND_PACKAGE_ARGS 4.0 NAMES Microsoft.GSL
|
||||
)
|
||||
endif()
|
||||
set(GSL_TARGET "Microsoft.GSL::GSL")
|
||||
set(GSL_INCLUDE_DIR "$<TARGET_PROPERTY:${GSL_TARGET},INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
onnxruntime_fetchcontent_makeavailable(GSL)
|
||||
|
||||
find_path(safeint_SOURCE_DIR NAMES "SafeInt.hpp")
|
||||
if(NOT safeint_SOURCE_DIR)
|
||||
unset(safeint_SOURCE_DIR)
|
||||
FetchContent_Declare(
|
||||
safeint
|
||||
URL ${DEP_URL_safeint}
|
||||
URL_HASH SHA1=${DEP_SHA1_safeint}
|
||||
)
|
||||
|
||||
# use fetch content rather than makeavailable because safeint only includes unconditional test targets
|
||||
FetchContent_Populate(safeint)
|
||||
endif()
|
||||
add_library(safeint_interface INTERFACE)
|
||||
target_include_directories(safeint_interface INTERFACE ${safeint_SOURCE_DIR})
|
||||
|
||||
|
||||
# Flatbuffers
|
||||
# We do not need to build flatc for iOS or Android Cross Compile
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATC" FORCE)
|
||||
endif()
|
||||
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "FLATBUFFERS_BUILD_TESTS" FORCE)
|
||||
set(FLATBUFFERS_INSTALL OFF CACHE BOOL "FLATBUFFERS_INSTALL" FORCE)
|
||||
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATHASH" FORCE)
|
||||
set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "FLATBUFFERS_BUILD_FLATLIB" FORCE)
|
||||
if(Patch_FOUND)
|
||||
set(ONNXRUNTIME_FLATBUFFERS_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/flatbuffers/flatbuffers.patch)
|
||||
else()
|
||||
set(ONNXRUNTIME_FLATBUFFERS_PATCH_COMMAND "")
|
||||
endif()
|
||||
|
||||
#flatbuffers 1.11.0 does not have flatbuffers::IsOutRange, therefore we require 1.12.0+
|
||||
FetchContent_Declare(
|
||||
safeint
|
||||
URL ${DEP_URL_safeint}
|
||||
URL_HASH SHA1=${DEP_SHA1_safeint}
|
||||
flatbuffers
|
||||
URL ${DEP_URL_flatbuffers}
|
||||
URL_HASH SHA1=${DEP_SHA1_flatbuffers}
|
||||
PATCH_COMMAND ${ONNXRUNTIME_FLATBUFFERS_PATCH_COMMAND}
|
||||
FIND_PACKAGE_ARGS 23.5.9 NAMES Flatbuffers flatbuffers
|
||||
)
|
||||
|
||||
# use fetch content rather than makeavailable because safeint only includes unconditional test targets
|
||||
FetchContent_Populate(safeint)
|
||||
# The next line will generate an error message "fatal: not a git repository", but it is ok. It is from flatbuffers
|
||||
onnxruntime_fetchcontent_makeavailable(utf8_range)
|
||||
# protobuf's cmake/utf8_range.cmake has the following line
|
||||
include_directories(${utf8_range_SOURCE_DIR})
|
||||
|
||||
onnxruntime_fetchcontent_makeavailable(Protobuf nlohmann_json mp11 re2 GSL flatbuffers ${ONNXRUNTIME_CPUINFO_PROJ} ${ONNXRUNTIME_CLOG_PROJ})
|
||||
onnxruntime_fetchcontent_makeavailable(flatbuffers)
|
||||
if(NOT flatbuffers_FOUND)
|
||||
if(NOT TARGET flatbuffers::flatbuffers)
|
||||
add_library(flatbuffers::flatbuffers ALIAS flatbuffers)
|
||||
|
|
@ -424,54 +507,6 @@ namespace std { using ::getenv; }
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if (onnxruntime_BUILD_UNIT_TESTS)
|
||||
onnxruntime_fetchcontent_makeavailable(googletest)
|
||||
endif()
|
||||
|
||||
if(Protobuf_FOUND)
|
||||
message("Protobuf version: ${Protobuf_VERSION}")
|
||||
else()
|
||||
# Adjust warning flags
|
||||
if (TARGET libprotoc)
|
||||
if (NOT MSVC)
|
||||
target_compile_options(libprotoc PRIVATE "-w")
|
||||
endif()
|
||||
endif()
|
||||
if (TARGET protoc)
|
||||
add_executable(protobuf::protoc ALIAS protoc)
|
||||
if (UNIX AND onnxruntime_ENABLE_LTO)
|
||||
#https://github.com/protocolbuffers/protobuf/issues/5923
|
||||
target_link_options(protoc PRIVATE "-Wl,--no-as-needed")
|
||||
endif()
|
||||
if (NOT MSVC)
|
||||
target_compile_options(protoc PRIVATE "-w")
|
||||
endif()
|
||||
get_target_property(PROTOC_OSX_ARCH protoc OSX_ARCHITECTURES)
|
||||
if (PROTOC_OSX_ARCH)
|
||||
if (${CMAKE_HOST_SYSTEM_PROCESSOR} IN_LIST PROTOC_OSX_ARCH)
|
||||
message("protoc can run")
|
||||
else()
|
||||
list(APPEND PROTOC_OSX_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
set_target_properties(protoc PROPERTIES OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
set_target_properties(libprotoc PROPERTIES OSX_ARCHITECTURES "${PROTOC_OSX_ARCH}")
|
||||
set_target_properties(libprotobuf PROPERTIES OSX_ARCHITECTURES "${PROTOC_OSX_ARCH}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (TARGET libprotobuf AND NOT MSVC)
|
||||
target_compile_options(libprotobuf PRIVATE "-w")
|
||||
endif()
|
||||
if (TARGET libprotobuf-lite AND NOT MSVC)
|
||||
target_compile_options(libprotobuf-lite PRIVATE "-w")
|
||||
endif()
|
||||
endif()
|
||||
if (onnxruntime_USE_FULL_PROTOBUF)
|
||||
set(PROTOBUF_LIB protobuf::libprotobuf)
|
||||
else()
|
||||
set(PROTOBUF_LIB protobuf::libprotobuf-lite)
|
||||
endif()
|
||||
|
||||
|
||||
# ONNX
|
||||
if (NOT onnxruntime_USE_FULL_PROTOBUF)
|
||||
set(ONNX_USE_LITE_PROTO ON CACHE BOOL "" FORCE)
|
||||
|
|
@ -490,27 +525,36 @@ FetchContent_Declare(
|
|||
URL ${DEP_URL_onnx}
|
||||
URL_HASH SHA1=${DEP_SHA1_onnx}
|
||||
PATCH_COMMAND ${ONNXRUNTIME_ONNX_PATCH_COMMAND}
|
||||
FIND_PACKAGE_ARGS NAMES ONNX onnx
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
include(eigen)
|
||||
include(wil)
|
||||
|
||||
if (NOT onnxruntime_MINIMAL_BUILD)
|
||||
onnxruntime_fetchcontent_makeavailable(onnx)
|
||||
onnxruntime_fetchcontent_makeavailable(onnx)
|
||||
else()
|
||||
include(onnx_minimal)
|
||||
endif()
|
||||
|
||||
set(GSL_TARGET "Microsoft.GSL::GSL")
|
||||
set(GSL_INCLUDE_DIR "$<TARGET_PROPERTY:${GSL_TARGET},INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
if(TARGET ONNX::onnx AND NOT TARGET onnx)
|
||||
message(STATUS "Aliasing ONNX::onnx to onnx")
|
||||
add_library(onnx ALIAS ONNX::onnx)
|
||||
endif()
|
||||
if(TARGET ONNX::onnx_proto AND NOT TARGET onnx_proto)
|
||||
message(STATUS "Aliasing ONNX::onnx_proto to onnx_proto")
|
||||
add_library(onnx_proto ALIAS ONNX::onnx_proto)
|
||||
endif()
|
||||
|
||||
add_library(safeint_interface INTERFACE)
|
||||
target_include_directories(safeint_interface INTERFACE ${safeint_SOURCE_DIR})
|
||||
find_package(Eigen3 CONFIG)
|
||||
if(Eigen3_FOUND)
|
||||
get_target_property(eigen_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
|
||||
else()
|
||||
include(eigen) # FetchContent
|
||||
endif()
|
||||
|
||||
if(onnxruntime_USE_VCPKG)
|
||||
find_package(wil CONFIG REQUIRED)
|
||||
set(WIL_TARGET "WIL::WIL")
|
||||
else()
|
||||
include(wil) # FetchContent
|
||||
endif()
|
||||
|
||||
# XNNPACK EP
|
||||
if (onnxruntime_USE_XNNPACK)
|
||||
|
|
@ -539,9 +583,11 @@ set(onnxruntime_EXTERNAL_LIBRARIES ${onnxruntime_EXTERNAL_LIBRARIES_XNNPACK} ${W
|
|||
# The other libs do not have the problem. All the sources are already there. We can compile them in any order.
|
||||
set(onnxruntime_EXTERNAL_DEPENDENCIES onnx_proto flatbuffers::flatbuffers)
|
||||
|
||||
target_compile_definitions(onnx PUBLIC $<TARGET_PROPERTY:onnx_proto,INTERFACE_COMPILE_DEFINITIONS> PRIVATE "__ONNX_DISABLE_STATIC_REGISTRATION")
|
||||
if (NOT onnxruntime_USE_FULL_PROTOBUF)
|
||||
target_compile_definitions(onnx PUBLIC "__ONNX_NO_DOC_STRINGS")
|
||||
if(NOT (onnx_FOUND OR ONNX_FOUND)) # building ONNX from source
|
||||
target_compile_definitions(onnx PUBLIC $<TARGET_PROPERTY:onnx_proto,INTERFACE_COMPILE_DEFINITIONS> PRIVATE "__ONNX_DISABLE_STATIC_REGISTRATION")
|
||||
if (NOT onnxruntime_USE_FULL_PROTOBUF)
|
||||
target_compile_definitions(onnx PUBLIC "__ONNX_NO_DOC_STRINGS")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (onnxruntime_RUN_ONNX_TESTS)
|
||||
|
|
@ -550,11 +596,12 @@ endif()
|
|||
|
||||
|
||||
if(onnxruntime_ENABLE_ATEN)
|
||||
message("Aten fallback is enabled.")
|
||||
message(STATUS "Aten fallback is enabled.")
|
||||
FetchContent_Declare(
|
||||
dlpack
|
||||
URL ${DEP_URL_dlpack}
|
||||
URL_HASH SHA1=${DEP_SHA1_dlpack}
|
||||
FIND_PACKAGE_ARGS NAMES dlpack
|
||||
)
|
||||
# We can't use onnxruntime_fetchcontent_makeavailable since some part of the the dlpack code is Linux only.
|
||||
# For example, dlpackcpp.h uses posix_memalign.
|
||||
|
|
@ -568,6 +615,7 @@ if(onnxruntime_ENABLE_TRAINING OR (onnxruntime_ENABLE_TRAINING_APIS AND onnxrunt
|
|||
cxxopts
|
||||
URL ${DEP_URL_cxxopts}
|
||||
URL_HASH SHA1=${DEP_SHA1_cxxopts}
|
||||
FIND_PACKAGE_ARGS NAMES cxxopts
|
||||
)
|
||||
set(CXXOPTS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(CXXOPTS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
|
|
@ -585,7 +633,7 @@ if (onnxruntime_USE_COREML)
|
|||
FetchContent_Populate(coremltools)
|
||||
endif()
|
||||
|
||||
message("Finished fetching external dependencies")
|
||||
message(STATUS "Finished fetching external dependencies")
|
||||
|
||||
set(onnxruntime_LINK_DIRS )
|
||||
|
||||
|
|
|
|||
|
|
@ -332,6 +332,9 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
|||
# If it's an onnxruntime library, extract .o files from the original cmake build path to a separate directory for
|
||||
# each library to avoid any clashes with filenames (e.g. utils.o)
|
||||
foreach(_LIB ${onnxruntime_INTERNAL_LIBRARIES} )
|
||||
if(NOT TARGET ${_LIB}) # if we didn't build from source. it may not a target
|
||||
continue()
|
||||
endif()
|
||||
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
|
||||
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
|
||||
set(CUR_STATIC_LIB_OBJ_DIR ${STATIC_LIB_TEMP_DIR}/$<TARGET_LINKER_FILE_BASE_NAME:${_LIB}>)
|
||||
|
|
@ -362,6 +365,9 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
|||
|
||||
# for external libraries we create a symlink to the .a file
|
||||
foreach(_LIB ${onnxruntime_EXTERNAL_LIBRARIES})
|
||||
if(NOT TARGET ${_LIB}) # if we didn't build from source. it may not a target
|
||||
continue()
|
||||
endif()
|
||||
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
|
||||
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
|
||||
add_custom_command(TARGET onnxruntime POST_BUILD
|
||||
|
|
|
|||
|
|
@ -877,6 +877,7 @@ AddTest(
|
|||
DEPENDS ${all_dependencies}
|
||||
TEST_ARGS ${test_all_args}
|
||||
)
|
||||
target_include_directories(onnxruntime_test_all PRIVATE ${ONNXRUNTIME_ROOT}/core/flatbuffers/schema) # ort.fbs.h
|
||||
|
||||
if (MSVC)
|
||||
# The warning means the type of two integral values around a binary operator is narrow than their result.
|
||||
|
|
@ -982,6 +983,9 @@ target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
|
|||
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto)
|
||||
target_include_directories(onnx_test_data_proto PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set_target_properties(onnx_test_data_proto PROPERTIES FOLDER "ONNXRuntimeTest")
|
||||
if(NOT DEFINED onnx_SOURCE_DIR)
|
||||
find_path(onnx_SOURCE_DIR NAMES "onnx/onnx-ml.proto3" "onnx/onnx-ml.proto" REQUIRED)
|
||||
endif()
|
||||
onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${onnx_SOURCE_DIR} TARGET onnx_test_data_proto)
|
||||
|
||||
#
|
||||
|
|
|
|||
8
cmake/vcpkg-configuration.json
Normal file
8
cmake/vcpkg-configuration.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"default-registry": {
|
||||
"kind": "git",
|
||||
"repository": "https://github.com/Microsoft/vcpkg",
|
||||
"baseline": "3508985146f1b1d248c67ead13f8f54be5b4f5da"
|
||||
},
|
||||
"registries": []
|
||||
}
|
||||
78
cmake/vcpkg.json
Normal file
78
cmake/vcpkg.json
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
|
||||
"name": "onnxruntime",
|
||||
"version-date": "2024-09-10",
|
||||
"description": "ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator",
|
||||
"homepage": "https://onnxruntime.ai/",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
"abseil",
|
||||
{
|
||||
"name": "boost-config",
|
||||
"version>=": "1.82.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-mp11",
|
||||
"version>=": "1.82.0"
|
||||
},
|
||||
"cpuinfo",
|
||||
"cxxopts",
|
||||
"date",
|
||||
"dlpack",
|
||||
{
|
||||
"name": "flatbuffers",
|
||||
"host": true,
|
||||
"version>=": "23.5.26"
|
||||
},
|
||||
{
|
||||
"name": "flatbuffers",
|
||||
"version>=": "23.5.26"
|
||||
},
|
||||
"ms-gsl",
|
||||
"nlohmann-json",
|
||||
{
|
||||
"name": "nsync",
|
||||
"platform": "!windows"
|
||||
},
|
||||
{
|
||||
"name": "nsync",
|
||||
"platform": "!windows",
|
||||
"version>=": "1.26.0"
|
||||
},
|
||||
"optional-lite",
|
||||
{
|
||||
"name": "protobuf",
|
||||
"version>=": "3.21.12"
|
||||
},
|
||||
{
|
||||
"name": "protobuf",
|
||||
"host": true,
|
||||
"version>=": "3.21.12"
|
||||
},
|
||||
"re2",
|
||||
"safeint",
|
||||
"utf8-range",
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
},
|
||||
"wil",
|
||||
{
|
||||
"name": "zlib",
|
||||
"platform": "windows"
|
||||
}
|
||||
],
|
||||
"features": {
|
||||
"tests": {
|
||||
"description": "Build ONNXRuntime unit tests",
|
||||
"dependencies": [
|
||||
"benchmark",
|
||||
"gtest"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,12 +46,8 @@ Status KernelTypeStrResolver::ResolveKernelTypeStr(const Node& node, std::string
|
|||
ORT_RETURN_IF(op_it == op_kernel_type_str_map_.end(), "Failed to find op_id: ", op_id);
|
||||
const auto& type_str_map = op_it->second;
|
||||
|
||||
#ifdef DISABLE_ABSEIL
|
||||
// TODO(edgchen1) maybe we can use transparent hash/eq to enable lookup with string_view
|
||||
const auto type_str_it = type_str_map.find(std::string(kernel_type_str));
|
||||
#else
|
||||
const auto type_str_it = type_str_map.find(kernel_type_str);
|
||||
#endif
|
||||
|
||||
ORT_RETURN_IF(type_str_it == type_str_map.end(),
|
||||
"Failed to find args for kernel type string '", kernel_type_str,
|
||||
|
|
|
|||
|
|
@ -33,11 +33,7 @@ class OrtValueNameIdxMap {
|
|||
common::Status GetIdx(std::string_view name, int& idx) const {
|
||||
idx = -1;
|
||||
|
||||
#ifdef DISABLE_ABSEIL
|
||||
auto it = map_.find(std::string(name));
|
||||
#else
|
||||
auto it = map_.find(name);
|
||||
#endif
|
||||
if (it == map_.end()) {
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Could not find OrtValue with name '", name, "'");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -460,6 +460,12 @@ def parse_arguments():
|
|||
action="store_true",
|
||||
help="Disable memory leak checker from Windows build. By default it is enabled in Windows Debug build. This option is Windows only.",
|
||||
)
|
||||
# Dependency search with vcpkg
|
||||
parser.add_argument(
|
||||
"--use_vcpkg",
|
||||
action="store_true",
|
||||
help="Use vcpkg to search dependencies. Requires CMAKE_TOOLCHAIN_FILE for vcpkg.cmake",
|
||||
)
|
||||
|
||||
# WebAssembly build
|
||||
parser.add_argument("--build_wasm", action="store_true", help="Build for WebAssembly")
|
||||
|
|
@ -999,6 +1005,7 @@ def generate_build_tree(
|
|||
# of them to get the best compatibility.
|
||||
"-DPython_EXECUTABLE=" + sys.executable,
|
||||
"-DPYTHON_EXECUTABLE=" + sys.executable,
|
||||
"-Donnxruntime_USE_VCPKG=" + ("ON" if args.use_vcpkg else "OFF"),
|
||||
"-Donnxruntime_USE_MIMALLOC=" + ("ON" if args.use_mimalloc else "OFF"),
|
||||
"-Donnxruntime_ENABLE_PYTHON=" + ("ON" if args.enable_pybind else "OFF"),
|
||||
"-Donnxruntime_BUILD_CSHARP=" + ("ON" if args.build_csharp else "OFF"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue