diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/onnx | |
Diffstat (limited to 'vcpkg/ports/onnx')
| -rw-r--r-- | vcpkg/ports/onnx/fix-cmakelists.patch | 31 | ||||
| -rw-r--r-- | vcpkg/ports/onnx/fix-cxx_standard.patch | 12 | ||||
| -rw-r--r-- | vcpkg/ports/onnx/fix-dependency-protobuf.patch | 28 | ||||
| -rw-r--r-- | vcpkg/ports/onnx/portfile.cmake | 82 | ||||
| -rw-r--r-- | vcpkg/ports/onnx/vcpkg.json | 23 |
5 files changed, 176 insertions, 0 deletions
diff --git a/vcpkg/ports/onnx/fix-cmakelists.patch b/vcpkg/ports/onnx/fix-cmakelists.patch new file mode 100644 index 0000000..2f5e79c --- /dev/null +++ b/vcpkg/ports/onnx/fix-cmakelists.patch @@ -0,0 +1,31 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b666eec..66c234d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,6 +63,16 @@ endif() + + include(GNUInstallDirs) + ++# install protobuf files ++install(FILES ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-data.proto ++ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-data.proto3 ++ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-ml.proto ++ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-ml.proto3 ++ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-operators-ml.proto ++ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-operators-ml.proto3 ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx ++) ++ + set(ONNX_ROOT ${PROJECT_SOURCE_DIR}) + + # Read ONNX version +@@ -104,7 +114,8 @@ endif() + # find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12 + # Use the following command in the future; now this is only compatible with the latest pybind11 + # find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED) +-find_package(PythonInterp ${PY_VERSION} REQUIRED) ++find_package(Python3 ${PY_VERSION} COMPONENTS Interpreter REQUIRED) ++set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + if(BUILD_ONNX_PYTHON) + find_package(PythonLibs ${PY_VERSION}) + endif() diff --git a/vcpkg/ports/onnx/fix-cxx_standard.patch b/vcpkg/ports/onnx/fix-cxx_standard.patch new file mode 100644 index 0000000..4f9f106 --- /dev/null +++ b/vcpkg/ports/onnx/fix-cxx_standard.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 55869f4..e8b20cb 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -524,6 +524,7 @@ else() + set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1) + endif() + target_compile_definitions(onnx_proto PRIVATE ${ONNX_API_DEFINE}) ++target_compile_features(onnx_proto PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) + + if(ONNX_USE_LITE_PROTO) + if(TARGET protobuf::libprotobuf-lite) diff --git a/vcpkg/ports/onnx/fix-dependency-protobuf.patch b/vcpkg/ports/onnx/fix-dependency-protobuf.patch new file mode 100644 index 0000000..28960b4 --- /dev/null +++ b/vcpkg/ports/onnx/fix-dependency-protobuf.patch @@ -0,0 +1,28 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d81ac1d..9f97998 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -149,6 +149,7 @@ if(ONNX_BUILD_TESTS) + set(googletest_STATIC_LIBRARIES GTest::gtest) + endif() + ++find_package(Protobuf CONFIG REQUIRED) + if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf)) + # Sometimes we need to use protoc compiled for host architecture while linking + # libprotobuf against target architecture. See https://github.com/caffe2/caffe +diff --git a/cmake/ONNXConfig.cmake.in b/cmake/ONNXConfig.cmake.in +index d588f8a..dbd4398 100644 +--- a/cmake/ONNXConfig.cmake.in ++++ b/cmake/ONNXConfig.cmake.in +@@ -6,9 +6,8 @@ + # library version information + set(ONNX_VERSION "@ONNX_VERSION@") + +-list(APPEND CMAKE_PREFIX_PATH "@PROTOBUF_DIR@") +-set(Protobuf_INCLUDE_DIR "@PROTOBUF_INCLUDE_DIR@") +-find_package(Protobuf REQUIRED) ++include(CMakeFindDependencyMacro) ++find_dependency(Protobuf CONFIG) + + # import targets + include ("${CMAKE_CURRENT_LIST_DIR}/ONNXTargets.cmake") diff --git a/vcpkg/ports/onnx/portfile.cmake b/vcpkg/ports/onnx/portfile.cmake new file mode 100644 index 0000000..f741ca0 --- /dev/null +++ b/vcpkg/ports/onnx/portfile.cmake @@ -0,0 +1,82 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO onnx/onnx + REF "v${VERSION}" + SHA512 5a18e2b19ec9c18c8b115fb7e12ed98eddaa581c95f15c4dd420cd6c86e7caa04f9a393da589e76b89cf9b3544abd3749a8c77c2446782f37502eb74e9b1f661 + PATCHES + fix-cmakelists.patch + fix-dependency-protobuf.patch + fix-cxx_standard.patch +) + +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME) + +# ONNX_CUSTOM_PROTOC_EXECUTABLE +find_program(PROTOC NAMES protoc PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf" REQUIRED NO_DEFAULT_PATH NO_CMAKE_PATH) + +# ONNX_USE_PROTOBUF_SHARED_LIBS: find the library and check its file extension +find_library(PROTOBUF_LIBPATH NAMES protobuf PATHS "${CURRENT_INSTALLED_DIR}/bin" "${CURRENT_INSTALLED_DIR}/lib" REQUIRED) +get_filename_component(PROTOBUF_LIBNAME "${PROTOBUF_LIBPATH}" NAME) +if(PROTOBUF_LIBNAME MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(USE_PROTOBUF_SHARED ON) +else() + set(USE_PROTOBUF_SHARED OFF) +endif() + +vcpkg_find_acquire_program(PYTHON3) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + "-DPython3_EXECUTABLE:FILEPATH=${PYTHON3}" + "-DONNX_CUSTOM_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}" + "-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}" + -DONNX_ML=ON + -DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED} + -DONNX_USE_LITE_PROTO=OFF + -DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME} + -DONNX_BUILD_TESTS=OFF + -DONNX_BUILD_BENCHMARKS=OFF + MAYBE_UNUSED_VARIABLES + ONNX_USE_MSVC_STATIC_RUNTIME +) +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX PACKAGE_NAME ONNX) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + # the others are empty + "${CURRENT_PACKAGES_DIR}/include/onnx/backend" + "${CURRENT_PACKAGES_DIR}/include/onnx/bin" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/controlflow" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/generator" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/image" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/logical" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/math" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/nn" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/object_detection" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/optional" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/quantization" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/reduction" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/rnn" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/sequence" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/text" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/traditionalml" + "${CURRENT_PACKAGES_DIR}/include/onnx/defs/training" + "${CURRENT_PACKAGES_DIR}/include/onnx/examples" + "${CURRENT_PACKAGES_DIR}/include/onnx/frontend" + "${CURRENT_PACKAGES_DIR}/include/onnx/onnx_cpp2py_export" + "${CURRENT_PACKAGES_DIR}/include/onnx/test" + "${CURRENT_PACKAGES_DIR}/include/onnx/tools" + "${CURRENT_PACKAGES_DIR}/include/onnx/onnx_ml" + "${CURRENT_PACKAGES_DIR}/include/onnx/onnx_data" + "${CURRENT_PACKAGES_DIR}/include/onnx/onnx_operators_ml" + "${CURRENT_PACKAGES_DIR}/include/onnx/reference/ops" + "${CURRENT_PACKAGES_DIR}/include/onnx/reference" +) diff --git a/vcpkg/ports/onnx/vcpkg.json b/vcpkg/ports/onnx/vcpkg.json new file mode 100644 index 0000000..c4e43a7 --- /dev/null +++ b/vcpkg/ports/onnx/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "onnx", + "version-semver": "1.17.0", + "port-version": 2, + "description": "Open standard for machine learning interoperability", + "homepage": "https://onnx.ai", + "license": "Apache-2.0", + "dependencies": [ + "protobuf", + { + "name": "protobuf", + "host": true + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} |