From fad9039a930300f0c0668cf15be5fa40a0000014 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Fri, 12 Jul 2024 09:51:05 -0700 Subject: [PATCH 1/3] update --- cmake/onnxruntime.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index ec98047750a91..38b4e9b84961f 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -95,7 +95,6 @@ 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() @@ -130,7 +129,6 @@ 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 @@ -222,10 +220,13 @@ target_link_libraries(onnxruntime PRIVATE ) set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_SO_LINK_FLAG} ${onnxruntime_DELAYLOAD_FLAGS}) + +#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html set_target_properties(onnxruntime PROPERTIES PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" LINK_DEPENDS ${SYMBOL_FILE} VERSION ${ORT_VERSION} + SOVERSION 1 FOLDER "ONNXRuntime" ) From c484559e4f65ca0ac03e4b203fcc90b4e7cbf68d Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Fri, 12 Jul 2024 13:43:28 -0700 Subject: [PATCH 2/3] update --- cmake/CMakeLists.txt | 22 ++++++++++++++++ cmake/onnxruntime.cmake | 29 ++++++++++++---------- cmake/onnxruntime_providers_cpu.cmake | 5 ---- cmake/onnxruntime_providers_openvino.cmake | 5 ---- cmake/winml.cmake | 5 ---- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e2fc3da9de35e..a23f8ee1136f0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1140,6 +1140,13 @@ 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) @@ -1154,6 +1161,13 @@ 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}) @@ -1636,6 +1650,14 @@ 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 38b4e9b84961f..90dab4ba44231 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -107,11 +107,7 @@ 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) @@ -222,14 +218,21 @@ target_link_libraries(onnxruntime PRIVATE set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_SO_LINK_FLAG} ${onnxruntime_DELAYLOAD_FLAGS}) #See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html -set_target_properties(onnxruntime PROPERTIES - PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" - LINK_DEPENDS ${SYMBOL_FILE} - VERSION ${ORT_VERSION} - SOVERSION 1 - FOLDER "ONNXRuntime" -) - +if(NOT MACROS) + 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 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 b211c02f712bd..d9fba6f564037 100644 --- a/cmake/onnxruntime_providers_cpu.cmake +++ b/cmake/onnxruntime_providers_cpu.cmake @@ -236,11 +236,6 @@ 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 5876b2b5c448b..d738e29101cfe 100644 --- a/cmake/onnxruntime_providers_openvino.cmake +++ b/cmake/onnxruntime_providers_openvino.cmake @@ -45,11 +45,6 @@ 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 d74250b962628..ff6b71217ad87 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -718,11 +718,6 @@ 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") From 63e487a66d63dbd0b4c190b1dfb689c10825d8f6 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Fri, 12 Jul 2024 13:50:51 -0700 Subject: [PATCH 3/3] update --- cmake/onnxruntime.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index 90dab4ba44231..aebf9b53f8f05 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -218,7 +218,7 @@ target_link_libraries(onnxruntime PRIVATE set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_SO_LINK_FLAG} ${onnxruntime_DELAYLOAD_FLAGS}) #See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html -if(NOT MACROS) +if(NOT APPLE AND NOT WIN32) set_target_properties(onnxruntime PROPERTIES PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" LINK_DEPENDS ${SYMBOL_FILE} @@ -226,7 +226,7 @@ if(NOT MACROS) SOVERSION 1 FOLDER "ONNXRuntime") else() - # Omit the SOVERSION setting in macOS/iOS/.. build + # Omit the SOVERSION setting in Windows/macOS/iOS/.. build set_target_properties(onnxruntime PROPERTIES PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}" LINK_DEPENDS ${SYMBOL_FILE}