onnxruntime/.github/workflows
PARK DongHa f633caa0b1
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
2024-09-10 16:39:27 -07:00
..
cffconvert.yml Bump actions/checkout from 3 to 4 (#17487) 2023-09-13 09:22:21 -07:00
codeql.yml Use Java 11 to build project in the codeql pipeline (#19999) 2024-03-20 17:53:48 -07:00
generate-skip-doc-change.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
gradle-wrapper-validation.yml Bump gradle/wrapper-validation-action from 2 to 3 (#20305) 2024-04-16 14:20:51 -07:00
labeler.yml Update labeler.yml to change permissions (#19709) 2024-02-28 21:10:25 -08:00
lint.yml Allow cpplint to always be green (#21491) 2024-07-25 15:57:30 -07:00
mac.yml Create CMake option onnxruntime_USE_VCPKG (#21348) 2024-09-10 16:39:27 -07:00
publish-c-apidocs.yml Decrease API docs artifact retention days (#22003) 2024-09-10 10:44:08 -07:00
publish-csharp-apidocs.yml Decrease API docs artifact retention days (#22003) 2024-09-10 10:44:08 -07:00
publish-gh-pages.yml Add website publish placeholder (#17318) 2023-08-30 11:01:54 -07:00
publish-java-apidocs.yml Decrease API docs artifact retention days (#22003) 2024-09-10 10:44:08 -07:00
publish-js-apidocs.yml Decrease API docs artifact retention days (#22003) 2024-09-10 10:44:08 -07:00
publish-objectivec-apidocs.yml Decrease API docs artifact retention days (#22003) 2024-09-10 10:44:08 -07:00
publish-python-apidocs.yml Decrease API docs artifact retention days (#22003) 2024-09-10 10:44:08 -07:00
sca.yml Fix a perm issue in Windows Static Analysis pipeline (#21100) 2024-06-19 14:44:39 -07:00
skip-doc-change.yml.j2 Update Win_GPU_CI trigger (#13290) 2022-10-12 15:22:42 +08:00
stale.yml Update stale.yml to use old version as a bug fix (#19532) 2024-02-15 17:03:11 -08:00
title-only-labeler.yml Update labeling bot (#21548) 2024-07-29 16:06:03 -07:00
windows.yml Create CMake option onnxruntime_USE_VCPKG (#21348) 2024-09-10 16:39:27 -07:00