From 86f297f0a4a0c86f46e59b92ea17da91133ea530 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 17 Jul 2024 17:28:06 +0000 Subject: [PATCH] Revert "Change libonnxruntime.so's SONAME: remove the minor and patch version. (#21339)" This reverts commit e5f18ba2c14ced91e5f483fde0a7ef4b3b04abbe. --- cmake/CMakeLists.txt | 22 ---------------- cmake/onnxruntime.cmake | 30 ++++++++++------------ cmake/onnxruntime_providers_cpu.cmake | 5 ++++ cmake/onnxruntime_providers_openvino.cmake | 5 ++++ cmake/winml.cmake | 5 ++++ 5 files changed, 28 insertions(+), 39 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5db0466497ad1..fb9f2f8f32b34 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1140,13 +1140,6 @@ endfunction() function(onnxruntime_add_shared_library target_name) add_library(${target_name} SHARED ${ARGN}) onnxruntime_configure_target(${target_name}) - if(WIN32) - target_compile_definitions(${target_name} PRIVATE VER_MAJOR=${VERSION_MAJOR_PART}) - target_compile_definitions(${target_name} PRIVATE VER_MINOR=${VERSION_MINOR_PART}) - target_compile_definitions(${target_name} PRIVATE VER_BUILD=${VERSION_BUILD_PART}) - target_compile_definitions(${target_name} PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART}) - target_compile_definitions(${target_name} PRIVATE VER_STRING=\"${VERSION_STRING}\") - endif() endfunction() function(onnxruntime_add_static_library target_name) @@ -1161,13 +1154,6 @@ function(onnxruntime_add_shared_library_module target_name) else() #On Windows, this target shouldn't generate an import lib, but I don't know how to disable it. add_library(${target_name} MODULE ${ARGN}) - if(WIN32) - target_compile_definitions(${target_name} PRIVATE VER_MAJOR=${VERSION_MAJOR_PART}) - target_compile_definitions(${target_name} PRIVATE VER_MINOR=${VERSION_MINOR_PART}) - target_compile_definitions(${target_name} PRIVATE VER_BUILD=${VERSION_BUILD_PART}) - target_compile_definitions(${target_name} PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART}) - target_compile_definitions(${target_name} PRIVATE VER_STRING=\"${VERSION_STRING}\") - endif() endif() onnxruntime_configure_target(${target_name}) @@ -1650,14 +1636,6 @@ set(VERSION_MINOR_PART 0 CACHE STRING "Second part of numeric file/product ver set(VERSION_BUILD_PART 0 CACHE STRING "Third part of numeric file/product version.") set(VERSION_PRIVATE_PART 0 CACHE STRING "Fourth part of numeric file/product version.") set(VERSION_STRING "Internal Build" CACHE STRING "String representation of file/product version.") -if(VERSION_MAJOR_PART STREQUAL "0" AND VERSION_MINOR_PART STREQUAL "0" AND VERSION_BUILD_PART STREQUAL "0" AND VERSION_PRIVATE_PART STREQUAL "0") - string(REPLACE "." ";" ORT_VERSION_STRING_LIST ${ORT_VERSION}) - list(GET ORT_VERSION_STRING_LIST 0 VERSION_MAJOR_PART) - list(GET ORT_VERSION_STRING_LIST 1 VERSION_MINOR_PART) - list(GET ORT_VERSION_STRING_LIST 2 VERSION_BUILD_PART) - set(VERSION_STRING ORT_VERSION) -endif() - if (WIN32) list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${SYS_PATH_LIB}) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index aebf9b53f8f05..ec98047750a91 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -95,6 +95,7 @@ elseif(onnxruntime_BUILD_APPLE_FRAMEWORK) FRAMEWORK TRUE FRAMEWORK_VERSION A MACOSX_FRAMEWORK_INFO_PLIST ${INFO_PLIST_PATH} + SOVERSION ${ORT_VERSION} # Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file. ) else() @@ -107,7 +108,11 @@ endif() add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES}) target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$") - +target_compile_definitions(onnxruntime PRIVATE VER_MAJOR=${VERSION_MAJOR_PART}) +target_compile_definitions(onnxruntime PRIVATE VER_MINOR=${VERSION_MINOR_PART}) +target_compile_definitions(onnxruntime PRIVATE VER_BUILD=${VERSION_BUILD_PART}) +target_compile_definitions(onnxruntime PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART}) +target_compile_definitions(onnxruntime PRIVATE VER_STRING=\"${VERSION_STRING}\") target_compile_definitions(onnxruntime PRIVATE FILE_NAME=\"onnxruntime.dll\") if(UNIX) @@ -125,6 +130,7 @@ if (NOT WIN32) set(ONNXRUNTIME_SO_LINK_FLAG " -Wl,-exported_symbols_list,${SYMBOL_FILE}") if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") set_target_properties(onnxruntime PROPERTIES + SOVERSION ${ORT_VERSION} MACOSX_RPATH TRUE INSTALL_RPATH_USE_LINK_PATH FALSE BUILD_WITH_INSTALL_NAME_DIR TRUE @@ -216,23 +222,13 @@ target_link_libraries(onnxruntime PRIVATE ) set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_SO_LINK_FLAG} ${onnxruntime_DELAYLOAD_FLAGS}) +set_target_properties(onnxruntime PROPERTIES + PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" + LINK_DEPENDS ${SYMBOL_FILE} + VERSION ${ORT_VERSION} + FOLDER "ONNXRuntime" +) -#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html -if(NOT APPLE AND NOT WIN32) - set_target_properties(onnxruntime PROPERTIES - PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" - LINK_DEPENDS ${SYMBOL_FILE} - VERSION ${ORT_VERSION} - SOVERSION 1 - FOLDER "ONNXRuntime") -else() - # Omit the SOVERSION setting in Windows/macOS/iOS/.. build - set_target_properties(onnxruntime PROPERTIES - PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" - LINK_DEPENDS ${SYMBOL_FILE} - VERSION ${ORT_VERSION} - FOLDER "ONNXRuntime") -endif() install(TARGETS onnxruntime EXPORT ${PROJECT_NAME}Targets PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime diff --git a/cmake/onnxruntime_providers_cpu.cmake b/cmake/onnxruntime_providers_cpu.cmake index d9fba6f564037..b211c02f712bd 100644 --- a/cmake/onnxruntime_providers_cpu.cmake +++ b/cmake/onnxruntime_providers_cpu.cmake @@ -236,6 +236,11 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD set_target_properties(onnxruntime_providers_shared PROPERTIES FOLDER "ONNXRuntime") set_target_properties(onnxruntime_providers_shared PROPERTIES LINKER_LANGUAGE CXX) + target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_MAJOR=${VERSION_MAJOR_PART}) + target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_MINOR=${VERSION_MINOR_PART}) + target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_BUILD=${VERSION_BUILD_PART}) + target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART}) + target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_STRING=\"${VERSION_STRING}\") target_compile_definitions(onnxruntime_providers_shared PRIVATE FILE_NAME=\"onnxruntime_providers_shared.dll\") diff --git a/cmake/onnxruntime_providers_openvino.cmake b/cmake/onnxruntime_providers_openvino.cmake index d738e29101cfe..5876b2b5c448b 100644 --- a/cmake/onnxruntime_providers_openvino.cmake +++ b/cmake/onnxruntime_providers_openvino.cmake @@ -45,6 +45,11 @@ target_include_directories(onnxruntime_providers_openvino SYSTEM PUBLIC ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${OpenVINO_INCLUDE_DIR} ${OPENVINO_INCLUDE_DIR_LIST} ${PYTHON_INCLUDE_DIRS} $ENV{OPENCL_INCS} $ENV{OPENCL_INCS}/../../cl_headers/) target_link_libraries(onnxruntime_providers_openvino ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 ${OPENVINO_LIB_LIST} ${ABSEIL_LIBS}) + target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_MAJOR=${VERSION_MAJOR_PART}) + target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_MINOR=${VERSION_MINOR_PART}) + target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_BUILD=${VERSION_BUILD_PART}) + target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART}) + target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_STRING=\"${VERSION_STRING}\") target_compile_definitions(onnxruntime_providers_openvino PRIVATE FILE_NAME=\"onnxruntime_providers_openvino.dll\") if(MSVC) diff --git a/cmake/winml.cmake b/cmake/winml.cmake index ff6b71217ad87..d74250b962628 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -718,6 +718,11 @@ target_compile_definitions(winml_dll PRIVATE ONNX_ML) target_compile_definitions(winml_dll PRIVATE LOTUS_LOG_THRESHOLD=2) target_compile_definitions(winml_dll PRIVATE LOTUS_ENABLE_STDERR_LOGGING) target_compile_definitions(winml_dll PRIVATE PLATFORM_WINDOWS) +target_compile_definitions(winml_dll PRIVATE VER_MAJOR=${VERSION_MAJOR_PART}) +target_compile_definitions(winml_dll PRIVATE VER_MINOR=${VERSION_MINOR_PART}) +target_compile_definitions(winml_dll PRIVATE VER_BUILD=${VERSION_BUILD_PART}) +target_compile_definitions(winml_dll PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART}) +target_compile_definitions(winml_dll PRIVATE VER_STRING=\"${VERSION_STRING}\") target_compile_definitions(winml_dll PRIVATE BINARY_NAME=\"${BINARY_NAME}\") if (onnxruntime_WINML_NAMESPACE_OVERRIDE STREQUAL "Windows")