From bbebf048bb3595855fbda46590e086240f4241bb Mon Sep 17 00:00:00 2001 From: Jordan Zangara Date: Wed, 16 Oct 2024 14:19:35 -0400 Subject: [PATCH] Apply fixes based on CI logs onnxruntime_providers_qnn needs to be exported for static builds. ABSL_ENABLE_INSTALL option conflicts with using XNNPACK. Static builds with training enabled were failing because of missing tensorboard exports. As tensorboard has no CMake scripts, add them. --- cmake/external/abseil-cpp.cmake | 9 ++++++++- cmake/onnxruntime_providers_qnn.cmake | 8 ++++++++ cmake/tensorboard/compat/proto/CMakeLists.txt | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cmake/external/abseil-cpp.cmake b/cmake/external/abseil-cpp.cmake index 10dbed8368b4a..93a5e5e0d2da0 100644 --- a/cmake/external/abseil-cpp.cmake +++ b/cmake/external/abseil-cpp.cmake @@ -9,7 +9,14 @@ set(BUILD_TESTING 0) set(ABSL_BUILD_TESTING OFF) set(ABSL_BUILD_TEST_HELPERS OFF) set(ABSL_USE_EXTERNAL_GOOGLETEST ON) -set(ABSL_ENABLE_INSTALL ON) + +# Both abseil and xnnpack create a target called memory, which +# results in a duplicate target if ABSL_ENABLE_INSTALL is on. +if (onnxruntime_USE_XNNPACK) + set(ABSL_ENABLE_INSTALL OFF) +else() + set(ABSL_ENABLE_INSTALL ON) +endif() if(Patch_FOUND AND WIN32) set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch) diff --git a/cmake/onnxruntime_providers_qnn.cmake b/cmake/onnxruntime_providers_qnn.cmake index b68d84c23bb32..f0116c130a5b2 100644 --- a/cmake/onnxruntime_providers_qnn.cmake +++ b/cmake/onnxruntime_providers_qnn.cmake @@ -41,3 +41,11 @@ if(NOT MSVC) target_compile_options(onnxruntime_providers_qnn PRIVATE "-Wno-unknown-pragmas") endif() + +if (NOT onnxruntime_BUILD_SHARED_LIB) + install(TARGETS onnxruntime_providers_qnn 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/tensorboard/compat/proto/CMakeLists.txt b/cmake/tensorboard/compat/proto/CMakeLists.txt index ad31e4062a8a4..addc3779e9521 100644 --- a/cmake/tensorboard/compat/proto/CMakeLists.txt +++ b/cmake/tensorboard/compat/proto/CMakeLists.txt @@ -23,3 +23,10 @@ add_dependencies(tensorboard ${onnxruntime_EXTERNAL_DEPENDENCIES}) if(WIN32) target_compile_options(tensorboard PRIVATE "/wd4100" "/wd4125" "/wd4127" "/wd4267" "/wd4456" "/wd4800" "/wd6011" "/wd6387" "/wd28182") endif() + +if (NOT onnxruntime_BUILD_SHARED_LIB) + install(TARGETS tensorboard EXPORT ${PROJECT_NAME}Targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif()