From 2279df5f09a2662e7ce05370413ae0c633cfea2f Mon Sep 17 00:00:00 2001 From: Vihang Mehta Date: Mon, 18 Nov 2024 16:48:29 -0800 Subject: [PATCH] Provide TBB/MLAS/oneDNN externally Signed-off-by: Vihang Mehta --- cmake/developer_package/target_flags.cmake | 2 +- cmake/templates/OpenVINOConfig.cmake.in | 5 ++++- src/plugins/intel_cpu/CMakeLists.txt | 4 ++-- src/plugins/intel_cpu/thirdparty/CMakeLists.txt | 7 ++++--- thirdparty/dependencies.cmake | 6 +++++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmake/developer_package/target_flags.cmake b/cmake/developer_package/target_flags.cmake index 6666e349315ae3..47765ee2832c6a 100644 --- a/cmake/developer_package/target_flags.cmake +++ b/cmake/developer_package/target_flags.cmake @@ -231,7 +231,7 @@ ov_libc_version() # macro(ov_get_glibcxx_use_cxx11_abi) if(LINUX AND OPENVINO_STDLIB STREQUAL "GNU") - ov_get_compiler_definition("_GLIBCXX_USE_CXX11_ABI" OV_GLIBCXX_USE_CXX11_ABI) + set(OV_GLIBCXX_USE_CXX11_ABI "1" PARENT_SCOPE) endif() endmacro() diff --git a/cmake/templates/OpenVINOConfig.cmake.in b/cmake/templates/OpenVINOConfig.cmake.in index c65bb8f44da339..b85eab60ba7b3e 100644 --- a/cmake/templates/OpenVINOConfig.cmake.in +++ b/cmake/templates/OpenVINOConfig.cmake.in @@ -214,7 +214,10 @@ macro(_ov_find_tbb) set(enable_system_tbb "@ENABLE_SYSTEM_TBB@") if(NOT enable_system_tbb) - set_and_check(_tbb_dir "@PACKAGE_OV_TBB_DIR@") + # [GML] Because bazel builds in a build_tmpdir, the TBB path is wrong. + # [GML] This is a hack to fix-up the path. + string(REPLACE ".build_tmpdir" "" _gml_package_ie_tbb_dir "@PACKAGE_OV_TBB_DIR@") + set_and_check(_tbb_dir ${_gml_package_ie_tbb_dir}) # see https://stackoverflow.com/questions/28070810/cmake-generate-error-on-windows-as-it-uses-as-escape-seq if(DEFINED ENV{TBBROOT}) diff --git a/src/plugins/intel_cpu/CMakeLists.txt b/src/plugins/intel_cpu/CMakeLists.txt index 2efe8554f02590..5f5d50a7325208 100644 --- a/src/plugins/intel_cpu/CMakeLists.txt +++ b/src/plugins/intel_cpu/CMakeLists.txt @@ -258,7 +258,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE dnnl target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) if (ENABLE_MLAS_FOR_CPU) target_link_libraries(${TARGET_NAME} PRIVATE mlas) - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $) + target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${MLAS_INCLUDE_DIRS}) add_definitions(-DOV_CPU_WITH_MLAS) endif() if (ENABLE_SNIPPETS_LIBXSMM_TPP) @@ -269,7 +269,7 @@ endif () if(ENABLE_SHL_FOR_CPU) target_link_libraries(${TARGET_NAME} PRIVATE shl) endif() -target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $) +target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${DNNL_INCLUDE_DIRS}) # Temporal solution to use template reference implementations in cases where optimizied implementation # is not (yet) needed. diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt index 6f5f7a93e932dc..7035857ec6e990 100644 --- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt @@ -162,8 +162,8 @@ if (ENABLE_SNIPPETS_LIBXSMM_TPP) endif() if(ENABLE_MLAS_FOR_CPU) - add_subdirectory(mlas) - ov_install_static_lib(mlas ${OV_CPACK_COMP_CORE}) + include_directories(${MLAS_INCLUDE_DIRS}) + link_directories(${MLAS_LIBRARY_DIRS}) endif() if(ENABLE_SHL_FOR_CPU) @@ -171,4 +171,5 @@ if(ENABLE_SHL_FOR_CPU) ov_install_static_lib(shl ${OV_CPACK_COMP_CORE}) endif() -ov_add_onednn() +include_directories(${DNNL_INCLUDE_DIRS}) +link_directories(${DNNL_LIBRARY_DIRS}) diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake index 9d7b16aeb8bdb2..4e41529b98ff84 100644 --- a/thirdparty/dependencies.cmake +++ b/thirdparty/dependencies.cmake @@ -479,7 +479,7 @@ endif() # if(ENABLE_OV_ONNX_FRONTEND) - find_package(ONNX 1.15.0 QUIET COMPONENTS onnx onnx_proto NO_MODULE) + find_package(ONNX QUIET COMPONENTS onnx onnx_proto NO_MODULE) if(ONNX_FOUND) # conan and vcpkg create imported targets 'onnx' and 'onnx_proto' @@ -518,6 +518,7 @@ endif() # Install # +if(ENABLE_SAMPLES OR ENABLE_TESTS) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES} @@ -538,7 +539,9 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags PATTERN .travis.yml EXCLUDE PATTERN src/gflags_completions.sh EXCLUDE PATTERN WORKSPACE EXCLUDE) +endif() +if(ENABLE_SAMPLES) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/json/nlohmann_json DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES} @@ -563,6 +566,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/json/nlohmann_json PATTERN tools EXCLUDE PATTERN WORKSPACE.bazel EXCLUDE PATTERN wsjcpp.yml EXCLUDE) +endif() # restore state