Skip to content

Commit 49328fe

Browse files
authored
Allow using a different version of flatbuffers when building with vcpkg (#23946)
### Description Allow using a different version of flatbuffers when building with vcpkg, so that users do not need to pin flatbuffer's version, which provides more flexibility in the build process. Delete utf8_range from the dependencies, because it is an indirect dependency of protobuf, which is already included in the build process. ### Motivation and Context
1 parent cffef2e commit 49328fe

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

cmake/deps.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ re2;https://github.com/google/re2/archive/refs/tags/2024-07-02.zip;646e1728269cd
5353
safeint;https://github.com/dcleblanc/SafeInt/archive/refs/tags/3.0.28.zip;23f252040ff6cb9f1fd18575b32fa8fb5928daac
5454
tensorboard;https://github.com/tensorflow/tensorboard/archive/373eb09e4c5d2b3cc2493f0949dc4be6b6a45e81.zip;67b833913605a4f3f499894ab11528a702c2b381
5555
cutlass;https://github.com/NVIDIA/cutlass/archive/refs/tags/v3.5.1.zip;e49b2b964163d27765a5002d210a2f3c73771835
56-
utf8_range;https://github.com/protocolbuffers/utf8_range/archive/72c943dea2b9240cd09efde15191e144bc7c7d38.zip;9925739c9debc0efa2adcb194d371a35b6a03156
5756
extensions;https://github.com/microsoft/onnxruntime-extensions/archive/c24b7bab0c12f53da76d0c31b03b9f0f8ec8f3b4.zip;239063aee4946a9af147b473a4c3da78ba7413b4
5857
composable_kernel;https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/204da9c522cebec5220bba52cd3542ebcaf99e7a.zip;1827348efd47831c13074245274d41b7cae8a557
5958
directx_headers;https://github.com/microsoft/DirectX-Headers/archive/refs/tags/v1.613.1.zip;47653509a3371eabb156360f42faf582f314bf2e

cmake/external/onnxruntime_external_deps.cmake

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,6 @@ if(onnxruntime_USE_MIMALLOC)
107107
FetchContent_MakeAvailable(mimalloc)
108108
endif()
109109

110-
#Protobuf depends on utf8_range
111-
onnxruntime_fetchcontent_declare(
112-
utf8_range
113-
URL ${DEP_URL_utf8_range}
114-
URL_HASH SHA1=${DEP_SHA1_utf8_range}
115-
EXCLUDE_FROM_ALL
116-
FIND_PACKAGE_ARGS NAMES utf8_range
117-
)
118-
119-
set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Build test suite" FORCE)
120-
set(utf8_range_ENABLE_INSTALL OFF CACHE BOOL "Configure installation" FORCE)
121-
122-
# The next line will generate an error message "fatal: not a git repository", but it is ok. It is from flatbuffers
123-
onnxruntime_fetchcontent_makeavailable(utf8_range)
124-
# protobuf's cmake/utf8_range.cmake has the following line
125-
include_directories(${utf8_range_SOURCE_DIR})
126-
127110
# Download a protoc binary from Internet if needed
128111
if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE AND NOT onnxruntime_USE_VCPKG)
129112
# This part of code is only for users' convenience. The code couldn't handle all cases. Users always can manually
@@ -442,6 +425,9 @@ target_include_directories(safeint_interface INTERFACE ${safeint_SOURCE_DIR})
442425

443426

444427
# Flatbuffers
428+
if(onnxruntime_USE_VCPKG)
429+
find_package(flatbuffers REQUIRED)
430+
else()
445431
# We do not need to build flatc for iOS or Android Cross Compile
446432
if (CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
447433
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATC" FORCE)
@@ -492,6 +478,7 @@ namespace std { using ::getenv; }
492478
endif()
493479
endif()
494480
endif()
481+
endif()
495482

496483
# ONNX
497484
if (NOT onnxruntime_USE_FULL_PROTOBUF)

0 commit comments

Comments
 (0)