From 3ec084074aa0b9d2510ae349fabc8309a8100a9e Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 1 Dec 2022 23:57:23 +0400 Subject: [PATCH] RPM packages improvements: part 2 (#14306) * Updated install_dependencies.sh * Added Fedora support * Improvements for RPM generation * Refactored work with gflags * Apply suggestions from code review * Improvements * Several improvements for Ubuntu 18.04 * Improvements in gflags * Update thirdparty/CMakeLists.txt temporary install samples dependencies * Fixed several mistakes * Fixed issues with gflags * Don't install dependencies on Linux * Added nlohmann findinds on debian9 case * Added FATAL_ERROR is gflags is not found in samples * Fixes for samples on CentOS 7 * Cross-compiled debian packakges with proper libraries location * Fixed include for old nlohman-json versions * Fixed compilation with old json * Applied review comments * Added support of old nlohmann versions via submodule * Temporary WA for CentOS 7 * Fixed compilation with old gflags * Fixed compilation of C samples * Fixed gflags on RHEL8.2 / Debian 9 --- cmake/developer_package/linux_name.cmake | 19 +-- .../packaging/debian/debian.cmake | 23 ++- .../packaging/packaging.cmake | 2 +- .../packaging/rpm/post_build.cmake | 4 +- .../developer_package/packaging/rpm/rpm.cmake | 4 +- cmake/packaging/rpm.cmake | 16 +- install_build_dependencies.sh | 2 +- samples/cpp/CMakeLists.txt | 59 +++---- samples/cpp/benchmark_app/CMakeLists.txt | 30 +++- .../cpp/benchmark_app/statistics_report.hpp | 7 +- samples/cpp/benchmark_app/utils.cpp | 28 +++- samples/cpp/common/utils/CMakeLists.txt | 2 +- .../install_openvino_dependencies.sh | 144 +++++++++++------- .../intel_gpu/tests/gtest_main_gpu.cpp | 2 +- thirdparty/CMakeLists.txt | 49 +++--- 15 files changed, 248 insertions(+), 143 deletions(-) diff --git a/cmake/developer_package/linux_name.cmake b/cmake/developer_package/linux_name.cmake index d3a4f949395..5903f9550e5 100644 --- a/cmake/developer_package/linux_name.cmake +++ b/cmake/developer_package/linux_name.cmake @@ -6,18 +6,19 @@ include(target_flags) if (LINUX) function(get_linux_name res_var) - if (NOT EXISTS "/etc/lsb-release") - execute_process(COMMAND find -L /etc/ -maxdepth 1 -type f -name *-release -exec cat {} \; - OUTPUT_VARIABLE release_data RESULT_VARIABLE result) - string(REPLACE "Red Hat" "CentOS" release_data "${release_data}") - set(name_regex "NAME=\"([^ \"\n]*).*\"\n") - set(version_regex "VERSION=\"([0-9]+(\\.[0-9]+)?)[^\n]*\"") - else () + if (EXISTS "/etc/lsb-release") # linux version detection using cat /etc/lsb-release file(READ "/etc/lsb-release" release_data) set(name_regex "DISTRIB_ID=([^ \n]*)\n") set(version_regex "DISTRIB_RELEASE=([0-9]+(\\.[0-9]+)?)") - endif () + else() + execute_process(COMMAND find -L /etc/ -maxdepth 1 -type f -name *-release -exec cat {} \; + OUTPUT_VARIABLE release_data + RESULT_VARIABLE result) + string(REPLACE "Red Hat" "CentOS" release_data "${release_data}") + set(name_regex "NAME=\"([^ \"\n]*).*\"\n") + set(version_regex "VERSION=\"([0-9]+(\\.[0-9]+)?)[^\n]*\"") + endif() string(REGEX MATCH ${name_regex} name ${release_data}) set(os_name ${CMAKE_MATCH_1}) @@ -25,7 +26,7 @@ if (LINUX) string(REGEX MATCH ${version_regex} version ${release_data}) set(os_name "${os_name} ${CMAKE_MATCH_1}") - if (os_name) + if(os_name) set(${res_var} ${os_name} PARENT_SCOPE) else () set(${res_var} NOTFOUND PARENT_SCOPE) diff --git a/cmake/developer_package/packaging/debian/debian.cmake b/cmake/developer_package/packaging/debian/debian.cmake index 34e18ce088d..735160b4694 100644 --- a/cmake/developer_package/packaging/debian/debian.cmake +++ b/cmake/developer_package/packaging/debian/debian.cmake @@ -13,14 +13,23 @@ macro(ov_debian_cpack_set_dirs) # override default locations for Debian set(OV_CPACK_TOOLSDIR ${CMAKE_INSTALL_BINDIR}) # only C++ tools are here set(OV_CPACK_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) - set(OV_CPACK_LIBRARYDIR ${CMAKE_INSTALL_LIBDIR}) set(OV_CPACK_RUNTIMEDIR ${CMAKE_INSTALL_LIBDIR}) + if(CMAKE_CROSSCOMPILING) + if(ARM) + set(OV_CPACK_RUNTIMEDIR "${OV_CPACK_RUNTIMEDIR}/arm-linux-gnueabihf") + elseif(AARCH64) + set(OV_CPACK_RUNTIMEDIR "${OV_CPACK_RUNTIMEDIR}/aarch64-linux-gnu") + elseif(X86) + set(OV_CPACK_RUNTIMEDIR "${OV_CPACK_RUNTIMEDIR}/i386-linux-gnu") + endif() + endif() + set(OV_CPACK_LIBRARYDIR ${OV_CPACK_RUNTIMEDIR}) set(OV_WHEEL_RUNTIMEDIR ${OV_CPACK_RUNTIMEDIR}) - set(OV_CPACK_ARCHIVEDIR ${CMAKE_INSTALL_LIBDIR}) - set(OV_CPACK_PLUGINSDIR ${CMAKE_INSTALL_LIBDIR}/openvino-${OpenVINO_VERSION}) - set(OV_CPACK_IE_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/inferenceengine${OpenVINO_VERSION}) - set(OV_CPACK_NGRAPH_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/ngraph${OpenVINO_VERSION}) - set(OV_CPACK_OPENVINO_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/openvino${OpenVINO_VERSION}) + set(OV_CPACK_ARCHIVEDIR ${OV_CPACK_RUNTIMEDIR}) + set(OV_CPACK_PLUGINSDIR ${OV_CPACK_RUNTIMEDIR}/openvino-${OpenVINO_VERSION}) + set(OV_CPACK_IE_CMAKEDIR ${OV_CPACK_RUNTIMEDIR}/cmake/inferenceengine${OpenVINO_VERSION}) + set(OV_CPACK_NGRAPH_CMAKEDIR ${OV_CPACK_RUNTIMEDIR}/cmake/ngraph${OpenVINO_VERSION}) + set(OV_CPACK_OPENVINO_CMAKEDIR ${OV_CPACK_RUNTIMEDIR}/cmake/openvino${OpenVINO_VERSION}) set(OV_CPACK_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc/openvino-${OpenVINO_VERSION}) set(OV_CPACK_PYTHONDIR lib/python3/dist-packages) @@ -34,7 +43,7 @@ macro(ov_debian_cpack_set_dirs) set(OV_CPACK_WHEELSDIR "tools") # for BW compatibility - set(IE_CPACK_LIBRARY_PATH ${OV_CPACK_LIBRARYDIR}) + set(IE_CPACK_LIBRARY_PATH ${OV_CPACK_RUNTIMEDIR}) set(IE_CPACK_RUNTIME_PATH ${OV_CPACK_RUNTIMEDIR}) set(IE_CPACK_ARCHIVE_PATH ${OV_CPACK_ARCHIVEDIR}) endmacro() diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake index 4125b059285..246cfb981f0 100644 --- a/cmake/developer_package/packaging/packaging.cmake +++ b/cmake/developer_package/packaging/packaging.cmake @@ -171,7 +171,7 @@ macro(ie_cpack) set(CPACK_GENERATOR "TGZ") endif() set(CPACK_SOURCE_GENERATOR "") # not used - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenVINO™ Toolkit for Deep Learning Inference") + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenVINO™ Toolkit") set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED OFF) set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) set(CPACK_PACKAGE_VENDOR "Intel Corporation") diff --git a/cmake/developer_package/packaging/rpm/post_build.cmake b/cmake/developer_package/packaging/rpm/post_build.cmake index f168373f0d3..4fe461de531 100644 --- a/cmake/developer_package/packaging/rpm/post_build.cmake +++ b/cmake/developer_package/packaging/rpm/post_build.cmake @@ -20,7 +20,7 @@ foreach(rpm_file IN LISTS CPACK_PACKAGE_FILES) set(file_option --file "${rpmlint_overrides}") endif() - execute_process(COMMAND "${rpmlint_PROGRAM}" ${file_option} ${rpm_file} + execute_process(COMMAND "${rpmlint_PROGRAM}" --strict ${file_option} ${rpm_file} RESULT_VARIABLE rpmlint_exit_code OUTPUT_VARIABLE rpmlint_output) @@ -29,6 +29,8 @@ foreach(rpm_file IN LISTS CPACK_PACKAGE_FILES) message("${rpmlint_output}") set(rpmlint_passed OFF) endif() + + unset(file_option) endforeach() if(NOT rpmlint_passed) diff --git a/cmake/developer_package/packaging/rpm/rpm.cmake b/cmake/developer_package/packaging/rpm/rpm.cmake index 87bf41702c7..6919b2770cf 100644 --- a/cmake/developer_package/packaging/rpm/rpm.cmake +++ b/cmake/developer_package/packaging/rpm/rpm.cmake @@ -121,7 +121,7 @@ ov_rpm_specific_settings() # needed to add triggers for packages with libraries set(def_triggers "${OpenVINO_BINARY_DIR}/_CPack_Packages/triggers") -set(triggers_content "/sbin/ldconfig\n") +set(triggers_content "# /bin/sh -p\n/sbin/ldconfig\n") file(WRITE "${def_triggers}" "${triggers_content}") # @@ -186,7 +186,7 @@ function(ov_rpm_add_rpmlint_suppression comp) message(FATAL_ERROR "RPM: Unsupported architecture ${CMAKE_SYSTEM_PROCESSOR}") endif() - set(package_file_name "${package_name}-${OpenVINO_VERSION}-1.${arch}.rpm") + set(package_file_name "${package_name}-${CPACK_PACKAGE_VERSION}-1.${arch}.rpm") set(rpmlint_override_file "${OpenVINO_BINARY_DIR}/_CPack_Packages/rpmlint/${package_file_name}.rpmlintrc") file(REMOVE ${rpmlint_override_file}) file(WRITE ${rpmlint_override_file} ${content}) diff --git a/cmake/packaging/rpm.cmake b/cmake/packaging/rpm.cmake index ead326a7cef..6c19c10a4b1 100644 --- a/cmake/packaging/rpm.cmake +++ b/cmake/packaging/rpm.cmake @@ -87,12 +87,14 @@ macro(ov_cpack_settings) execute_process(COMMAND "${rpmlint_PROGRAM}" --version WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" RESULT_VARIABLE rpmlint_code - OUTPUT_VARIABLE rpmlint_version) + OUTPUT_VARIABLE rpmlint_version + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE) if(NOT rpmlint_code EQUAL 0) message(FATAL_ERROR "Internal error: Failed to determine rpmlint version") else() - if(rpmlint_version MATCHES ".*version ([0-9]+\.[0-9]+) Copyright.*") + if(rpmlint_version MATCHES "([0-9]+\.[0-9]+)") set(rpmlint_version "${CMAKE_MATCH_1}") else() message(WARNING "Failed to extract rpmlint version from '${rpmlint_version}'") @@ -201,7 +203,6 @@ macro(ov_cpack_settings) if(ENABLE_OV_IR_FRONTEND) set(CPACK_COMPONENT_IR_DESCRIPTION "OpenVINO IR Frontend") - set(CPACK_RPM_IR_PACKAGE_REQUIRES "${core_package}") set(CPACK_RPM_IR_PACKAGE_NAME "libopenvino-ir-frontend-${cpack_name_ver}") set(CPACK_RPM_IR_POST_INSTALL_SCRIPT_FILE "${def_triggers}") set(CPACK_RPM_IR_POST_UNINSTALL_SCRIPT_FILE "${def_triggers}") @@ -211,7 +212,6 @@ macro(ov_cpack_settings) if(ENABLE_OV_ONNX_FRONTEND) set(CPACK_COMPONENT_ONNX_DESCRIPTION "OpenVINO ONNX Frontend") - set(CPACK_RPM_ONNX_PACKAGE_REQUIRES "${core_package}") set(CPACK_RPM_ONNX_PACKAGE_NAME "libopenvino-onnx-frontend-${cpack_name_ver}") set(CPACK_RPM_ONNX_POST_INSTALL_SCRIPT_FILE "${def_triggers}") set(CPACK_RPM_ONNX_POST_UNINSTALL_SCRIPT_FILE "${def_triggers}") @@ -221,7 +221,6 @@ macro(ov_cpack_settings) if(ENABLE_OV_TF_FRONTEND) set(CPACK_COMPONENT_TENSORFLOW_DESCRIPTION "OpenVINO TensorFlow Frontend") - set(CPACK_RPM_TENSORFLOW_PACKAGE_REQUIRES "${core_package}") set(CPACK_RPM_TENSORFLOW_PACKAGE_NAME "libopenvino-tensorflow-frontend-${cpack_name_ver}") set(CPACK_RPM_TENSORFLOW_POST_INSTALL_SCRIPT_FILE "${def_triggers}") set(CPACK_RPM_TENSORFLOW_POST_UNINSTALL_SCRIPT_FILE "${def_triggers}") @@ -231,7 +230,6 @@ macro(ov_cpack_settings) if(ENABLE_OV_PADDLE_FRONTEND) set(CPACK_COMPONENT_PADDLE_DESCRIPTION "OpenVINO Paddle Frontend") - set(CPACK_RPM_PADDLE_PACKAGE_REQUIRES "${core_package}") set(CPACK_RPM_PADDLE_PACKAGE_NAME "libopenvino-paddle-frontend-${cpack_name_ver}") set(CPACK_RPM_PADDLE_POST_INSTALL_SCRIPT_FILE "${def_triggers}") set(CPACK_RPM_PADDLE_POST_UNINSTALL_SCRIPT_FILE "${def_triggers}") @@ -297,7 +295,11 @@ macro(ov_cpack_settings) "devel-file-in-non-devel-package /usr/${OV_CPACK_SAMPLESDIR}/cpp/*" "devel-file-in-non-devel-package /usr/${OV_CPACK_SAMPLESDIR}/c/*" # depends on gflags-devel - "devel-dependency gflags-devel") + "devel-dependency gflags-devel" + # duplicated files are OK + "files-duplicate /usr/${OV_CPACK_SAMPLESDIR}/cpp/CMakeLists.txt /usr/${OV_CPACK_SAMPLESDIR}/c/CMakeLists.txt" + "files-duplicate /usr/${OV_CPACK_SAMPLESDIR}/cpp/build_samples.sh /usr/${OV_CPACK_SAMPLESDIR}/c/build_samples.sh" + ) set(samples_copyright "generic") # python_samples diff --git a/install_build_dependencies.sh b/install_build_dependencies.sh index 8865a6f3f1b..4b5c19a3d98 100755 --- a/install_build_dependencies.sh +++ b/install_build_dependencies.sh @@ -11,7 +11,7 @@ yes_or_no() { fi while true; do - read -p "Add third-party Nux Dextop repository and install FFmpeg package (y) / Skip this step (N)" yn + read -p -r "Add third-party Nux Dextop repository and install FFmpeg package (y) / Skip this step (N)" yn case $yn in [Yy]*) return 0 ;; [Nn]*) return 1 ;; diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 4c9869f2fa7..90f1e043c36 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -97,38 +97,43 @@ if(NOT DEFINED CMAKE_CXX_STANDARD) endif() #################################### -if(NOT TARGET gflags) - if(APPLE OR DEFINED ENV{CONDA_PREFIX} OR DEFINED ENV{HOMEBREW_PREFIX}) - # conda-forge and brew contains only shared version of gflags - if(ENV{CONDA_PREFIX} AND WIN32) - # conda-forge windows compiled as gflags - find_package(gflags QUIET COMPONENTS shared) - else() - find_package(gflags QUIET COMPONENTS nothreads_shared) - endif() +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils") + set(gflags_required ON) +endif() + +if(TARGET gflags) + set(GFLAGS_TARGET gflags) +elseif(gflags_required) + if(EXISTS /etc/debian_version) + set(gflags_component nothreads_static) else() - find_package(gflags QUIET COMPONENTS nothreads_static) + set(gflags_component shared) + endif() + find_package(gflags QUIET OPTIONAL_COMPONENTS ${gflags_component}) + if(gflags_FOUND) + if(TARGET ${GFLAGS_TARGET}) + # nothing + elseif(TARGET gflags_nothreads-static) + # Debian 9: gflag_component is ignored + set(GFLAGS_TARGET gflags_nothreads-static) + elseif(TARGET gflags-shared) + # gflags shared case for CentOS / RHEL / Fedora + set(GFLAGS_TARGET gflags-shared) + else() + message(FATAL_ERROR "Internal error: failed to find imported target 'gflags' using '${gflags_component}' component") + endif() + + message(STATUS "gflags (${gflags_VERSION}) is found at ${gflags_DIR} using '${gflags_component}' component") endif() - if(gflags_FOUND) - if(NOT TARGET ${GFLAGS_TARGET}) - if(TARGET gflags_nothreads-static) - # arm cross-compilation - set(GFLAGS_TARGET gflags_nothreads-static) - elseif(TARGET gflags_nothreads-shared) - # centos/rhel8 - set(GFLAGS_TARGET gflags_nothreads-shared) - else() - message(FATAL_ERROR "Failed to set GFLAGS_TARGET target") - endif() + if(NOT gflags_FOUND) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags") + add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL) + set(GFLAGS_TARGET gflags_nothreads_static) + else() + message(FATAL_ERROR "Failed to find 'gflags' library using '${gflags_component}' component") endif() - message(STATUS "gflags (${gflags_VERSION}) is found at ${gflags_DIR}") - elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags") - add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL) - set(GFLAGS_TARGET gflags_nothreads_static) endif() -else() - set(GFLAGS_TARGET gflags) endif() if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils") diff --git a/samples/cpp/benchmark_app/CMakeLists.txt b/samples/cpp/benchmark_app/CMakeLists.txt index 434a19f3dff..308998cacd3 100644 --- a/samples/cpp/benchmark_app/CMakeLists.txt +++ b/samples/cpp/benchmark_app/CMakeLists.txt @@ -19,7 +19,17 @@ if(NOT ANDROID) endif() if(NOT TARGET nlohmann_json::nlohmann_json) - find_package(nlohmann_json QUIET) + find_package(nlohmann_json QUIET + # exception for Ubuntu 18.04, where cmake files for nlohmann_json + # are located in a wrong directory + HINTS /usr/lib/cmake) + if(TARGET nlohmann_json) + # Ubuntu 18.04 case where target 'nlohmann_json' is here, but nlohmann_json_FOUND is OFF + if(NOT TARGET nlohmann_json::nlohmann_json) + add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json) + endif() + set(nlohmann_json_FOUND ON) + endif() if(nlohmann_json_FOUND) message(STATUS "nlohmann_json (${nlohmann_json_VERSION}) is found at ${nlohmann_json_DIR}") elseif(PkgConfig_FOUND) @@ -31,12 +41,28 @@ if(NOT TARGET nlohmann_json::nlohmann_json) endif() endif() + if(NOT nlohmann_json_FOUND) + # try to find header file json.hpp + # for example, on debian 9 there is no cmake / pkgconfig files + find_file(nlohmann_include_file + NAMES "json.hpp" + "Path to json.hpp (nlohmann-json-dev )") + if(nlohmann_include_file) + add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED) + get_filename_component(nlohmann_include_dir "${nlohmann_include_file}" PATH) + set_target_properties(nlohmann_json::nlohmann_json PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${nlohmann_include_dir}" + INTERFACE_COMPILE_DEFINITIONS JSON_HEADER) + set(nlohmann_json_FOUND ON) + endif() + endif() + if(NOT nlohmann_json_FOUND) if(EXISTS "${Samples_SOURCE_DIR}/thirdparty/nlohmann_json") # suppress shadowing names warning set(JSON_SystemInclude ON CACHE BOOL "" FORCE) add_subdirectory("${Samples_SOURCE_DIR}/thirdparty/nlohmann_json" - "${Samples_BINARY_DIR}/thirdparty/nlohmann_json" EXCLUDE_FROM_ALL) + "${Samples_BINARY_DIR}/thirdparty/nlohmann_json" EXCLUDE_FROM_ALL) else() message(FATAL_ERROR "Failed to find / build nlohmann_json library") endif() diff --git a/samples/cpp/benchmark_app/statistics_report.hpp b/samples/cpp/benchmark_app/statistics_report.hpp index cd0128fc377..57d9f79f087 100644 --- a/samples/cpp/benchmark_app/statistics_report.hpp +++ b/samples/cpp/benchmark_app/statistics_report.hpp @@ -5,11 +5,16 @@ #pragma once #include -#include #include #include #include +#ifdef JSON_HEADER +# include +#else +# include +#endif + // clang-format off #include "samples/common.hpp" #include "samples/csv_dumper.hpp" diff --git a/samples/cpp/benchmark_app/utils.cpp b/samples/cpp/benchmark_app/utils.cpp index 53612e6d323..16438e9f6a9 100644 --- a/samples/cpp/benchmark_app/utils.cpp +++ b/samples/cpp/benchmark_app/utils.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -20,6 +19,12 @@ #include "utils.hpp" // clang-format on +#ifdef JSON_HEADER +# include +#else +# include +#endif + #ifdef USE_OPENCV # include #endif @@ -767,21 +772,28 @@ void load_config(const std::string& filename, std::map& nlohmann::json jsonConfig; try { ifs >> jsonConfig; - } catch (const nlohmann::json::parse_error& e) { + } catch (const std::exception& e) { throw std::runtime_error("Can't parse config file \"" + filename + "\".\n" + e.what()); } - for (const auto& item : jsonConfig.items()) { - std::string deviceName = item.key(); - for (const auto& option : item.value().items()) { + for (auto item = jsonConfig.cbegin(), end = jsonConfig.cend(); item != end; ++item) { + const std::string& deviceName = item.key(); + const auto& itemValue = item.value(); + for (auto option = itemValue.cbegin(), itemValueEnd = itemValue.cend(); option != itemValueEnd; ++option) { if (option.key() != "DEVICE_PROPERTIES") { config[deviceName][option.key()] = option.value().get(); continue; } - for (const auto& hw_properties : option.value().items()) { - auto hw_device_name = hw_properties.key(); + const auto& optionValue = option.value(); + for (auto hw_properties = optionValue.cbegin(), optionValueEnd = optionValue.cend(); + hw_properties != optionValueEnd; + ++hw_properties) { + const std::string& hw_device_name = hw_properties.key(); std::map hw_device_properties; - for (const auto& property : hw_properties.value().items()) + const auto& hw_propertiesValue = hw_properties.value(); + for (auto property = hw_propertiesValue.cbegin(), hw_propertiesEnd = hw_propertiesValue.cend(); + property != hw_propertiesEnd; + ++property) hw_device_properties[property.key()] = property.value().get(); config[deviceName][hw_device_name] = hw_device_properties; } diff --git a/samples/cpp/common/utils/CMakeLists.txt b/samples/cpp/common/utils/CMakeLists.txt index 7a882825e11..3813e86692c 100644 --- a/samples/cpp/common/utils/CMakeLists.txt +++ b/samples/cpp/common/utils/CMakeLists.txt @@ -14,7 +14,7 @@ target_include_directories(${TARGET_NAME} find_package(OpenVINO REQUIRED COMPONENTS Runtime) -target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime PRIVATE gflags) +target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime PRIVATE ${GFLAGS_TARGET}) if(COMMAND add_clang_format_target) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) diff --git a/scripts/install_dependencies/install_openvino_dependencies.sh b/scripts/install_dependencies/install_openvino_dependencies.sh index 2d04e35f696..f2d056a69c5 100755 --- a/scripts/install_dependencies/install_openvino_dependencies.sh +++ b/scripts/install_dependencies/install_openvino_dependencies.sh @@ -87,7 +87,8 @@ if [ "$os" == "auto" ] ; then os="rhel8" fi case $os in - rhel8|rhel9.1|\ + centos7|centos8|rhel8|rhel9.1|\ + fedora34|fedora35|fedora36|fedora37|fedora38|\ raspbian9|debian9|ubuntu18.04|\ raspbian10|debian10|ubuntu20.04|ubuntu20.10|ubuntu21.04|\ raspbian11|debian11|ubuntu21.10|ubuntu22.04|\ @@ -108,7 +109,7 @@ if [ "$os" == "raspbian9" ] || [ "$os" == "debian9" ] ; then # - cmake version is 3.7.2 # which are not supported by OpenVINO - pkgs_core=() + pkgs_core=(libpugixml1v5) pkgs_python=() pkgs_dev=(pkg-config g++ gcc libc6-dev libgflags-dev zlib1g-dev nlohmann-json-dev make curl sudo) pkgs_myriad=(libusb-1.0-0) @@ -176,61 +177,95 @@ elif [ "$os" == "ubuntu20.04" ] || [ "$os" == "debian10" ] || [ "$os" == "raspbi pkgs_python=(${pkgs_python[@]} libpython3.10) fi -elif [ "$os" == "rhel8" ] || [ "$os" == "rhel9.1" ] ; then +elif [ "$os" == "centos7" ] || [ "$os" == "centos8" ] || + [ "$os" == "rhel8" ] || [ "$os" == "rhel9.1" ] || + [ "$os" == "fedora34" ] || [ "$os" == "fedora35" ] || [ "$os" == "fedora36" ] || + [ "$os" == "fedora36" ] || [ "$os" == "fedora38" ] ; then + + arch=$(uname -m) + pkgs_dev=(gcc gcc-c++ make glibc libstdc++ libgcc cmake3 json-devel.$arch zlib-devel.$arch sudo) if [ "$os" == "rhel9.1" ] ; then - pkgs_python=(python39 python3-pip) - elif [ "$os" == "rhel8" ] ; then - pkgs_python=(python38 python38-pip) + pkgs_dev+=(curl-minimal) + else + pkgs_dev+=(curl) fi - pkgs_core=( - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/tbb-2018.2-9.el8.x86_64.rpm - https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/pugixml-1.13-1.el8.x86_64.rpm - https://vault.centos.org/centos/8/PowerTools/x86_64/os/Packages/gflags-2.1.2-6.el8.x86_64.rpm - ) - pkgs_opencv_req=(gtk3) - pkgs_dev=( - gcc gcc-c++ make glibc libstdc++ libgcc cmake pkg-config zlib-devel curl sudo - ) - pkgs_myriad=() - pkgs_opencv_opt=( - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libcdio-2.0.0-3.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libtheora-1.1.1-21.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/opus-1.3-0.4.beta.el8.x86_64.rpm - http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/orc-0.4.28-3.el8.x86_64.rpm - http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/libglvnd-gles-1.3.4-1.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libdvdread-5.0.3-9.el8.x86_64.rpm - http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/libvisual-0.4.0-25.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/liba52-0.7.4-32.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libdvdread-5.0.3-9.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libXv-1.0.11-7.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/taglib-1.11.1-8.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/mpg123-libs-1.25.10-2.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/lame-libs-3.100-6.el8.x86_64.rpm - https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/libgudev-232-4.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libv4l-1.14.2-3.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/speex-1.2.0-1.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libraw1394-2.1.2-5.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libsrtp-1.5.4-8.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libvpx-1.7.0-8.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/wavpack-5.1.0-15.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libiec61883-1.2.0-18.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libshout-2.2.2-19.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/twolame-libs-0.3.13-12.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libavc1394-0.5.4-7.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libdv-1.0.0-27.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/libdvdnav-5.0.3-8.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/webrtc-audio-processing-0.3-9.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/gstreamer1-plugins-base-1.16.1-2.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/gstreamer1-1.16.1-2.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/gstreamer1-plugins-bad-free-1.16.1-1.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/gstreamer1-plugins-good-1.16.1-2.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/gstreamer1-plugins-ugly-free-1.16.1-1.el8.x86_64.rpm - https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/soundtouch-2.0.0-3.el8.x86_64.rpm - ) - extra_repos+=(https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm) + if [ "$os" == "fedora35" ] || [ "$os" == "fedora35" ] || [ "$os" == "fedora36" ] || + [ "$os" == "fedora36" ] || [ "$os" == "fedora38" ] ; then + pkgs_core=(tbb.$arch pugixml.$arch gflags.$arch) + pkgs_python=(python3 python3-pip) + pkgs_dev+=(gflags-devel.$arch) + pkgs_myriad=(libusb1.$arch) + else + pkgs_myriad=(libusbx.$arch) + fi + if [ "$os" == "centos7" ] ; then + pkgs_core=(tbb.$arch pugixml.$arch gflags.$arch) + pkgs_dev+=(gflags-devel.$arch) + pkgs_opencv_opt=( + gstreamer1.$arch + gstreamer1-plugins-ugly-free.$arch + gstreamer1-plugins-good.$arch + gstreamer1-plugins-bad-free.$arch + ) + extra_repos+=(https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm) + elif [ "$os" == "centos8" ] || [ "$os" == "rhel8" ] ; then + pkgs_core+=( + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/tbb-2018.2-9.el8.$arch.rpm + https://download-ib01.fedoraproject.org/pub/epel/8/Everything/$arch/Packages/p/pugixml-1.13-1.el8.$arch.rpm + https://vault.centos.org/centos/8/PowerTools/$arch/os/Packages/gflags-2.1.2-6.el8.$arch.rpm + ) + pkgs_python+=(python38 python38-pip) + pkgs_dev+=(https://vault.centos.org/centos/8/PowerTools/$arch/os/Packages/gflags-devel-2.1.2-6.el8.$arch.rpm) + pkgs_opencv_req=(gtk3) + pkgs_opencv_opt=( + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libcdio-2.0.0-3.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libtheora-1.1.1-21.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/opus-1.3-0.4.beta.el8.$arch.rpm + http://mirror.centos.org/centos/8-stream/AppStream/$arch/os/Packages/orc-0.4.28-3.el8.$arch.rpm + http://mirror.centos.org/centos/8-stream/AppStream/$arch/os/Packages/libglvnd-gles-1.3.4-1.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libdvdread-5.0.3-9.el8.$arch.rpm + http://mirror.centos.org/centos/8-stream/AppStream/$arch/os/Packages/libvisual-0.4.0-25.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/liba52-0.7.4-32.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libdvdread-5.0.3-9.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libXv-1.0.11-7.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/taglib-1.11.1-8.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/mpg123-libs-1.25.10-2.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/lame-libs-3.100-6.el8.$arch.rpm + https://vault.centos.org/centos/8/BaseOS/$arch/os/Packages/libgudev-232-4.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libv4l-1.14.2-3.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/speex-1.2.0-1.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libraw1394-2.1.2-5.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libsrtp-1.5.4-8.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libvpx-1.7.0-8.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/wavpack-5.1.0-15.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libiec61883-1.2.0-18.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libshout-2.2.2-19.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/twolame-libs-0.3.13-12.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libavc1394-0.5.4-7.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libdv-1.0.0-27.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/libdvdnav-5.0.3-8.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/webrtc-audio-processing-0.3-9.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/gstreamer1-plugins-base-1.16.1-2.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/gstreamer1-1.16.1-2.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/gstreamer1-plugins-bad-free-1.16.1-1.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/gstreamer1-plugins-good-1.16.1-2.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/gstreamer1-plugins-ugly-free-1.16.1-1.el8.$arch.rpm + https://vault.centos.org/centos/8/AppStream/$arch/os/Packages/soundtouch-2.0.0-3.el8.$arch.rpm + ) + extra_repos+=(https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm) + elif [ "$os" == "rhel9.1" ] ; then + pkgs_core=( + http://mirror.stream.centos.org/9-stream/AppStream/$arch/os/Packages/tbb-2020.3-8.el9.$arch.rpm + https://download-ib01.fedoraproject.org/pub/epel/9/Everything/$arch/Packages/p/pugixml-1.13-1.el9.$arch.rpm + https://download-ib01.fedoraproject.org/pub/epel/9/Everything/$arch/Packages/g/gflags-2.2.2-9.el9.$arch.rpm + ) + pkgs_python=(python3 python3-pip) + pkgs_dev+=(https://download-ib01.fedoraproject.org/pub/epel/9/Everything/$arch/Packages/g/gflags-devel-2.2.2-9.el9.$arch.rpm) + extra_repos+=(https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm) + fi else echo "Internal script error: invalid OS (${os}) after check (package selection)" >&2 exit 3 @@ -282,7 +317,10 @@ if [ "$os" == "debian9" ] || [ "$os" == "raspbian9" ] || [ "$os" == "ubuntu18.04 apt-get update && apt-get install -y --no-install-recommends $iopt ${pkgs[@]} -elif [ "$os" == "rhel8" ] || [ "$os" == "rhel9.1" ] ; then +elif [ "$os" == "centos7" ] || [ "$os" == "centos8" ] || + [ "$os" == "rhel8" ] || [ "$os" == "rhel9.1" ] || + [ "$os" == "fedora34" ] || [ "$os" == "fedora35" ] || [ "$os" == "fedora36" ] || + [ "$os" == "fedora36" ] || [ "$os" == "fedora38" ] ; then [ -z "$interactive" ] && iopt="--assumeyes" [ -n "$dry" ] && iopt="--downloadonly" diff --git a/src/plugins/intel_gpu/tests/gtest_main_gpu.cpp b/src/plugins/intel_gpu/tests/gtest_main_gpu.cpp index abd4615401d..d5e51937389 100644 --- a/src/plugins/intel_gpu/tests/gtest_main_gpu.cpp +++ b/src/plugins/intel_gpu/tests/gtest_main_gpu.cpp @@ -41,7 +41,7 @@ GTEST_API_ int main(int argc, char** argv) { printf("Running main() from %s\n", __FILE__); //gflags - GFLAGS_NAMESPACE::AllowCommandLineReparsing(); + gflags::AllowCommandLineReparsing(); gflags::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_device_id != -1 && cldnn::device_query::device_id == -1) cldnn::device_query::device_id = FLAGS_device_id; diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index a7cd5f416c1..26e2f56c2e7 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -91,9 +91,6 @@ if(ENABLE_SYSTEM_PUGIXML) if(interface_include_dir AND NOT EXISTS "${interface_include_dir}") set_target_properties(${pugixml_target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "") - # buggy pugixml.pc does not allow to work with openvino.pc well - set(pugixml_buggy_pkgconfig ON CACHE INTERNAL "" FORCE) - message(WARNING "openvino.pc pkg-config file generation has turned off because it should have to depend on pugixml.pc") endif() message(STATUS "${PKG_CONFIG_EXECUTABLE}: pugixml (${pugixml_VERSION}) is found at ${pugixml_PREFIX}") endif() @@ -189,37 +186,37 @@ endif() # if(ENABLE_SAMPLES OR ENABLE_COMPILE_TOOL OR ENABLE_TESTS) - if(NOT APPLE OR CPACK_GENERATOR MATCHES "^(BREW|CONDA-FORGE)$") - # - on Apple only dynamic libraries are available - # also, we can easily mix arm64 and x86_64 binaries when cross-compile for Intel CPU - - if(CPACK_GENERATOR MATCHES "^(BREW|CONDA-FORGE)$" OR DEFINED ENV{HOMEBREW_PREFIX} OR LINUX_OS_NAME MATCHES "(Fedora|CentOS)") - # conda-forge and brew contains only shared version of gflags - find_package(gflags QUIET COMPONENTS nothreads_shared) - else() - find_package(gflags QUIET COMPONENTS nothreads_static) + if(LINUX) + if(LINUX_OS_NAME MATCHES "(Fedora|CentOS)") + set(gflag_component nothreads_shared) + elseif(LINUX_OS_NAME MATCHES "(Ubuntu|Debian)") + set(gflag_component nothreads_static) endif() + find_package(gflags QUIET OPTIONAL_COMPONENTS ${gflag_component}) endif() if(gflags_FOUND) if(TARGET gflags) set_target_properties(gflags PROPERTIES IMPORTED_GLOBAL ON) - elseif(TARGET gflags_nothreads-shared) - # gflags shared case for CentOS/RHEL8 - set_target_properties(gflags_nothreads-shared PROPERTIES IMPORTED_GLOBAL ON) - add_library(gflags ALIAS gflags_nothreads-shared) elseif(TARGET gflags_nothreads-static) - # debian_9_arm case + # Debian 9: gflag_component is ignored set_target_properties(gflags_nothreads-static PROPERTIES IMPORTED_GLOBAL ON) add_library(gflags ALIAS gflags_nothreads-static) + elseif(TARGET gflags_nothreads-shared) + # CentOS / RHEL / Fedora case + set_target_properties(gflags_nothreads-shared PROPERTIES IMPORTED_GLOBAL ON) + add_library(gflags ALIAS gflags_nothreads-shared) elseif(TARGET ${GFLAGS_TARGET}) set_target_properties(${GFLAGS_TARGET} PROPERTIES IMPORTED_GLOBAL ON) add_library(gflags ALIAS ${GFLAGS_TARGET}) else() - message(FATAL_ERROR "Internal error: failed to find imported target 'gflags'") + message(FATAL_ERROR "Internal error: failed to find imported target 'gflags' using '${gflag_component}' component") endif() - message(STATUS "gflags (${gflags_VERSION}) is found at ${gflags_DIR}") - else() + + message(STATUS "gflags (${gflags_VERSION}) is found at ${gflags_DIR} using '${gflag_component}' component") + endif() + + if(NOT TARGET gflags) add_subdirectory(gflags EXCLUDE_FROM_ALL) openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags) endif() @@ -305,6 +302,14 @@ if(ENABLE_SAMPLES) # this is required only because of VPUX plugin reused this openvino_developer_export_targets(COMPONENT openvino_common TARGETS nlohmann_json) + + # for nlohmann library version v3.0.0 and later + if(NOT TARGET nlohmann_json::nlohmann_json) + add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED GLOBAL) + set_target_properties(nlohmann_json::nlohmann_json PROPERTIES + INTERFACE_LINK_LIBRARIES nlohmann_json + INTERFACE_COMPILE_DEFINITIONS JSON_HEADER) + endif() endif() # @@ -322,10 +327,10 @@ if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW)$") message(FATAL_ERROR "zlib must be used as a ${CPACK_GENERATOR} package. Install zlib1g-dev / zlib-devel") endif() endif() - if(NOT ENABLE_SYSTEM_PUGIXML AND NOT LINUX_OS_NAME STREQUAL "CentOS 7") + if(NOT ENABLE_SYSTEM_PUGIXML) message(FATAL_ERROR "Pugixml must be used as a ${CPACK_GENERATOR} package. Install libpugixml-dev / pugixml-devel") endif() -else() +elseif(APPLE OR WIN32 OR LINUX_OS_NAME STREQUAL "CentOS 7") install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gflags DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES}