logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

onnxruntime-1.9.1-system_libs.patch (3196B)


  1. diff --git a/CMakeLists.txt.old b/CMakeLists.txt
  2. index 2534b99..d144047 100644
  3. --- a/CMakeLists.txt.old
  4. +++ b/CMakeLists.txt
  5. @@ -540,7 +540,7 @@ if (MSVC)
  6. set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /safeseh")
  7. endif()
  8. endif()
  9. -
  10. +
  11. #Always enable exception handling, even for Windows ARM
  12. if(NOT onnxruntime_DISABLE_EXCEPTIONS)
  13. @@ -833,7 +833,13 @@ get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE)
  14. get_filename_component(REPO_ROOT "${REPO_ROOT}" ABSOLUTE)
  15. set(ONNXRUNTIME_INCLUDE_DIR ${REPO_ROOT}/include/onnxruntime)
  16. -add_subdirectory(external/date EXCLUDE_FROM_ALL)
  17. +if(onnxruntime_PREFER_SYSTEM_LIB)
  18. + find_package(date REQUIRED)
  19. + add_library(date_interface ALIAS date::date)
  20. +endif()
  21. +if(NOT TARGET date::date)
  22. + add_subdirectory(external/date EXCLUDE_FROM_ALL)
  23. +endif()
  24. set(SAFEINT_INCLUDE_DIR ${REPO_ROOT}/cmake/external/SafeInt)
  25. add_library(safeint_interface INTERFACE)
  26. @@ -844,16 +850,33 @@ if(onnxruntime_DISABLE_EXCEPTIONS)
  27. add_compile_definitions(optional_CONFIG_NO_EXCEPTIONS=1)
  28. endif()
  29. -add_subdirectory(external/mp11 EXCLUDE_FROM_ALL)
  30. +if(onnxruntime_PREFER_SYSTEM_LIB)
  31. + find_package(boost_mp11)
  32. +endif()
  33. +if(NOT TARGET Boost::mp11)
  34. + add_subdirectory(external/mp11 EXCLUDE_FROM_ALL)
  35. +endif()
  36. -set(JSON_BuildTests OFF CACHE INTERNAL "")
  37. -set(JSON_Install OFF CACHE INTERNAL "")
  38. -add_subdirectory(external/json EXCLUDE_FROM_ALL)
  39. +if(onnxruntime_PREFER_SYSTEM_LIB)
  40. + find_package(nlohmann_json REQUIRED)
  41. +endif()
  42. +if(NOT TARGET nlohmann_json::nlohmann_json)
  43. + set(JSON_BuildTests OFF CACHE INTERNAL "")
  44. + set(JSON_Install OFF CACHE INTERNAL "")
  45. + add_subdirectory(external/json EXCLUDE_FROM_ALL)
  46. +endif()
  47. +find_package(PkgConfig)
  48. if(onnxruntime_PREFER_SYSTEM_LIB)
  49. - find_package(re2)
  50. + pkg_check_modules(RE2 re2)
  51. endif()
  52. -if(NOT TARGET re2::re2)
  53. +if(RE2_FOUND)
  54. + add_library(re2::re2 INTERFACE IMPORTED)
  55. + set_target_properties(re2::re2 PROPERTIES
  56. + INTERFACE_COMPILE_OPTIONS "${RE2_CFLAGS}"
  57. + INTERFACE_LINK_LIBRARIES "${RE2_LDFLAGS}"
  58. + )
  59. +else()
  60. add_subdirectory(external/re2 EXCLUDE_FROM_ALL)
  61. set_target_properties(re2 PROPERTIES FOLDER "External/re2")
  62. set(RE2_INCLUDE_DIR ${REPO_ROOT}/cmake/external/re2)
  63. @@ -885,12 +908,12 @@ else()
  64. elseif(WINDOWS_STORE OR (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib))
  65. message(WARNING "Cpuinfo not included in Windows Store or WCOS builds")
  66. set(CPUINFO_SUPPORTED FALSE)
  67. - endif()
  68. + endif()
  69. elseif(NOT ${onnxruntime_target_platform} MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
  70. message(WARNING
  71. "Target processor architecture \"${onnxruntime_target_platform}\" is not supported in cpuinfo. "
  72. "cpuinfo not included.")
  73. - set(CPUINFO_SUPPORTED FALSE)
  74. + set(CPUINFO_SUPPORTED FALSE)
  75. endif()
  76. endif()
  77. @@ -907,7 +930,7 @@ if(CPUINFO_SUPPORTED)
  78. set(IOS ON CACHE INTERNAL "")
  79. set(IOS_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE INTERNAL "")
  80. endif()
  81. -
  82. +
  83. string(APPEND CMAKE_CXX_FLAGS " -DCPUINFO_SUPPORTED")
  84. add_subdirectory(external/pytorch_cpuinfo EXCLUDE_FROM_ALL)
  85. if(MSVC)