Skip to content

Commit

Permalink
[onnx] Use _PROTOBUF_INSTALL_PREFIX from portfile.cmake for `find_…
Browse files Browse the repository at this point in the history
…package(Protobuf)` (#238)

* [onnx] fixing protobuf search
* [onnx] use _PROTOBUF_INSTALL_PREFIX
  • Loading branch information
luncliff authored Sep 1, 2024
1 parent 61a5345 commit b0eb603
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
34 changes: 34 additions & 0 deletions ports/onnx/fix-cmake-protobuf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a815ac1..bdc787f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -151,10 +151,10 @@ else()
# to resolve PREFIX.
if(Protobuf_PROTOC_EXECUTABLE)
set(ONNX_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
- get_filename_component(_PROTOBUF_INSTALL_PREFIX
- ${Protobuf_PROTOC_EXECUTABLE} DIRECTORY)
- get_filename_component(_PROTOBUF_INSTALL_PREFIX
- ${_PROTOBUF_INSTALL_PREFIX}/.. REALPATH)
+ if(NOT DEFINED _PROTOBUF_INSTALL_PREFIX)
+ get_filename_component(_PROTOBUF_INSTALL_PREFIX ${Protobuf_PROTOC_EXECUTABLE} DIRECTORY)
+ get_filename_component(_PROTOBUF_INSTALL_PREFIX ${_PROTOBUF_INSTALL_PREFIX}/.. REALPATH)
+ endif()
find_library(Protobuf_PROTOC_LIBRARY
NAMES protoc
PATHS ${_PROTOBUF_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
@@ -173,12 +173,12 @@ else()
find_path(Protobuf_INCLUDE_DIR google/protobuf/service.h
PATHS ${_PROTOBUF_INSTALL_PREFIX}/include
NO_DEFAULT_PATH)
- find_package(Protobuf)
+ find_package(Protobuf REQUIRED)
if (Protobuf_FOUND)
set(PROTOBUF_DIR "${_PROTOBUF_INSTALL_PREFIX}")
set(PROTOBUF_INCLUDE_DIR "${_PROTOBUF_INSTALL_PREFIX}/include")
set(Build_Protobuf OFF)
- if ("${Protobuf_VERSION}" VERSION_GREATER_EQUAL "4.22.0")
+ if (FALSE)
# There are extra dependencies for protobuf.
find_package(absl REQUIRED)
find_package(utf8_range REQUIRED)
9 changes: 6 additions & 3 deletions ports/onnx/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vcpkg_from_github(
SHA512 7a9a8493b9c007429629484156487395044506f34e72253640e626351cb623b390750b36af78a290786131e3dcac35f4eb269e8693b594b7ce7cb105bcf9318d
PATCHES
fix-cmake.patch
fix-cmake-protobuf.patch
support-test.patch
)

Expand Down Expand Up @@ -43,9 +44,10 @@ vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON3}
-DProtobuf_PROTOC_EXECUTABLE=${PROTOC}
-DONNX_CUSTOM_PROTOC_EXECUTABLE=${PROTOC}
"-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON3}"
"-D_PROTOBUF_INSTALL_PREFIX=${CURRENT_INSTALLED_DIR}"
"-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}"
"-DONNX_CUSTOM_PROTOC_EXECUTABLE=${PROTOC}"
-DONNX_VERIFY_PROTO3=ON # --protoc_path for gen_proto.py
-DONNX_ML=ON
-DONNX_GEN_PB_TYPE_STUBS=ON
Expand All @@ -54,6 +56,7 @@ vcpkg_cmake_configure(
MAYBE_UNUSED_VARIABLES
ONNX_USE_MSVC_STATIC_RUNTIME
ONNX_CUSTOM_PROTOC_EXECUTABLE
PROTOBUF_SEARCH_DIRS
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX PACKAGE_NAME ONNX)
Expand Down
1 change: 1 addition & 0 deletions ports/onnx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "onnx",
"version-semver": "1.16.2",
"port-version": 1,
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
},
"onnx": {
"baseline": "1.16.2",
"port-version": 0
"port-version": 1
},
"onnxruntime": {
"baseline": "1.18.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/o-/onnx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "801e9d2fecd40f26b85b845c940a342510b83713",
"version-semver": "1.16.2",
"port-version": 1
},
{
"git-tree": "39cd4efb2f7e3c014a8a8657aa266bf9d10f7a89",
"version-semver": "1.16.2",
Expand Down

0 comments on commit b0eb603

Please sign in to comment.