@@ -24,6 +24,7 @@ endif()
2424include (ExternalProject)
2525
2626set (PADDLE2ONNX_PROJECT "extern_paddle2onnx" )
27+ set (PADDLE2ONNX_VERSION "0.9.9" )
2728set (PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH} /paddle2onnx)
2829set (PADDLE2ONNX_SOURCE_DIR
2930 ${THIRD_PARTY_PATH} /paddle2onnx/src/${PADDLE2ONNX_PROJECT} )
@@ -34,71 +35,85 @@ set(PADDLE2ONNX_INC_DIR
3435set (PADDLE2ONNX_LIB_DIR
3536 "${PADDLE2ONNX_INSTALL_DIR} /lib"
3637 CACHE PATH "onnxruntime lib directory." FORCE)
37- set (CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH} "
38- "${PADDLE2ONNX_INSTALL_DIR} /${LIBDIR} " )
38+ set (CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH} " "${PADDLE2ONNX_LIB_DIR} " )
39+
40+ # For PADDLE2ONNX code to include internal headers.
41+ include_directories (${PADDLE2ONNX_INC_DIR} )
42+ set (PADDLE2ONNX_LIB_NEW_NAME "libpaddle2onnx${CMAKE_SHARED_LIBRARY_SUFFIX} " )
43+ if (APPLE )
44+ set (PADDLE2ONNX_LIB_NAME
45+ "libpaddle2onnx.${PADDLE2ONNX_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX} " )
46+ else ()
47+ set (PADDLE2ONNX_LIB_NAME
48+ "libpaddle2onnx${CMAKE_SHARED_LIBRARY_SUFFIX} .${PADDLE2ONNX_VERSION} " )
49+ endif ()
3950
40- include_directories (${PADDLE2ONNX_INC_DIR}
41- )# For PADDLE2ONNX code to include internal headers.
4251if (WIN32 )
43- set (PADDLE2ONNX_SOURCE_LIB
44- "${PADDLE2ONNX_SOURCE_DIR} /lib/libpaddle2onnx.dylib"
45- CACHE FILEPATH "Paddle2ONNX source library." FORCE)
4652 set (PADDLE2ONNX_LIB
4753 "${PADDLE2ONNX_INSTALL_DIR} /lib/paddle2onnx.dll"
4854 CACHE FILEPATH "paddle2onnx library." FORCE)
4955 set (PADDLE2ONNX_COMPILE_LIB
5056 "${PADDLE2ONNX_INSTALL_DIR} /lib/paddle2onnx.lib"
5157 CACHE FILEPATH "paddle2onnx compile library." FORCE)
52- elseif (APPLE )
53- set (PADDLE2ONNX_SOURCE_LIB
54- "${PADDLE2ONNX_SOURCE_DIR} /lib/libpaddle2onnx.dylib"
55- CACHE FILEPATH "Paddle2ONNX source library." FORCE)
56- set (PADDLE2ONNX_LIB
57- "${PADDLE2ONNX_INSTALL_DIR} /lib/libpaddle2onnx.dylib"
58- CACHE FILEPATH "PADDLE2ONNX library." FORCE)
59- set (PADDLE2ONNX_COMPILE_LIB
60- "${PADDLE2ONNX_INSTALL_DIR} /lib/libpaddle2onnx.dylib"
61- CACHE FILEPATH "paddle2onnx compile library." FORCE)
6258else ()
6359 set (PADDLE2ONNX_SOURCE_LIB
64- "${PADDLE2ONNX_SOURCE_DIR} /lib/libpaddle2onnx.so "
65- CACHE FILEPATH "Paddle2ONNX source library." FORCE)
60+ "${PADDLE2ONNX_SOURCE_DIR} /lib/${PADDLE2ONNX_LIB_NAME} "
61+ CACHE FILEPATH "PADDLE2ONNX source library." FORCE)
6662 set (PADDLE2ONNX_LIB
67- "${PADDLE2ONNX_INSTALL_DIR} /lib/libpaddle2onnx.so "
63+ "${PADDLE2ONNX_LIB_DIR} / ${PADDLE2ONNX_LIB_NAME} "
6864 CACHE FILEPATH "PADDLE2ONNX library." FORCE)
6965 set (PADDLE2ONNX_COMPILE_LIB
70- " ${PADDLE2ONNX_INSTALL_DIR} /lib/libpaddle2onnx.so"
66+ ${PADDLE2ONNX_LIB}
7167 CACHE FILEPATH "paddle2onnx compile library." FORCE)
7268endif ()
7369
7470if (WIN32 )
7571 set (PADDLE2ONNX_URL
76- "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7 /paddle2onnx-win-x64-0.9.7 .zip"
72+ "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v ${PADDLE2ONNX_VERSION} /paddle2onnx-win-x64-${PADDLE2ONNX_VERSION} .zip"
7773 )
7874elseif (APPLE )
7975 set (PADDLE2ONNX_URL
80- "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7 /paddle2onnx-osx-x86_64-0.9.7 .tgz"
76+ "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v ${PADDLE2ONNX_VERSION} /paddle2onnx-osx-x86_64-${PADDLE2ONNX_VERSION} .tgz"
8177 )
8278else ()
8379 set (PADDLE2ONNX_URL
84- "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7 /paddle2onnx-linux-x64-0.9.7 .tgz"
80+ "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v ${PADDLE2ONNX_VERSION} /paddle2onnx-linux-x64-${PADDLE2ONNX_VERSION} .tgz"
8581 )
8682endif ()
8783
88- ExternalProject_Add(
89- ${PADDLE2ONNX_PROJECT}
90- ${EXTERNAL_PROJECT_LOG_ARGS}
91- URL ${PADDLE2ONNX_URL}
92- PREFIX ${PADDLE2ONNX_PREFIX_DIR}
93- DOWNLOAD_NO_PROGRESS 1
94- CONFIGURE_COMMAND ""
95- BUILD_COMMAND ""
96- UPDATE_COMMAND ""
97- INSTALL_COMMAND
98- ${CMAKE_COMMAND} -E copy_directory ${PADDLE2ONNX_SOURCE_DIR} /lib
99- ${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
100- ${PADDLE2ONNX_SOURCE_DIR} /include ${PADDLE2ONNX_INC_DIR}
101- BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB} )
84+ if (WIN32 )
85+ ExternalProject_Add(
86+ ${PADDLE2ONNX_PROJECT}
87+ ${EXTERNAL_PROJECT_LOG_ARGS}
88+ URL ${PADDLE2ONNX_URL}
89+ PREFIX ${PADDLE2ONNX_PREFIX_DIR}
90+ DOWNLOAD_NO_PROGRESS 1
91+ CONFIGURE_COMMAND ""
92+ BUILD_COMMAND ""
93+ UPDATE_COMMAND ""
94+ INSTALL_COMMAND
95+ ${CMAKE_COMMAND} -E copy_directory ${PADDLE2ONNX_SOURCE_DIR} /lib
96+ ${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
97+ ${PADDLE2ONNX_SOURCE_DIR} /include ${PADDLE2ONNX_INC_DIR}
98+ BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB} )
99+ else ()
100+ ExternalProject_Add(
101+ ${PADDLE2ONNX_PROJECT}
102+ ${EXTERNAL_PROJECT_LOG_ARGS}
103+ URL ${PADDLE2ONNX_URL}
104+ PREFIX ${PADDLE2ONNX_PREFIX_DIR}
105+ DOWNLOAD_NO_PROGRESS 1
106+ CONFIGURE_COMMAND ""
107+ BUILD_COMMAND ""
108+ UPDATE_COMMAND ""
109+ INSTALL_COMMAND
110+ ${CMAKE_COMMAND} -E copy ${PADDLE2ONNX_SOURCE_LIB}
111+ ${PADDLE2ONNX_COMPILE_LIB} && ${CMAKE_COMMAND} -E copy_directory
112+ ${PADDLE2ONNX_SOURCE_DIR} /include ${PADDLE2ONNX_INC_DIR} &&
113+ ${CMAKE_COMMAND} -E create_symlink ${PADDLE2ONNX_LIB_NAME}
114+ ${PADDLE2ONNX_LIB_DIR} /${PADDLE2ONNX_LIB_NEW_NAME}
115+ BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB} )
116+ endif ()
102117
103118add_library (paddle2onnx STATIC IMPORTED GLOBAL )
104119set_property (TARGET paddle2onnx PROPERTY IMPORTED_LOCATION
0 commit comments