mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-08 11:11:48 +08:00
2aa021c307
* [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
57 lines
2.2 KiB
Diff
57 lines
2.2 KiB
Diff
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
|