diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7168a99fe1f93..bc610ae7d86cb 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -102,6 +102,7 @@ option(onnxruntime_BUILD_UNIT_TESTS "Build ONNXRuntime unit tests" ON) option(onnxruntime_BUILD_CSHARP "Build C# library" OFF) option(onnxruntime_BUILD_OBJC "Build Objective-C library" OFF) option(onnxruntime_USE_PREINSTALLED_EIGEN "Use pre-installed EIGEN. Need to provide eigen_SOURCE_PATH if turn this on." OFF) +option(onnxruntime_USE_EIGEN_PACKAGE "Use Eigen obtained via find_package. Note that onnxruntime is incompatible with the current major Eigen release. See the eigen commit in cmake/deps.txt." OFF) option(onnxruntime_BUILD_BENCHMARKS "Build ONNXRuntime micro-benchmarks" OFF) option(onnxruntime_USE_LLVM "Build TVM with LLVM" OFF) option(onnxruntime_USE_VSINPU "Build with VSINPU support" OFF) @@ -1683,12 +1684,10 @@ if (onnxruntime_USE_WINML) list(APPEND ONNXRUNTIME_CMAKE_FILES winml) endif() # if (onnxruntime_USE_WINML) -if (onnxruntime_BUILD_SHARED_LIB OR onnxruntime_BUILD_APPLE_FRAMEWORK) - if (onnxruntime_BUILD_APPLE_FRAMEWORK AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS") - message(FATAL_ERROR "onnxruntime_BUILD_APPLE_FRAMEWORK can only be enabled for macOS or iOS or visionOS.") - endif() - list(APPEND ONNXRUNTIME_CMAKE_FILES onnxruntime) +if (onnxruntime_BUILD_APPLE_FRAMEWORK AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS") + message(FATAL_ERROR "onnxruntime_BUILD_APPLE_FRAMEWORK can only be enabled for macOS or iOS or visionOS.") endif() +list(APPEND ONNXRUNTIME_CMAKE_FILES onnxruntime) if (onnxruntime_BUILD_JAVA) message(STATUS "Java Build is enabled") @@ -1803,33 +1802,57 @@ if (onnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS) ) endif() -if(TARGET onnxruntime) # Install - include(GNUInstallDirs) - include(CMakePackageConfigHelpers) - set(PROJECT_CONFIG_CONTENT "@PACKAGE_INIT@\n") - string(APPEND PROJECT_CONFIG_CONTENT - "include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake\")") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/PROJECT_CONFIG_FILE" ${PROJECT_CONFIG_CONTENT}) - install(EXPORT ${PROJECT_NAME}Targets - NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) -# Create config for find_package() - configure_package_config_file( - "${CMAKE_CURRENT_BINARY_DIR}/PROJECT_CONFIG_FILE" ${PROJECT_NAME}Config.cmake - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") - - write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - VERSION ${ORT_VERSION} - COMPATIBILITY SameMajorVersion) +include(CMakePackageConfigHelpers) + +set(PROJECT_CONFIG_CONTENT "@PACKAGE_INIT@\n") + +if (NOT onnxruntime_BUILD_SHARED_LIB) +string(APPEND PROJECT_CONFIG_CONTENT + "include(CMakeFindDependencyMacro)\n\ + find_dependency(absl)\n\ + find_dependency(date)\n\ + find_dependency(Eigen3)\n\ + find_dependency(nlohmann_json)\n\ + find_dependency(ONNX)\n\ + find_dependency(re2)\n\ + find_dependency(flatbuffers)\n\ + find_dependency(unofficial-nsync)\n\ + find_dependency(cpuinfo)\n\ + find_dependency(protobuf)\n\ + find_dependency(Boost COMPONENTS mp11)\n\ + find_dependency(Microsoft.GSL 4.0)\n\ + find_dependency(Iconv)\n\ + find_path(safeint_SOURCE_DIR NAMES \"SafeInt.hpp\" REQUIRED)\n\ + add_library(safeint_interface IMPORTED INTERFACE)\n\ + target_include_directories(safeint_interface INTERFACE ${safeint_SOURCE_DIR})\n\ + ") +endif() + +string(APPEND PROJECT_CONFIG_CONTENT + "include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake\")\n") + + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/PROJECT_CONFIG_FILE" ${PROJECT_CONFIG_CONTENT}) +install(EXPORT ${PROJECT_NAME}Targets + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) - install( - FILES - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") -endif() +# Create config for find_package() +configure_package_config_file( + "${CMAKE_CURRENT_BINARY_DIR}/PROJECT_CONFIG_FILE" ${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + VERSION ${ORT_VERSION} + COMPATIBILITY SameMajorVersion) + +install( + FILES + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") if(DEFINED BUILD_AS_ARM64X) set(ARM64X_TARGETS onnxruntime) diff --git a/cmake/deps.txt b/cmake/deps.txt index 342184bda2f0e..56638a931b576 100644 --- a/cmake/deps.txt +++ b/cmake/deps.txt @@ -27,7 +27,7 @@ flatbuffers;https://github.com/google/flatbuffers/archive/refs/tags/v23.5.26.zip fp16;https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip;b985f6985a05a1c03ff1bb71190f66d8f98a1494 fxdiv;https://github.com/Maratyszcza/FXdiv/archive/63058eff77e11aa15bf531df5dd34395ec3017c8.zip;a5658f4036402dbca7cebee32be57fb8149811e1 google_benchmark;https://github.com/google/benchmark/archive/refs/tags/v1.8.5.zip;cd47d3d272faf353600c8cc2fdec2b52d6f69177 -google_nsync;https://github.com/google/nsync/archive/refs/tags/1.26.0.zip;5e7c00ef6bf5b787386fc040067903ec774e2752 +google_nsync;https://github.com/google/nsync/archive/refs/tags/1.29.0.zip;acc46ec0bc736da1cf581c9bb2700f9cea210b6c googletest;https://github.com/google/googletest/archive/refs/tags/v1.15.0.zip;9d2d0af8d77ac726ea55d44a8fa727ec98311349 #xnnpack 2024.09.04 googlexnnpack;https://github.com/google/XNNPACK/archive/309b75c9e56e0a674bf78d59872ce131f814dfb6.zip;39FA5259EAEACE0547284B63D5CEDC4F05553F5A diff --git a/cmake/external/eigen.cmake b/cmake/external/eigen.cmake index 339cded091b29..40661c2a41d20 100644 --- a/cmake/external/eigen.cmake +++ b/cmake/external/eigen.cmake @@ -18,6 +18,6 @@ else () ) endif() - FetchContent_Populate(eigen) + onnxruntime_fetchcontent_makeavailable(eigen) set(eigen_INCLUDE_DIRS "${eigen_SOURCE_DIR}") endif() diff --git a/cmake/external/onnxruntime_external_deps.cmake b/cmake/external/onnxruntime_external_deps.cmake index cb737ee53639f..4973de4fad0db 100644 --- a/cmake/external/onnxruntime_external_deps.cmake +++ b/cmake/external/onnxruntime_external_deps.cmake @@ -102,9 +102,17 @@ if (NOT WIN32) add_library(nsync::nsync_cpp ALIAS nsync_cpp) target_include_directories(nsync_cpp PUBLIC ${google_nsync_SOURCE_DIR}/public) endif() - if(TARGET unofficial::nsync::nsync_cpp AND NOT TARGET nsync::nsync_cpp) + + if (NOT TARGET nsync::nsync_cpp) + if(TARGET unofficial::nsync::nsync_cpp) message(STATUS "Aliasing unofficial::nsync::nsync_cpp to nsync::nsync_cpp") add_library(nsync::nsync_cpp ALIAS unofficial::nsync::nsync_cpp) + elseif(TARGET nsync_cpp) + message(STATUS "Aliasing nsync_cpp to nsync::nsync_cpp") + add_library(nsync::nsync_cpp ALIAS nsync_cpp) + else() + message(FATAL_ERROR "Failed to import needed target nsync::nsync_cpp") + endif() endif() endif() @@ -217,7 +225,7 @@ FetchContent_Declare( URL ${DEP_URL_protobuf} URL_HASH SHA1=${DEP_SHA1_protobuf} PATCH_COMMAND ${ONNXRUNTIME_PROTOBUF_PATCH_COMMAND} - FIND_PACKAGE_ARGS NAMES Protobuf protobuf + FIND_PACKAGE_ARGS 3.21 NAMES Protobuf protobuf ) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests" FORCE) @@ -295,19 +303,19 @@ FetchContent_Declare( ) onnxruntime_fetchcontent_makeavailable(date) +find_package(Boost COMPONENTS mp11) + +if (NOT TARGET Boost::mp11) FetchContent_Declare( mp11 URL ${DEP_URL_mp11} URL_HASH SHA1=${DEP_SHA1_mp11} - FIND_PACKAGE_ARGS NAMES Boost ) -onnxruntime_fetchcontent_makeavailable(mp11) -if(NOT TARGET Boost::mp11) - if(onnxruntime_USE_VCPKG) - find_package(Boost REQUIRED) - endif() - message(STATUS "Aliasing Boost::headers to Boost::mp11") - add_library(Boost::mp11 ALIAS Boost::headers) + +FetchContent_Populate(mp11) + +add_library(Boost::mp11 IMPORTED INTERFACE) +target_include_directories(Boost::mp11 INTERFACE ${mp11_SOURCE_DIR}/include) endif() set(JSON_BuildTests OFF CACHE INTERNAL "") @@ -453,7 +461,7 @@ if(NOT safeint_SOURCE_DIR) # use fetch content rather than makeavailable because safeint only includes unconditional test targets FetchContent_Populate(safeint) endif() -add_library(safeint_interface INTERFACE) +add_library(safeint_interface IMPORTED INTERFACE) target_include_directories(safeint_interface INTERFACE ${safeint_SOURCE_DIR}) @@ -463,7 +471,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATC" FORCE) endif() set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "FLATBUFFERS_BUILD_TESTS" FORCE) -set(FLATBUFFERS_INSTALL OFF CACHE BOOL "FLATBUFFERS_INSTALL" FORCE) +set(FLATBUFFERS_INSTALL ON CACHE BOOL "FLATBUFFERS_INSTALL" FORCE) set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATHASH" FORCE) set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "FLATBUFFERS_BUILD_FLATLIB" FORCE) if(Patch_FOUND) @@ -527,7 +535,7 @@ FetchContent_Declare( URL_HASH SHA1=${DEP_SHA1_onnx} PATCH_COMMAND ${ONNXRUNTIME_ONNX_PATCH_COMMAND} FIND_PACKAGE_ARGS NAMES ONNX onnx -) + ) if (NOT onnxruntime_MINIMAL_BUILD) onnxruntime_fetchcontent_makeavailable(onnx) else() @@ -543,7 +551,10 @@ if(TARGET ONNX::onnx_proto AND NOT TARGET onnx_proto) add_library(onnx_proto ALIAS ONNX::onnx_proto) endif() +if(onnxruntime_USE_EIGEN_PACKAGE) find_package(Eigen3 CONFIG) +endif() + if(Eigen3_FOUND) get_target_property(eigen_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES) else() @@ -579,7 +590,7 @@ endif() #onnxruntime_EXTERNAL_LIBRARIES could contain onnx, onnx_proto,libprotobuf, cuda/cudnn, # dnnl/mklml, onnxruntime_codegen_tvm, tvm and pthread # pthread is always at the last -set(onnxruntime_EXTERNAL_LIBRARIES ${onnxruntime_EXTERNAL_LIBRARIES_XNNPACK} ${WIL_TARGET} nlohmann_json::nlohmann_json onnx onnx_proto ${PROTOBUF_LIB} re2::re2 Boost::mp11 safeint_interface flatbuffers::flatbuffers ${GSL_TARGET} ${ABSEIL_LIBS} date::date ${ONNXRUNTIME_CLOG_TARGET_NAME}) +set(onnxruntime_EXTERNAL_LIBRARIES ${onnxruntime_EXTERNAL_LIBRARIES_XNNPACK} ${WIL_TARGET} nlohmann_json::nlohmann_json onnx onnx_proto ${PROTOBUF_LIB} re2::re2 Boost::mp11 safeint_interface flatbuffers::flatbuffers ${GSL_TARGET} ${ABSEIL_LIBS} date::date ${ONNXRUNTIME_CLOG_TARGET_NAME} nsync::nsync_cpp) # The source code of onnx_proto is generated, we must build this lib first before starting to compile the other source code that uses ONNX protobuf types. # The other libs do not have the problem. All the sources are already there. We can compile them in any order. set(onnxruntime_EXTERNAL_DEPENDENCIES onnx_proto flatbuffers::flatbuffers) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index f2be742458313..9ec1d3ff38675 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -38,7 +38,7 @@ function(get_c_cxx_api_headers HEADERS_VAR) # need to add header files for enabled EPs foreach(f ${ONNXRUNTIME_PROVIDER_NAMES}) - # The header files in include/onnxruntime/core/providers/cuda directory cannot be flattened to the same directory + # The header files in include/onnxruntime/core/providers/cuda directory cannot be flattened to the same directory # with onnxruntime_c_api.h . Most other EPs probably also do not work in this way. if((NOT f STREQUAL cuda) AND (NOT f STREQUAL rocm)) file(GLOB _provider_headers CONFIGURE_DEPENDS @@ -73,115 +73,122 @@ add_custom_command(OUTPUT ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_s add_custom_target(onnxruntime_generate_def ALL DEPENDS ${SYMBOL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c) endif() -if(WIN32) - onnxruntime_add_shared_library(onnxruntime - ${SYMBOL_FILE} - "${ONNXRUNTIME_ROOT}/core/dll/dllmain.cc" - "${ONNXRUNTIME_ROOT}/core/dll/onnxruntime.rc" - ) -elseif(onnxruntime_BUILD_APPLE_FRAMEWORK) - # apple framework requires the header file be part of the library - onnxruntime_add_shared_library(onnxruntime - ${ONNXRUNTIME_PUBLIC_HEADERS} - "${CMAKE_CURRENT_BINARY_DIR}/generated_source.c" - ) - # create Info.plist for the framework and podspec for CocoaPods (optional) - set(MACOSX_FRAMEWORK_NAME "onnxruntime") - set(MACOSX_FRAMEWORK_IDENTIFIER "com.microsoft.onnxruntime") - # Need to include CoreML as a weaklink for CocoaPods package if the EP is enabled - if(onnxruntime_USE_COREML) - set(APPLE_WEAK_FRAMEWORK "\\\"CoreML\\\"") +if (onnxruntime_BUILD_SHARED_LIB) + if(WIN32) + onnxruntime_add_shared_library(onnxruntime + ${SYMBOL_FILE} + "${ONNXRUNTIME_ROOT}/core/dll/dllmain.cc" + "${ONNXRUNTIME_ROOT}/core/dll/onnxruntime.rc" + ) + elseif(onnxruntime_BUILD_APPLE_FRAMEWORK) + # apple framework requires the header file be part of the library + onnxruntime_add_shared_library(onnxruntime + ${ONNXRUNTIME_PUBLIC_HEADERS} + "${CMAKE_CURRENT_BINARY_DIR}/generated_source.c" + ) + + # create Info.plist for the framework and podspec for CocoaPods (optional) + set(MACOSX_FRAMEWORK_NAME "onnxruntime") + set(MACOSX_FRAMEWORK_IDENTIFIER "com.microsoft.onnxruntime") + # Need to include CoreML as a weaklink for CocoaPods package if the EP is enabled + if(onnxruntime_USE_COREML) + set(APPLE_WEAK_FRAMEWORK "\\\"CoreML\\\"") + endif() + set(INFO_PLIST_PATH "${CMAKE_CURRENT_BINARY_DIR}/Info.plist") + configure_file(${REPO_ROOT}/cmake/Info.plist.in ${INFO_PLIST_PATH}) + configure_file( + ${REPO_ROOT}/tools/ci_build/github/apple/framework_info.json.template + ${CMAKE_CURRENT_BINARY_DIR}/framework_info.json) + set_target_properties(onnxruntime PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION A + MACOSX_FRAMEWORK_INFO_PLIST ${INFO_PLIST_PATH} + # Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file. + ) + else() + if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") + onnxruntime_add_shared_library(onnxruntime ${ONNXRUNTIME_ROOT}/core/session/onnxruntime_c_api.cc) + else() + onnxruntime_add_shared_library(onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c ) + endif() + if (onnxruntime_USE_CUDA) + set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker -rpath=\\$ORIGIN") + endif() endif() - set(INFO_PLIST_PATH "${CMAKE_CURRENT_BINARY_DIR}/Info.plist") - configure_file(${REPO_ROOT}/cmake/Info.plist.in ${INFO_PLIST_PATH}) - configure_file( - ${REPO_ROOT}/tools/ci_build/github/apple/framework_info.json.template - ${CMAKE_CURRENT_BINARY_DIR}/framework_info.json) - set_target_properties(onnxruntime PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION A - MACOSX_FRAMEWORK_INFO_PLIST ${INFO_PLIST_PATH} - # Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file. - ) -else() + if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") - onnxruntime_add_shared_library(onnxruntime ${ONNXRUNTIME_ROOT}/core/session/onnxruntime_c_api.cc) + add_dependencies(onnxruntime ${onnxruntime_EXTERNAL_DEPENDENCIES}) else() - onnxruntime_add_shared_library(onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c ) - endif() - if (onnxruntime_USE_CUDA) - set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker -rpath=\\$ORIGIN") + add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES}) endif() -endif() - -if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") - add_dependencies(onnxruntime ${onnxruntime_EXTERNAL_DEPENDENCIES}) -else() - add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES}) -endif() -target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$") + target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$") -target_compile_definitions(onnxruntime PRIVATE FILE_NAME=\"onnxruntime.dll\") + target_compile_definitions(onnxruntime PRIVATE FILE_NAME=\"onnxruntime.dll\") -if(UNIX) - if (APPLE) - set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker -dead_strip") - elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX") - set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker --version-script=${SYMBOL_FILE} -Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack") + if(UNIX) + if (APPLE) + set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker -dead_strip") + elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker --version-script=${SYMBOL_FILE} -Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack") + endif() + else() + set(ONNXRUNTIME_SO_LINK_FLAG " -DEF:${SYMBOL_FILE}") endif() -else() - set(ONNXRUNTIME_SO_LINK_FLAG " -DEF:${SYMBOL_FILE}") -endif() -if (NOT WIN32) - if (APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "^iOS") - set(ONNXRUNTIME_SO_LINK_FLAG " -Wl,-exported_symbols_list,${SYMBOL_FILE}") - if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") - set_target_properties(onnxruntime PROPERTIES - MACOSX_RPATH TRUE - INSTALL_RPATH_USE_LINK_PATH FALSE - BUILD_WITH_INSTALL_NAME_DIR TRUE - INSTALL_NAME_DIR @rpath) - else() - set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "@loader_path") + if (NOT WIN32) + if (APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "^iOS") + set(ONNXRUNTIME_SO_LINK_FLAG " -Wl,-exported_symbols_list,${SYMBOL_FILE}") + if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") + set_target_properties(onnxruntime PROPERTIES + MACOSX_RPATH TRUE + INSTALL_RPATH_USE_LINK_PATH FALSE + BUILD_WITH_INSTALL_NAME_DIR TRUE + INSTALL_NAME_DIR @rpath) + else() + set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "@loader_path") + endif() + elseif (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'") endif() - elseif (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'") endif() -endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_MINIMAL_BUILD) - # target onnxruntime is a shared library, the dummy __cxa_demangle is only attach to it to avoid - # affecting downstream ort library users with the behavior of dummy __cxa_demangle. So the dummy - # __cxa_demangle must not expose to libonnxruntime_common.a. It works as when the linker is - # creating the DSO, our dummy __cxa_demangle always comes before libc++abi.a so the - # __cxa_demangle in libc++abi.a is discarded, thus, huge binary size reduction. - target_sources(onnxruntime PRIVATE "${ONNXRUNTIME_ROOT}/core/platform/android/cxa_demangle.cc") - target_compile_definitions(onnxruntime PRIVATE USE_DUMMY_EXA_DEMANGLE=1) -endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_MINIMAL_BUILD) + # target onnxruntime is a shared library, the dummy __cxa_demangle is only attach to it to avoid + # affecting downstream ort library users with the behavior of dummy __cxa_demangle. So the dummy + # __cxa_demangle must not expose to libonnxruntime_common.a. It works as when the linker is + # creating the DSO, our dummy __cxa_demangle always comes before libc++abi.a so the + # __cxa_demangle in libc++abi.a is discarded, thus, huge binary size reduction. + target_sources(onnxruntime PRIVATE "${ONNXRUNTIME_ROOT}/core/platform/android/cxa_demangle.cc") + target_compile_definitions(onnxruntime PRIVATE USE_DUMMY_EXA_DEMANGLE=1) + endif() -# strip binary on Android, or for a minimal build on Unix -if(CMAKE_SYSTEM_NAME STREQUAL "Android" OR (onnxruntime_MINIMAL_BUILD AND UNIX)) - if (onnxruntime_MINIMAL_BUILD AND ADD_DEBUG_INFO_TO_MINIMAL_BUILD) - # don't strip - else() - set_target_properties(onnxruntime PROPERTIES LINK_FLAGS_RELEASE -s) - set_target_properties(onnxruntime PROPERTIES LINK_FLAGS_MINSIZEREL -s) + # strip binary on Android, or for a minimal build on Unix + if(CMAKE_SYSTEM_NAME STREQUAL "Android" OR (onnxruntime_MINIMAL_BUILD AND UNIX)) + if (onnxruntime_MINIMAL_BUILD AND ADD_DEBUG_INFO_TO_MINIMAL_BUILD) + # don't strip + else() + set_target_properties(onnxruntime PROPERTIES LINK_FLAGS_RELEASE -s) + set_target_properties(onnxruntime PROPERTIES LINK_FLAGS_MINSIZEREL -s) + endif() + endif() + + # we need to copy C/C++ API headers to be packed into Android AAR package + if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA) + set(ANDROID_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/android/headers) + file(MAKE_DIRECTORY ${ANDROID_HEADERS_DIR}) + # copy the header files one by one + foreach(h_ ${ONNXRUNTIME_PUBLIC_HEADERS}) + get_filename_component(HEADER_NAME_ ${h_} NAME) + add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${ANDROID_HEADERS_DIR}/${HEADER_NAME_}) + endforeach() endif() endif() -# we need to copy C/C++ API headers to be packed into Android AAR package -if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA) - set(ANDROID_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/android/headers) - file(MAKE_DIRECTORY ${ANDROID_HEADERS_DIR}) - # copy the header files one by one - foreach(h_ ${ONNXRUNTIME_PUBLIC_HEADERS}) - get_filename_component(HEADER_NAME_ ${h_} NAME) - add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${ANDROID_HEADERS_DIR}/${HEADER_NAME_}) - endforeach() +if (NOT onnxruntime_BUILD_SHARED_LIB) +add_library(onnxruntime INTERFACE) endif() # This list is a reversed topological ordering of library dependencies. @@ -229,10 +236,17 @@ endif() # If you are linking a new library, please add it to the list onnxruntime_INTERNAL_LIBRARIES or onnxruntime_EXTERNAL_LIBRARIES, # Please do not add a library directly to the target_link_libraries command -target_link_libraries(onnxruntime PRIVATE - ${onnxruntime_INTERNAL_LIBRARIES} - ${onnxruntime_EXTERNAL_LIBRARIES} +if (onnxruntime_BUILD_SHARED_LIB) + target_link_libraries(onnxruntime PRIVATE + ${onnxruntime_INTERNAL_LIBRARIES} + ${onnxruntime_EXTERNAL_LIBRARIES} + ) +else() +target_link_libraries(onnxruntime INTERFACE +${onnxruntime_INTERNAL_LIBRARIES} +${onnxruntime_EXTERNAL_LIBRARIES} ) +endif() 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 diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index 896379d743441..b419e44083624 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -218,7 +218,7 @@ endif() if (NOT onnxruntime_BUILD_SHARED_LIB) install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/common DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core) - install(TARGETS onnxruntime_common + install(TARGETS onnxruntime_common EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_flatbuffers.cmake b/cmake/onnxruntime_flatbuffers.cmake index 3ab4c19122ba1..066fb561de57d 100644 --- a/cmake/onnxruntime_flatbuffers.cmake +++ b/cmake/onnxruntime_flatbuffers.cmake @@ -22,10 +22,9 @@ if (FLATBUFFERS_BUILD_FLATC) add_dependencies(onnxruntime_flatbuffers flatc) endif() if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_flatbuffers + install(TARGETS onnxruntime_flatbuffers EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() - diff --git a/cmake/onnxruntime_framework.cmake b/cmake/onnxruntime_framework.cmake index 9f8d807fad8f4..94450c6c61d13 100644 --- a/cmake/onnxruntime_framework.cmake +++ b/cmake/onnxruntime_framework.cmake @@ -69,9 +69,9 @@ endif() if(onnxruntime_USE_TENSORRT OR onnxruntime_USE_NCCL) # TODO: for now, core framework depends on CUDA. It should be moved to TensorRT EP # TODO: provider_bridge_ort.cc should not include nccl.h -target_include_directories(onnxruntime_framework PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) +target_include_directories(onnxruntime_framework PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) else() -target_include_directories(onnxruntime_framework PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(onnxruntime_framework PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) endif() # Needed for the provider interface, as it includes training headers when training is enabled if (onnxruntime_ENABLE_TRAINING_OPS) @@ -127,7 +127,7 @@ if (onnxruntime_BUILD_SHARED_LIB) install(FILES ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/framework/provider_options.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/) else() install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/framework DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core) - install(TARGETS onnxruntime_framework + install(TARGETS onnxruntime_framework EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_graph.cmake b/cmake/onnxruntime_graph.cmake index 4d51325b8414e..fba1a680bb62a 100644 --- a/cmake/onnxruntime_graph.cmake +++ b/cmake/onnxruntime_graph.cmake @@ -157,7 +157,7 @@ endif() if (NOT onnxruntime_BUILD_SHARED_LIB) install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/graph DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core) - install(TARGETS onnxruntime_graph + install(TARGETS onnxruntime_graph EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake index e35c83ba45952..34050ea7701cf 100644 --- a/cmake/onnxruntime_mlas.cmake +++ b/cmake/onnxruntime_mlas.cmake @@ -699,7 +699,7 @@ if (PLATFORM_NAME STREQUAL "macabi") endif() if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_mlas + install(TARGETS onnxruntime_mlas EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_optimizer.cmake b/cmake/onnxruntime_optimizer.cmake index 3bae1b8a48e0f..8764a8a369c47 100644 --- a/cmake/onnxruntime_optimizer.cmake +++ b/cmake/onnxruntime_optimizer.cmake @@ -127,7 +127,7 @@ set_target_properties(onnxruntime_optimizer PROPERTIES FOLDER "ONNXRuntime") if (NOT onnxruntime_BUILD_SHARED_LIB) install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/optimizer DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core) - install(TARGETS onnxruntime_optimizer + install(TARGETS onnxruntime_optimizer EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_providers_acl.cmake b/cmake/onnxruntime_providers_acl.cmake index e23d2892713fc..7670e032a5417 100644 --- a/cmake/onnxruntime_providers_acl.cmake +++ b/cmake/onnxruntime_providers_acl.cmake @@ -26,9 +26,9 @@ set_target_properties(onnxruntime_providers_acl PROPERTIES LINKER_LANGUAGE CXX) if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_acl + install(TARGETS onnxruntime_providers_acl EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() \ No newline at end of file + endif() diff --git a/cmake/onnxruntime_providers_armnn.cmake b/cmake/onnxruntime_providers_armnn.cmake index 33fadb7c64c2e..c7f6e7bad3e7f 100644 --- a/cmake/onnxruntime_providers_armnn.cmake +++ b/cmake/onnxruntime_providers_armnn.cmake @@ -25,9 +25,9 @@ set_target_properties(onnxruntime_providers_armnn PROPERTIES LINKER_LANGUAGE CXX) if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_armnn + install(TARGETS onnxruntime_providers_armnn EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() \ No newline at end of file + endif() diff --git a/cmake/onnxruntime_providers_coreml.cmake b/cmake/onnxruntime_providers_coreml.cmake index 0aa25a221bf27..72785c61af639 100644 --- a/cmake/onnxruntime_providers_coreml.cmake +++ b/cmake/onnxruntime_providers_coreml.cmake @@ -214,7 +214,7 @@ target_include_directories(onnxruntime_providers_coreml PRIVATE ${ONNXRUNTIME_RO set_target_properties(onnxruntime_providers_coreml PROPERTIES LINKER_LANGUAGE CXX) if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_coreml + install(TARGETS onnxruntime_providers_coreml EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_providers_cpu.cmake b/cmake/onnxruntime_providers_cpu.cmake index bbcc709b144a0..da7f9c0ce188e 100644 --- a/cmake/onnxruntime_providers_cpu.cmake +++ b/cmake/onnxruntime_providers_cpu.cmake @@ -60,7 +60,7 @@ if(NOT onnxruntime_DISABLE_CONTRIB_OPS) "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/aten_ops/aten_op_executor.cc" ) endif() - set(onnxruntime_cpu_neural_speed_srcs + set(onnxruntime_cpu_neural_speed_srcs "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/quantization/neural_speed_wrapper.h" "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/quantization/neural_speed_defs.h" "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/quantization/neural_speed_gemm.cc" @@ -266,7 +266,7 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD endif() if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers + install(TARGETS onnxruntime_providers EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_providers_dml.cmake b/cmake/onnxruntime_providers_dml.cmake index 439be882dcc5e..9e96e14b7c4c9 100644 --- a/cmake/onnxruntime_providers_dml.cmake +++ b/cmake/onnxruntime_providers_dml.cmake @@ -83,7 +83,7 @@ set_target_properties(onnxruntime_providers_dml PROPERTIES FOLDER "ONNXRuntime") if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_dml + install(TARGETS onnxruntime_providers_dml EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_providers_nnapi.cmake b/cmake/onnxruntime_providers_nnapi.cmake index b718a976eb26f..06364ebd49593 100644 --- a/cmake/onnxruntime_providers_nnapi.cmake +++ b/cmake/onnxruntime_providers_nnapi.cmake @@ -74,7 +74,7 @@ endif() if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_nnapi + install(TARGETS onnxruntime_providers_nnapi EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_providers_rknpu.cmake b/cmake/onnxruntime_providers_rknpu.cmake index 408bcfde06c36..831df84aa6e08 100644 --- a/cmake/onnxruntime_providers_rknpu.cmake +++ b/cmake/onnxruntime_providers_rknpu.cmake @@ -36,9 +36,9 @@ set_target_properties(onnxruntime_providers_rknpu PROPERTIES LINKER_LANGUAGE CXX) if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_rknpu + install(TARGETS onnxruntime_providers_rknpu EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() \ No newline at end of file + endif() diff --git a/cmake/onnxruntime_providers_tvm.cmake b/cmake/onnxruntime_providers_tvm.cmake index 8fd50c70dd5d7..7f2304ce57bcc 100644 --- a/cmake/onnxruntime_providers_tvm.cmake +++ b/cmake/onnxruntime_providers_tvm.cmake @@ -56,9 +56,9 @@ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/) if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_tvm + install(TARGETS onnxruntime_providers_tvm EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() \ No newline at end of file + endif() diff --git a/cmake/onnxruntime_providers_xnnpack.cmake b/cmake/onnxruntime_providers_xnnpack.cmake index 796536ac9d12b..1fbe553fa58a0 100644 --- a/cmake/onnxruntime_providers_xnnpack.cmake +++ b/cmake/onnxruntime_providers_xnnpack.cmake @@ -28,7 +28,7 @@ set_target_properties(onnxruntime_providers_xnnpack PROPERTIES LINKER_LANGUAGE CXX) if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_providers_xnnpack + install(TARGETS onnxruntime_providers_xnnpack EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_session.cmake b/cmake/onnxruntime_session.cmake index b51c875951135..3f1acaae3cad7 100644 --- a/cmake/onnxruntime_session.cmake +++ b/cmake/onnxruntime_session.cmake @@ -61,7 +61,7 @@ endif() if (NOT onnxruntime_BUILD_SHARED_LIB) install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/session DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core) - install(TARGETS onnxruntime_session + install(TARGETS onnxruntime_session EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cmake/onnxruntime_util.cmake b/cmake/onnxruntime_util.cmake index ae7e842f223d6..c3234f6bb4173 100644 --- a/cmake/onnxruntime_util.cmake +++ b/cmake/onnxruntime_util.cmake @@ -9,7 +9,8 @@ file(GLOB_RECURSE onnxruntime_util_srcs CONFIGURE_DEPENDS source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_util_srcs}) onnxruntime_add_static_library(onnxruntime_util ${onnxruntime_util_srcs}) -target_include_directories(onnxruntime_util PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC ${eigen_INCLUDE_DIRS}) +target_link_libraries(onnxruntime_util PUBLIC Eigen3::Eigen) +target_include_directories(onnxruntime_util PRIVATE ${ONNXRUNTIME_ROOT}) onnxruntime_add_include_to_target(onnxruntime_util onnxruntime_common onnx onnx_proto ${PROTOBUF_LIB} Boost::mp11) if(UNIX) target_compile_options(onnxruntime_util PUBLIC "-Wno-error=comment") @@ -22,7 +23,7 @@ if (WIN32) endif() if (NOT onnxruntime_BUILD_SHARED_LIB) - install(TARGETS onnxruntime_util + install(TARGETS onnxruntime_util EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}