aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/onnx-optimizer
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/onnx-optimizer
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/onnx-optimizer')
-rw-r--r--vcpkg/ports/onnx-optimizer/fix-cmakelists.patch68
-rw-r--r--vcpkg/ports/onnx-optimizer/portfile.cmake30
-rw-r--r--vcpkg/ports/onnx-optimizer/vcpkg.json19
3 files changed, 117 insertions, 0 deletions
diff --git a/vcpkg/ports/onnx-optimizer/fix-cmakelists.patch b/vcpkg/ports/onnx-optimizer/fix-cmakelists.patch
new file mode 100644
index 0000000..d98ed10
--- /dev/null
+++ b/vcpkg/ports/onnx-optimizer/fix-cmakelists.patch
@@ -0,0 +1,68 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 0063385..f1522bc 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -10,6 +10,15 @@ project(onnx_optimizer C CXX)
+
+ set(CMAKE_CXX_STANDARD 17)
+
++# Add MSVC RunTime Flag
++function(add_msvc_runtime_flag lib)
++ if(${ONNX_USE_MSVC_STATIC_RUNTIME})
++ target_compile_options(${lib} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/MT> $<$<CONFIG:Debug>:/MTd>)
++ else()
++ target_compile_options(${lib} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/MD> $<$<CONFIG:Debug>:/MDd>)
++ endif()
++endfunction()
++
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+ include(cmake/utils.cmake)
+@@ -23,12 +32,10 @@ option(ONNX_OPT_USE_SYSTEM_PROTOBUF "" OFF)
+ if(NOT ONNX_OPT_USE_SYSTEM_PROTOBUF)
+ option(protobuf_BUILD_TESTS "" OFF)
+ option(protobuf_MSVC_STATIC_RUNTIME "" ${ONNX_USE_MSVC_STATIC_RUNTIME})
+- add_subdirectory_if_no_target(${PROJECT_SOURCE_DIR}/third_party/protobuf/cmake libprotobuf)
+ endif()
+
+-
+-set(ONNX_ROOT ${PROJECT_SOURCE_DIR}/third_party/onnx)
+-add_subdirectory_if_no_target(${ONNX_ROOT} ${ONNX_TARGET_NAME})
++find_package(protobuf CONFIG REQUIRED)
++find_package(ONNX CONFIG REQUIRED)
+
+ file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" ONNX_OPTIMIZER_VERSION)
+ string(STRIP "${ONNX_OPTIMIZER_VERSION}" ONNX_OPTIMIZER_VERSION)
+@@ -41,7 +48,7 @@ file(GLOB onnx_opt_srcs "onnxoptimizer/*.cc"
+ list(REMOVE_ITEM onnx_opt_srcs "${PROJECT_SOURCE_DIR}/onnxoptimizer/cpp2py_export.cc")
+
+ onnxopt_add_library(onnx_optimizer ${onnx_opt_srcs})
+-target_link_libraries(onnx_optimizer PUBLIC ${ONNX_TARGET_NAME})
++target_link_libraries(onnx_optimizer PUBLIC ONNX::onnx ONNX::onnx_proto)
+ target_include_directories(onnx_optimizer PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
+diff --git a/cmake/utils.cmake b/cmake/utils.cmake
+index 6cca9f3..9d79f1a 100644
+--- a/cmake/utils.cmake
++++ b/cmake/utils.cmake
+@@ -1,5 +1,3 @@
+-include(${PROJECT_SOURCE_DIR}/third_party/onnx/cmake/Utils.cmake)
+-
+ # Poor man's FetchContent
+ function(add_subdirectory_if_no_target dir target)
+ if (NOT TARGET ${target})
+diff --git a/cmake/ONNXOptimizerConfig.cmake.in b/cmake/ONNXOptimizerConfig.cmake.in
+index 72dcc88..c5639c8 100644
+--- a/cmake/ONNXOptimizerConfig.cmake.in
++++ b/cmake/ONNXOptimizerConfig.cmake.in
+@@ -3,6 +3,9 @@
+ # ONNX_OPTIMIZER_INCLUDE_DIRS - include directories for onnx optimizer
+ # as well as ONNX Optimizer targets for other cmake libraries to use.
+
++include(CMakeFindDependencyMacro)
++find_dependency(protobuf CONFIG)
++find_dependency(ONNX CONFIG)
+ # library version information
+ set(ONNX_OPTIMIZER_VERSION "@ONNX_OPTIMIZER_VERSION@")
+
diff --git a/vcpkg/ports/onnx-optimizer/portfile.cmake b/vcpkg/ports/onnx-optimizer/portfile.cmake
new file mode 100644
index 0000000..ce07fb3
--- /dev/null
+++ b/vcpkg/ports/onnx-optimizer/portfile.cmake
@@ -0,0 +1,30 @@
+vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO onnx/optimizer
+ REF "v${VERSION}"
+ SHA512 552d6fa261c3ce2db2e0938a5b5261676335bce9bd828b46a1e2631f3b362c748ae9a6cfe7d62072fc3774b3f506bc54aa5827b52241e6f48d78a08dea1d9316
+ HEAD_REF master
+ PATCHES
+ fix-cmakelists.patch
+)
+
+string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)
+
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ ${FEATURE_OPTIONS}
+ -DONNX_OPT_USE_SYSTEM_PROTOBUF=ON
+ -DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME}
+)
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(PACKAGE_NAME ONNXOptimizer CONFIG_PATH lib/cmake/ONNXOptimizer)
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include"
+ "${CURRENT_PACKAGES_DIR}/debug/share"
+ "${CURRENT_PACKAGES_DIR}/include/onnxoptimizer/test"
+)
diff --git a/vcpkg/ports/onnx-optimizer/vcpkg.json b/vcpkg/ports/onnx-optimizer/vcpkg.json
new file mode 100644
index 0000000..33eeb61
--- /dev/null
+++ b/vcpkg/ports/onnx-optimizer/vcpkg.json
@@ -0,0 +1,19 @@
+{
+ "name": "onnx-optimizer",
+ "version-semver": "0.3.19",
+ "port-version": 1,
+ "description": "Actively maintained ONNX Optimizer",
+ "homepage": "https://github.com/onnx/optimizer",
+ "license": "Apache-2.0",
+ "dependencies": [
+ "onnx",
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}