mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 20:32:47 +08:00
[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
This commit is contained in:
parent
c26101d71e
commit
2aa021c307
56
ports/onnx-optimizer/fix-cmakelists.patch
Normal file
56
ports/onnx-optimizer/fix-cmakelists.patch
Normal file
@ -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
|
43
ports/onnx-optimizer/portfile.cmake
Normal file
43
ports/onnx-optimizer/portfile.cmake
Normal file
@ -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"
|
||||
)
|
31
ports/onnx-optimizer/vcpkg.json
Normal file
31
ports/onnx-optimizer/vcpkg.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
9
versions/o-/onnx-optimizer.json
Normal file
9
versions/o-/onnx-optimizer.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "e98d775d36ccb84c9ffa20e2cf6f8ef1b7ab0461",
|
||||
"version-semver": "0.2.6",
|
||||
"port-version": 0
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user