diff options
| author | Park DongHa <dong-ha-park@linecorp.com> | 2021-09-17 08:19:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-16 16:19:50 -0700 |
| commit | 2aa021c307b9edb024b92efb17d8aa58133a73c4 (patch) | |
| tree | 95a1b553d1af52bacffe7dc9ec8375e171e6e684 | |
| parent | c26101d71e1e3f8a8a010bf6854c983ab777b9e9 (diff) | |
| download | vcpkg-2aa021c307b9edb024b92efb17d8aa58133a73c4.tar.gz vcpkg-2aa021c307b9edb024b92efb17d8aa58133a73c4.zip | |
[onnx-optimizer] create a new port (#19258)
* [onnx-optimizer] create a new port
* migrate changes to new branch
* [onnx-optimizer] specify maybe unused
* ONNX_USE_PROTOBUF_SHARED_LIBS is for Windows
* [onnx-optimizer] update baseline
* [onnx-optimizer] make protobuf option constant
| -rw-r--r-- | ports/onnx-optimizer/fix-cmakelists.patch | 56 | ||||
| -rw-r--r-- | ports/onnx-optimizer/portfile.cmake | 43 | ||||
| -rw-r--r-- | ports/onnx-optimizer/vcpkg.json | 31 | ||||
| -rw-r--r-- | versions/baseline.json | 4 | ||||
| -rw-r--r-- | versions/o-/onnx-optimizer.json | 9 |
5 files changed, 143 insertions, 0 deletions
diff --git a/ports/onnx-optimizer/fix-cmakelists.patch b/ports/onnx-optimizer/fix-cmakelists.patch new file mode 100644 index 000000000..4c54d77e0 --- /dev/null +++ b/ports/onnx-optimizer/fix-cmakelists.patch @@ -0,0 +1,56 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c2e48b3..5716fbb 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -7,10 +7,18 @@ if(NOT MSVC)
+ set(CMAKE_CXX_STANDARD 11)
+ endif(NOT MSVC)
+
++# 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)
+
+-set(ONNX_ROOT ${PROJECT_SOURCE_DIR}/third_party/onnx)
+-add_subdirectory(${ONNX_ROOT})
++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)
+@@ -31,6 +39,7 @@ add_executable(onnx_optimizer_exec examples/onnx_optimizer_exec.cpp)
+ target_link_libraries(onnx_optimizer_exec onnx_optimizer)
+
+ if(BUILD_ONNX_PYTHON)
++ find_package(Python3 COMPONENTS Development REQUIRED)
+ if("${PY_EXT_SUFFIX}" STREQUAL "")
+ if(MSVC)
+ set(PY_EXT_SUFFIX ".pyd")
+@@ -51,7 +60,7 @@ if(BUILD_ONNX_PYTHON)
+ $<INSTALL_INTERFACE:include>
+ ${PYTHON_INCLUDE_DIR})
+ # pybind11 is a header only lib
+- find_package(pybind11 2.2)
++ find_package(pybind11 2.2 CONFIG REQUIRED)
+ if(pybind11_FOUND)
+ target_include_directories(onnx_opt_cpp2py_export PUBLIC
+ ${pybind11_INCLUDE_DIRS})
+@@ -87,11 +96,9 @@ if(BUILD_ONNX_PYTHON)
+ endif()
+
+ target_link_libraries(onnx_opt_cpp2py_export PRIVATE onnx_optimizer)
+-
++ target_link_directories(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARY_DIRS})
++ target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARIES})
+ if(MSVC)
+- find_package(PythonInterp ${PY_VERSION} REQUIRED)
+- find_package(PythonLibs ${PY_VERSION} REQUIRED)
+- target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${PYTHON_LIBRARIES})
+ target_compile_options(onnx_opt_cpp2py_export
+ PRIVATE /MP
+ /WX
diff --git a/ports/onnx-optimizer/portfile.cmake b/ports/onnx-optimizer/portfile.cmake new file mode 100644 index 000000000..fe62f0304 --- /dev/null +++ b/ports/onnx-optimizer/portfile.cmake @@ -0,0 +1,43 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO onnx/optimizer + REF v0.2.6 + SHA512 cc6373781f04bc6fafd3282d248e26eaf93556b86acbb0dee44b4aa7a5d59c634905c1a05d035e31a50fc0f06cfc686fa483b79a324dd973faa421747d4a681b + HEAD_REF master + PATCHES + fix-cmakelists.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + pybind11 BUILD_ONNX_PYTHON +) +if("pybind11" IN_LIST FEATURES) + vcpkg_find_acquire_program(PYTHON3) + list(APPEND FEATURE_OPTIONS + -DPython3_EXECUTABLE=${PYTHON3} + -DONNX_USE_PROTOBUF_SHARED_LIBS=ON # /wd4251 + ) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} +) +if("pybind11" IN_LIST FEATURES) + # This target is not in install/export + vcpkg_cmake_build(TARGET onnx_opt_cpp2py_export) +endif() +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(PACKAGE_NAME ONNXOptimizer CONFIG_PATH lib/cmake/ONNXOptimizer) + +file(INSTALL "${SOURCE_PATH}/LICENSE" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/include/onnxoptimizer/test" +) diff --git a/ports/onnx-optimizer/vcpkg.json b/ports/onnx-optimizer/vcpkg.json new file mode 100644 index 000000000..f38496eb0 --- /dev/null +++ b/ports/onnx-optimizer/vcpkg.json @@ -0,0 +1,31 @@ +{ + "name": "onnx-optimizer", + "version-semver": "0.2.6", + "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 + } + ], + "features": { + "pybind11": { + "description": "Build Python binaries", + "dependencies": [ + { + "name": "onnx", + "features": [ + "pybind11" + ] + } + ] + } + } +} diff --git a/versions/baseline.json b/versions/baseline.json index 900bb45e1..703135f58 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4696,6 +4696,10 @@ "baseline": "1.9.0", "port-version": 0 }, + "onnx-optimizer": { + "baseline": "0.2.6", + "port-version": 0 + }, "onnxruntime-gpu": { "baseline": "1.5.1", "port-version": 0 diff --git a/versions/o-/onnx-optimizer.json b/versions/o-/onnx-optimizer.json new file mode 100644 index 000000000..3a6bc01dc --- /dev/null +++ b/versions/o-/onnx-optimizer.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "e98d775d36ccb84c9ffa20e2cf6f8ef1b7ab0461", + "version-semver": "0.2.6", + "port-version": 0 + } + ] +} |
