diff --git a/.ci/azure/android_arm64.yml b/.ci/azure/android_arm64.yml index 279b3e5827d..31bf5b69829 100644 --- a/.ci/azure/android_arm64.yml +++ b/.ci/azure/android_arm64.yml @@ -141,7 +141,6 @@ jobs: -DANDROID_STL=c++_shared -DANDROID_PLATFORM=$(ANDROID_SDK_VERSION) -DENABLE_TESTS=ON - -DENABLE_INTEL_GPU=ON -DCMAKE_CXX_LINKER_LAUNCHER=ccache -DCMAKE_C_LINKER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 1fcfe154ae7..b1944eb87c8 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -245,6 +245,7 @@ jobs: -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DENABLE_SYSTEM_SNAPPY=ON + -DENABLE_SYSTEM_TBB=ON -DCPACK_GENERATOR=$(CMAKE_CPACK_GENERATOR) -DBUILD_nvidia_plugin=OFF -S $(REPO_DIR) diff --git a/.ci/azure/linux_arm64.yml b/.ci/azure/linux_arm64.yml index 4e4efe406d4..939320d9cd3 100644 --- a/.ci/azure/linux_arm64.yml +++ b/.ci/azure/linux_arm64.yml @@ -108,17 +108,17 @@ jobs: - checkout: self clean: 'true' - submodules: 'true' path: openvino - script: | set -e - sudo -E $(OPENVINO_REPO_DIR)/install_build_dependencies.sh python3 -m pip install --upgrade pip python3 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/requirements.txt python3 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/wheel/requirements-dev.txt # install dependencies needed to build CPU plugin for ARM sudo -E apt --assume-yes install scons crossbuild-essential-arm64 + # generic dependencies + sudo -E apt --assume-yes install cmake ccache # Speed up build sudo -E apt -y --no-install-recommends install unzip wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip @@ -126,25 +126,60 @@ jobs: sudo cp -v ninja /usr/local/bin/ displayName: 'Install dependencies' - - task: CMake@1 - inputs: - cmakeArgs: > - -G "Ninja Multi-Config" - -DCMAKE_VERBOSE_MAKEFILE=ON - -DCMAKE_COMPILE_WARNING_AS_ERROR=ON - -DOpenCV_DIR=$(INSTALL_OPENCV)/cmake - -DENABLE_PYTHON=OFF - -DENABLE_TESTS=ON - -DENABLE_DATA=OFF - -DCMAKE_TOOLCHAIN_FILE=$(OPENVINO_REPO_DIR)/cmake/arm64.toolchain.cmake - -DCMAKE_VERBOSE_MAKEFILE=ON - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - -DCMAKE_C_COMPILER_LAUNCHER=ccache - -DARM_COMPUTE_SCONS_JOBS=$(NUM_PROC) - -DCMAKE_INSTALL_PREFIX=$(INSTALL_OPENVINO) - -S $(OPENVINO_REPO_DIR) + - script: | + git submodule update --init -- $(OPENVINO_REPO_DIR)/src/plugins + git submodule update --init -- $(OPENVINO_REPO_DIR)/thirdparty/gtest + displayName: 'Init submodules for non Conan dependencies' + + - script: | + python3 -m pip install conan + # generate build profile + conan profile detect + # generate host profile for linux_arm64 + echo "include(default)" > $(BUILD_OPENVINO)/linux_arm64 + echo "[buildenv]" >> $(BUILD_OPENVINO)/linux_arm64 + echo "CC=aarch64-linux-gnu-gcc" >> $(BUILD_OPENVINO)/linux_arm64 + echo "CXX=aarch64-linux-gnu-g++" >> $(BUILD_OPENVINO)/linux_arm64 + # install OpenVINO dependencies + export CMAKE_CXX_COMPILER_LAUNCHER=ccache + export CMAKE_C_COMPILER_LAUNCHER=ccache + conan install $(OPENVINO_REPO_DIR)/conanfile.txt \ + -pr:h $(BUILD_OPENVINO)/linux_arm64 \ + -s:h arch=armv8 \ + -of $(BUILD_OPENVINO) \ + -b missing + env: + CCACHE_DIR: $(OPENVINO_CCACHE_DIR) + CCACHE_TEMPDIR: $(TMP_DIR)/ccache + CCACHE_BASEDIR: $(Pipeline.Workspace) + CCACHE_MAXSIZE: 50G + displayName: 'Install conan and dependencies' + + - script: | + source $(BUILD_OPENVINO)/conanbuild.sh + cmake \ + -G Ninja \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ + -DENABLE_CPPLINT=OFF \ + -DENABLE_PYTHON=OFF \ + -DENABLE_TESTS=ON \ + -DENABLE_DATA=OFF \ + -DENABLE_SYSTEM_TBB=ON \ + -DENABLE_SYSTEM_PROTOBUF=ON \ + -DENABLE_SYSTEM_SNAPPY=ON \ + -DENABLE_SYSTEM_PUGIXML=ON \ + -DCMAKE_TOOLCHAIN_FILE=$(BUILD_OPENVINO)/conan_toolchain.cmake \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DARM_COMPUTE_SCONS_JOBS=$(NUM_PROC) \ + -DCMAKE_INSTALL_PREFIX=$(INSTALL_OPENVINO) \ + -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \ + -S $(OPENVINO_REPO_DIR) \ -B $(BUILD_OPENVINO) - displayName: 'CMake OpenVINO ARM plugin' + source $(BUILD_OPENVINO)/deactivate_conanbuild.sh + displayName: 'CMake configure' - script: cmake --build $(BUILD_OPENVINO) --parallel --config $(BUILD_TYPE) env: @@ -152,13 +187,13 @@ jobs: CCACHE_TEMPDIR: $(TMP_DIR)/ccache CCACHE_BASEDIR: $(Pipeline.Workspace) CCACHE_MAXSIZE: 50G - displayName: 'Build OpenVINO ARM plugin' + displayName: 'Build OpenVINO Runtime' - script: cmake --build $(BUILD_OPENVINO) --parallel --config $(BUILD_TYPE) --target install - displayName: 'Install OpenVINO ARM plugin' + displayName: 'Install OpenVINO Runtime' - task: PublishBuildArtifacts@1 inputs: PathtoPublish: $(Build.ArtifactStagingDirectory) ArtifactName: 'openvino_aarch64_linux' - displayName: 'Publish OpenVINO AArch64 linux package' + displayName: 'Publish OpenVINO Runtime for ARM' diff --git a/.ci/azure/windows_conditional_compilation.yml b/.ci/azure/windows_conditional_compilation.yml index 2e8a96797c7..4b8bbfc4e89 100644 --- a/.ci/azure/windows_conditional_compilation.yml +++ b/.ci/azure/windows_conditional_compilation.yml @@ -116,7 +116,7 @@ jobs: -G Ninja ^ -DENABLE_CPPLINT=OFF ^ -DENABLE_GAPI_PREPROCESSING=OFF ^ - -DENABLE_FASTER_BUILD=ON ^ + -DENABLE_PLUGINS_XML=ON ^ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON ^ -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) ^ -DENABLE_PROFILING_ITT=ON ^ @@ -153,7 +153,6 @@ jobs: -DVERBOSE_BUILD=ON ^ -DENABLE_CPPLINT=OFF ^ -DENABLE_GAPI_PREPROCESSING=OFF ^ - -DENABLE_FASTER_BUILD=ON ^ -DENABLE_PROFILING_ITT=OFF ^ -DSELECTIVE_BUILD=ON ^ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON ^ diff --git a/.gitignore b/.gitignore index fdc00ccfbd2..96fec2d0fda 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ temp/ .repo/ CMakeLists.txt.user docs/IE_PLUGIN_DG/html/ +CMakeUserPresets.json *.project *.cproject diff --git a/CMakeLists.txt b/CMakeLists.txt index 92bb7b0f19b..4f6066ad971 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,6 @@ endif() # resolving dependencies for the project message (STATUS "CMAKE_VERSION ......................... " ${CMAKE_VERSION}) -message (STATUS "CMAKE_BINARY_DIR ...................... " ${CMAKE_BINARY_DIR}) -message (STATUS "CMAKE_SOURCE_DIR ...................... " ${CMAKE_SOURCE_DIR}) message (STATUS "OpenVINO_SOURCE_DIR ................... " ${OpenVINO_SOURCE_DIR}) message (STATUS "OpenVINO_BINARY_DIR ................... " ${OpenVINO_BINARY_DIR}) message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR}) @@ -66,7 +64,7 @@ endif() if(CMAKE_TOOLCHAIN_FILE) message (STATUS "CMAKE_TOOLCHAIN_FILE .................. " ${CMAKE_TOOLCHAIN_FILE}) endif() -if(OV_GLIBC_VERSION) +if(NOT OV_GLIBC_VERSION VERSION_EQUAL 0.0) message (STATUS "GLIBC_VERSION ......................... " ${OV_GLIBC_VERSION}) endif() diff --git a/cmake/developer_package/IEDevScriptsConfig.cmake b/cmake/developer_package/IEDevScriptsConfig.cmake index a607e36bb29..e41118bb175 100644 --- a/cmake/developer_package/IEDevScriptsConfig.cmake +++ b/cmake/developer_package/IEDevScriptsConfig.cmake @@ -111,8 +111,8 @@ else() set(BIN_FOLDER "bin/${ARCH_FOLDER}") endif() -if(CMAKE_GENERATOR MATCHES "^Ninja Multi-Config$") - # Ninja-Multi specific, see: +if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config") + # 'Ninja Multi-Config' specific, see: # https://cmake.org/cmake/help/latest/variable/CMAKE_DEFAULT_BUILD_TYPE.html set(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "CMake default build type") elseif(NOT OV_GENERATOR_MULTI_CONFIG) @@ -240,7 +240,7 @@ if(ENABLE_LTO) LANGUAGES C CXX) if(NOT IPO_SUPPORTED) - set(ENABLE_LTO "OFF" CACHE STRING "Enable Link Time Optmization" FORCE) + set(ENABLE_LTO "OFF" CACHE STRING "Enable Link Time Optimization" FORCE) message(WARNING "IPO / LTO is not supported: ${OUTPUT_MESSAGE}") endif() endif() @@ -250,8 +250,8 @@ endif() macro(ov_install_static_lib target comp) if(NOT BUILD_SHARED_LIBS) get_target_property(target_type ${target} TYPE) - if(${target_type} STREQUAL "STATIC_LIBRARY") - set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL FALSE) + if(target_type STREQUAL "STATIC_LIBRARY") + set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL OFF) endif() install(TARGETS ${target} EXPORT OpenVINOTargets ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${comp} ${ARGN}) diff --git a/cmake/developer_package/api_validator/api_validator.cmake b/cmake/developer_package/api_validator/api_validator.cmake index 08f91322a34..68693fb7b54 100644 --- a/cmake/developer_package/api_validator/api_validator.cmake +++ b/cmake/developer_package/api_validator/api_validator.cmake @@ -4,23 +4,28 @@ if(WIN32) set(PROGRAMFILES_ENV "ProgramFiles(X86)") - file(TO_CMAKE_PATH $ENV{${PROGRAMFILES_ENV}} PROGRAMFILES) - set(WDK_PATHS "${PROGRAMFILES}/Windows Kits/10/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/x64" - "${PROGRAMFILES}/Windows Kits/10/bin/x64") + # check that PROGRAMFILES_ENV is defined, because in case of cross-compilation for Windows + # we don't have such variable + if(DEFINED ENV{PROGRAMFILES_ENV}) + file(TO_CMAKE_PATH $ENV{${PROGRAMFILES_ENV}} PROGRAMFILES) - message(STATUS "Trying to find apivalidator in: ") - foreach(wdk_path IN LISTS WDK_PATHS) - message(" * ${wdk_path}") - endforeach() + set(WDK_PATHS "${PROGRAMFILES}/Windows Kits/10/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/x64" + "${PROGRAMFILES}/Windows Kits/10/bin/x64") - find_host_program(ONECORE_API_VALIDATOR - NAMES apivalidator - PATHS ${WDK_PATHS} - DOC "ApiValidator for OneCore compliance") + message(STATUS "Trying to find apivalidator in: ") + foreach(wdk_path IN LISTS WDK_PATHS) + message(" * ${wdk_path}") + endforeach() - if(ONECORE_API_VALIDATOR) - message(STATUS "Found apivalidator: ${ONECORE_API_VALIDATOR}") + find_host_program(ONECORE_API_VALIDATOR + NAMES apivalidator + PATHS ${WDK_PATHS} + DOC "ApiValidator for OneCore compliance") + + if(ONECORE_API_VALIDATOR) + message(STATUS "Found apivalidator: ${ONECORE_API_VALIDATOR}") + endif() endif() endif() diff --git a/cmake/developer_package/compile_flags/fuzzing.cmake b/cmake/developer_package/compile_flags/fuzzing.cmake index e030695d5a4..70fdb223163 100644 --- a/cmake/developer_package/compile_flags/fuzzing.cmake +++ b/cmake/developer_package/compile_flags/fuzzing.cmake @@ -4,8 +4,13 @@ macro(enable_fuzzing) # Enable (libFuzzer)[https://llvm.org/docs/LibFuzzer.html] if supported. - set(FUZZING_COMPILER_FLAGS "-fsanitize=fuzzer-no-link -fprofile-instr-generate -fcoverage-mapping") - set(FUZZING_LINKER_FLAGS "-fsanitize-coverage=trace-pc-guard -fprofile-instr-generate") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # see https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-160#remarks + set(FUZZING_COMPILER_FLAGS "/fsanitize=fuzzer") + elseif(OV_COMPILER_IS_CLANG) + set(FUZZING_COMPILER_FLAGS "-fsanitize=fuzzer-no-link -fprofile-instr-generate -fcoverage-mapping") + set(FUZZING_LINKER_FLAGS "-fsanitize-coverage=trace-pc-guard -fprofile-instr-generate") + endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FUZZING_COMPILER_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FUZZING_COMPILER_FLAGS}") @@ -20,6 +25,10 @@ function(add_fuzzer FUZZER_EXE_NAME FUZZER_SOURCES) add_executable(${FUZZER_EXE_NAME} ${FUZZER_SOURCES}) target_link_libraries(${FUZZER_EXE_NAME} PRIVATE fuzz-testhelper) if(ENABLE_FUZZING) - set_target_properties(${FUZZER_EXE_NAME} PROPERTIES LINK_FLAGS "-fsanitize=fuzzer") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # no extra flags are required + elseif(OV_COMPILER_IS_CLANG) + set_target_properties(${FUZZER_EXE_NAME} PROPERTIES LINK_FLAGS "-fsanitize=fuzzer") + endif() endif() endfunction(add_fuzzer) diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index a5dbb05de41..fd176ec6b44 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -12,23 +12,17 @@ include(CheckCXXCompilerFlag) # Defines ie_c_cxx_deprecated varaible which contains C / C++ compiler flags # macro(ov_disable_deprecated_warnings) - if(WIN32) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(ie_c_cxx_deprecated "/wd4996") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) set(ie_c_cxx_deprecated "/Qdiag-disable:1478,1786") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(ie_c_cxx_deprecated "/wd4996") - elseif(OV_COMPILER_IS_CLANG) - set(ie_c_cxx_deprecated "-Wno-deprecated-declarations") - endif() - else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + else() set(ie_c_cxx_deprecated "-diag-disable=1478,1786") - elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) - set(ie_c_cxx_deprecated "-Wno-deprecated-declarations") endif() - endif() - - if(NOT ie_c_cxx_deprecated) + elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) + set(ie_c_cxx_deprecated "-Wno-deprecated-declarations") + else() message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() @@ -49,24 +43,18 @@ endmacro() # Defines ie_c_cxx_deprecated_no_errors varaible which contains C / C++ compiler flags # macro(ov_deprecated_no_errors) - if(WIN32) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # show 4996 only for /w4 + set(ie_c_cxx_deprecated_no_errors "/wd4996") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) set(ie_c_cxx_deprecated_no_errors "/Qdiag-warning:1478,1786") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # show 4996 only for /w4 - set(ie_c_cxx_deprecated_no_errors "/wd4996") - elseif(OV_COMPILER_IS_CLANG) - set(ie_c_cxx_deprecated_no_errors "-Wno-error=deprecated-declarations") - endif() - else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + else() set(ie_c_cxx_deprecated_no_errors "-diag-warning=1478,1786") - elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) - set(ie_c_cxx_deprecated_no_errors "-Wno-error=deprecated-declarations") endif() - endif() - - if(NOT ie_c_cxx_deprecated_no_errors) + elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) + set(ie_c_cxx_deprecated_no_errors "-Wno-error=deprecated-declarations") + else() message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() @@ -101,23 +89,21 @@ endmacro() # Provides SSE4.2 compilation flags depending on an OS and a compiler # macro(ie_sse42_optimization_flags flags) - if(WIN32) - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # No such option for MSVC 2019 - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # No such option for MSVC 2019 + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) set(${flags} /QxSSE4.2) else() - message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") + set(${flags} -xSSE4.2) + endif() + elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) + set(${flags} -msse4.2) + if(EMSCRIPTEN) + list(APPEND ${flags} -msimd128) endif() else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(${flags} -xSSE4.2) - else() - set(${flags} -msse4.2) - if(EMSCRIPTEN) - list(APPEND ${flags} -msimd128) - endif() - endif() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() endmacro() @@ -127,20 +113,18 @@ endmacro() # Provides AVX2 compilation flags depending on an OS and a compiler # macro(ie_avx2_optimization_flags flags) - if(WIN32) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(${flags} /arch:AVX2) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) set(${flags} /QxCORE-AVX2) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(${flags} /arch:AVX2) else() - message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") - endif() - else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") set(${flags} -xCORE-AVX2) - else() - set(${flags} -mavx2 -mfma) endif() + elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) + set(${flags} -mavx2 -mfma) + else() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() endmacro() @@ -151,24 +135,18 @@ endmacro() # depending on an OS and a compiler # macro(ie_avx512_optimization_flags flags) - if(WIN32) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(${flags} /arch:AVX512) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) set(${flags} /QxCOMMON-AVX512) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(${flags} /arch:AVX512) else() - message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") - endif() - else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") set(${flags} -xCOMMON-AVX512) endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(${flags} -mavx512f -mfma) - endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|AppleClang)$") - set(${flags} -mavx512f -mfma) - endif() + elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) + set(${flags} -mavx512f -mfma) + else() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() endmacro() @@ -265,8 +243,10 @@ endfunction() function(ov_force_include target scope header_file) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options(${target} ${scope} /FI"${header_file}") - else() + elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) target_compile_options(${target} ${scope} -include "${header_file}") + else() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() endfunction() @@ -318,11 +298,11 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) if(CMAKE_CL_64) # Default char Type Is unsigned # ie_add_compiler_flags(/J) -else() +elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) ie_add_compiler_flags(-fsigned-char) endif() -if(WIN32) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # # Common options / warnings enabled # @@ -335,16 +315,14 @@ if(WIN32) # This option helps ensure the fewest possible hard-to-find code defects. Similar to -Wall on GNU / Clang ie_add_compiler_flags(/W3) - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # Increase Number of Sections in .Obj file - ie_add_compiler_flags(/bigobj) - # Build with multiple processes - ie_add_compiler_flags(/MP) + # Increase Number of Sections in .Obj file + ie_add_compiler_flags(/bigobj) + # Build with multiple processes + ie_add_compiler_flags(/MP) - if(AARCH64 AND NOT MSVC_VERSION LESS 1930) - # otherwise, _ARM64_EXTENDED_INTRINSICS is defined, which defines 'mvn' macro - ie_add_compiler_flags(/D_ARM64_DISTINCT_NEON_TYPES) - endif() + if(AARCH64 AND NOT MSVC_VERSION LESS 1930) + # otherwise, _ARM64_EXTENDED_INTRINSICS is defined, which defines 'mvn' macro + ie_add_compiler_flags(/D_ARM64_DISTINCT_NEON_TYPES) endif() # Handle Large Addresses @@ -361,42 +339,62 @@ if(WIN32) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /WX") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /WX") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /WX") - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - ie_add_compiler_flags(/Qdiag-warning:47,1740,1786) - endif() endif() # # Disable noisy warnings # - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # C4251 needs to have dll-interface to be used by clients of class - ie_add_compiler_flags(/wd4251) - # C4275 non dll-interface class used as base for dll-interface class - ie_add_compiler_flags(/wd4275) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # 161: unrecognized pragma - # 177: variable was declared but never referenced - # 556: not matched type of assigned function pointer - # 1744: field of class type without a DLL interface used in a class with a DLL interface - # 1879: unimplemented pragma ignored - # 2586: decorated name length exceeded, name was truncated - # 2651: attribute does not apply to any entity - # 3180: unrecognized OpenMP pragma - # 11075: To get full report use -Qopt-report:4 -Qopt-report-phase ipo - # 15335: was not vectorized: vectorization possible but seems inefficient. Use vector always directive or /Qvec-threshold0 to override - ie_add_compiler_flags(/Qdiag-disable:161,177,556,1744,1879,2586,2651,3180,11075,15335) - endif() + # C4251 needs to have dll-interface to be used by clients of class + ie_add_compiler_flags(/wd4251) + # C4275 non dll-interface class used as base for dll-interface class + ie_add_compiler_flags(/wd4275) + # # Debug information flags, by default CMake adds /Zi option # but provides no way to specify CMAKE_COMPILE_PDB_NAME on root level # In order to avoid issues with ninja we are replacing default flag instead of having two of them # and observing warning D9025 about flag override + # + string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND WIN32) + # + # Warnings as errors + # + + if(CMAKE_COMPILE_WARNING_AS_ERROR AND CMAKE_VERSION VERSION_LESS 3.24) + ie_add_compiler_flags(/Qdiag-warning:47,1740,1786) + endif() + + # + # Disable noisy warnings + # + + # 161: unrecognized pragma + ie_add_compiler_flags(/Qdiag-disable:161) + # 177: variable was declared but never referenced + ie_add_compiler_flags(/Qdiag-disable:177) + # 556: not matched type of assigned function pointer + ie_add_compiler_flags(/Qdiag-disable:556) + # 1744: field of class type without a DLL interface used in a class with a DLL interface + ie_add_compiler_flags(/Qdiag-disable:1744) + # 1879: unimplemented pragma ignored + ie_add_compiler_flags(/Qdiag-disable:1879) + # 2586: decorated name length exceeded, name was truncated + ie_add_compiler_flags(/Qdiag-disable:2586) + # 2651: attribute does not apply to any entity + ie_add_compiler_flags(/Qdiag-disable:2651) + # 3180: unrecognized OpenMP pragma + ie_add_compiler_flags(/Qdiag-disable:3180) + # 11075: To get full report use -Qopt-report:4 -Qopt-report-phase ipo + ie_add_compiler_flags(/Qdiag-disable:11075) + # 15335: was not vectorized: vectorization possible but seems inefficient. + # Use vector always directive or /Qvec-threshold0 to override + ie_add_compiler_flags(/Qdiag-disable:15335) else() # # Common enabled warnings diff --git a/cmake/developer_package/compile_flags/sanitizer.cmake b/cmake/developer_package/compile_flags/sanitizer.cmake index 0a609d91b1d..1d4790faa2d 100644 --- a/cmake/developer_package/compile_flags/sanitizer.cmake +++ b/cmake/developer_package/compile_flags/sanitizer.cmake @@ -5,7 +5,9 @@ include(CheckCXXCompilerFlag) if (ENABLE_SANITIZER) - if (WIN32) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # the flag is available since MSVC 2019 16.9 + # see https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-160 check_cxx_compiler_flag("/fsanitize=address" SANITIZE_ADDRESS_SUPPORTED) if (SANITIZE_ADDRESS_SUPPORTED) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} /fsanitize=address") @@ -14,21 +16,23 @@ if (ENABLE_SANITIZER) "Please, check requirements:\n" "https://github.com/openvinotoolkit/openvino/wiki/AddressSanitizer-and-LeakSanitizer") endif() - else() + elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address") check_cxx_compiler_flag("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED) if (SANITIZE_RECOVER_ADDRESS_SUPPORTED) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address") endif() set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address") + else() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() endif() -if (ENABLE_UB_SANITIZER) - if (WIN32) - message(FATAL_ERROR "UndefinedBehavior sanitizer is not supported in Windows") +if(ENABLE_UB_SANITIZER) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(FATAL_ERROR "UndefinedBehavior sanitizer is not supported in Windows with MSVC compiler. Please, use clang-cl or mingw") endif() - + # TODO: Remove -fno-sanitize=null as thirdparty/ocl/clhpp_headers UBSAN compatibility resolved: # https://github.com/KhronosGroup/OpenCL-CLHPP/issues/17 # Mute -fsanitize=function Indirect call of a function through a function pointer of the wrong type. @@ -48,43 +52,50 @@ if (ENABLE_UB_SANITIZER) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fno-sanitize=function") endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # TODO: Remove -Wno-maybe-uninitialized after CVS-61143 fix + if(CMAKE_COMPILER_IS_GNUCXX) + # TODO: Remove -Wno-maybe-uninitialized after CVS-61143 is fixed set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -Wno-maybe-uninitialized") endif() check_cxx_compiler_flag("-fsanitize-recover=undefined" SANITIZE_RECOVER_UNDEFINED_SUPPORTED) - if (SANITIZE_RECOVER_UNDEFINED_SUPPORTED) + if(SANITIZE_RECOVER_UNDEFINED_SUPPORTED) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=undefined") endif() set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=undefined") endif() -if (ENABLE_THREAD_SANITIZER) - set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=thread") - set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread") +if(ENABLE_THREAD_SANITIZER) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(FATAL_ERROR "Thread sanitizer is not supported in Windows with MSVC compiler. Please, use clang-cl or mingw") + elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=thread") + set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread") + else() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") + endif() endif() # common sanitizer options -if (DEFINED SANITIZER_COMPILER_FLAGS) +if(DEFINED SANITIZER_COMPILER_FLAGS) # ensure symbols are present - if (NOT WIN32) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} /Oy-") + elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -g -fno-omit-frame-pointer") - if(NOT OV_COMPILER_IS_CLANG) + if(CMAKE_COMPILER_IS_GNUCXX) # GPU plugin tests compilation is slow with -fvar-tracking-assignments on GCC. # Clang has no var-tracking-assignments. set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fno-var-tracking-assignments") endif() # prevent unloading libraries at runtime, so sanitizer can resolve their symbols - if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(NOT OV_COMPILER_IS_APPLECLANG) set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -Wl,-z,nodelete") if(OV_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld") endif() endif() - else() - set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} /Oy-") + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_COMPILER_FLAGS}") diff --git a/cmake/developer_package/compile_flags/sdl.cmake b/cmake/developer_package/compile_flags/sdl.cmake index 3973ba74db6..49ff54d8326 100644 --- a/cmake/developer_package/compile_flags/sdl.cmake +++ b/cmake/developer_package/compile_flags/sdl.cmake @@ -2,61 +2,68 @@ # SPDX-License-Identifier: Apache-2.0 # -if(UNIX) - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -Wformat -Wformat-security") +if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR + (UNIX AND CMAKE_CXX_COMPILER_ID STREQUAL "Intel")) + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -Wformat -Wformat-security") + if (NOT ENABLE_SANITIZER) if(EMSCRIPTEN) # emcc does not support fortification, see: # https://stackoverflow.com/questions/58854858/undefined-symbol-stack-chk-guard-in-libopenh264-so-when-building-ffmpeg-wit else() # ASan does not support fortification https://github.com/google/sanitizers/issues/247 - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -D_FORTIFY_SOURCE=2") + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -D_FORTIFY_SOURCE=2") endif() endif() if(NOT APPLE) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pie") endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(IE_LINKER_FLAGS "${IE_LINKER_FLAGS} -z noexecstack -z relro -z now") - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv") + if(CMAKE_COMPILER_IS_GNUCXX) + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-all") + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fstack-protector-all") else() - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-strong") + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fstack-protector-strong") endif() if (NOT ENABLE_SANITIZER) - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -s") + # Remove all symbol table and relocation information from the executable + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -s") + endif() + if(NOT MINGW) + set(OV_LINKER_FLAGS "${OV_LINKER_FLAGS} -z noexecstack -z relro -z now") endif() elseif(OV_COMPILER_IS_CLANG) if(EMSCRIPTEN) # emcc does not support fortification # https://stackoverflow.com/questions/58854858/undefined-symbol-stack-chk-guard-in-libopenh264-so-when-building-ffmpeg-wit else() - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-all") + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fstack-protector-all") endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") if (NOT ENABLE_SANITIZER) - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -Wl,--strip-all") + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -Wl,--strip-all") endif() - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-strong") - set(IE_LINKER_FLAGS "${IE_LINKER_FLAGS} -z noexecstack -z relro -z now") - endif() -else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} /sdl") - endif() - set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} /guard:cf") - if(ENABLE_INTEGRITYCHECK) - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /INTEGRITYCHECK") - endif() - if(ENABLE_QSPECTRE) - ie_add_compiler_flags(/Qspectre) + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -fstack-protector-strong") + set(OV_LINKER_FLAGS "${OV_LINKER_FLAGS} -z noexecstack -z relro -z now") endif() +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} /sdl /guard:cf") endif() -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${IE_C_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${IE_C_CXX_FLAGS}") -set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${IE_LINKER_FLAGS}") -set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${IE_LINKER_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${IE_LINKER_FLAGS}") +if(ENABLE_QSPECTRE) + set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} /Qspectre") +endif() + +if(ENABLE_INTEGRITYCHECK) + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /INTEGRITYCHECK") +endif() + +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OV_C_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OV_C_CXX_FLAGS}") +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${OV_LINKER_FLAGS}") +set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${OV_LINKER_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OV_LINKER_FLAGS}") + +unset(OV_C_CXX_FLAGS) +unset(OV_LINKER_FLAGS) diff --git a/cmake/developer_package/cpplint/cpplint.py b/cmake/developer_package/cpplint/cpplint.py index 2700bae29f8..206132301fc 100644 --- a/cmake/developer_package/cpplint/cpplint.py +++ b/cmake/developer_package/cpplint/cpplint.py @@ -641,7 +641,7 @@ _repository = None # Files to exclude from linting. This is set by the --exclude flag. _excludes = None -# Whether to supress PrintInfo messages +# Whether to suppress PrintInfo messages _quiet = False # The allowed line length of files. @@ -752,7 +752,7 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error): 'Unknown NOLINT error category: %s' % category) -def ProcessGlobalSuppresions(lines): +def ProcessGlobalSuppressions(lines): """Updates the list of global error suppressions. Parses any lint directives in the file that have global effect. @@ -780,7 +780,7 @@ def IsErrorSuppressedByNolint(category, linenum): """Returns true if the specified error category is suppressed on this line. Consults the global error_suppressions map populated by - ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions. + ParseNolintSuppressions/ProcessGlobalSuppressions/ResetNolintSuppressions. Args: category: str, the category of the error. @@ -6203,7 +6203,7 @@ def ProcessFileData(filename, file_extension, lines, error, ResetNolintSuppressions() CheckForCopyright(filename, lines, error) - ProcessGlobalSuppresions(lines) + ProcessGlobalSuppressions(lines) RemoveMultiLineComments(filename, lines, error) clean_lines = CleansedLines(lines) diff --git a/cmake/developer_package/features.cmake b/cmake/developer_package/features.cmake index 5c810c713c6..fe1cfe02ab7 100644 --- a/cmake/developer_package/features.cmake +++ b/cmake/developer_package/features.cmake @@ -74,7 +74,12 @@ ie_option (VERBOSE_BUILD "shows extra information about build" OFF) ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF) -ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "OV_COMPILER_IS_CLANG;NOT WIN32" OFF) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1930) + # Visual Studio 2022: 1930-1939 = VS 17.0 (v143 toolset) + set(_msvc_version_2022 ON) +endif() + +ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "OV_COMPILER_IS_CLANG OR _msvc_version_2022" OFF) # # Check features diff --git a/cmake/developer_package/frontends/frontends.cmake b/cmake/developer_package/frontends/frontends.cmake index 897e6f8e3a6..39335be08bf 100644 --- a/cmake/developer_package/frontends/frontends.cmake +++ b/cmake/developer_package/frontends/frontends.cmake @@ -171,7 +171,7 @@ macro(ov_add_frontend) endforeach() # Disable all warnings for generated code - set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES COMPILE_OPTIONS -w GENERATED TRUE) + set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES COMPILE_OPTIONS -w GENERATED ON) # Create library add_library(${TARGET_NAME} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} @@ -204,8 +204,7 @@ macro(ov_add_frontend) ov_add_vs_version_file(NAME ${TARGET_NAME} FILEDESCRIPTION ${OV_FRONTEND_FILEDESCRIPTION}) - target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime) - target_link_libraries(${TARGET_NAME} PRIVATE ${OV_FRONTEND_LINK_LIBRARIES}) + target_link_libraries(${TARGET_NAME} PRIVATE ${OV_FRONTEND_LINK_LIBRARIES} PUBLIC openvino::runtime) ov_add_library_version(${TARGET_NAME}) # WA for TF frontends which always require protobuf (not protobuf-lite) @@ -216,23 +215,34 @@ macro(ov_add_frontend) if(proto_files) if(OV_FRONTEND_PROTOBUF_LITE) - if(NOT protobuf_lite_installed) - ov_install_static_lib(${Protobuf_LITE_LIBRARIES} ${OV_CPACK_COMP_CORE}) - set(protobuf_lite_installed ON CACHE INTERNAL "" FORCE) - endif() - link_system_libraries(${TARGET_NAME} PRIVATE ${Protobuf_LITE_LIBRARIES}) + set(protobuf_target_name libprotobuf-lite) + set(protobuf_install_name "protobuf_lite_installed") else() - if(NOT protobuf_installed) - ov_install_static_lib(${Protobuf_LIBRARIES} ${OV_CPACK_COMP_CORE}) - set(protobuf_installed ON CACHE INTERNAL "" FORCE) - endif() - link_system_libraries(${TARGET_NAME} PRIVATE ${Protobuf_LIBRARIES}) + set(protobuf_target_name libprotobuf) + set(protobuf_install_name "protobuf_installed") + endif() + if(ENABLE_SYSTEM_PROTOBUF) + # use imported target name with namespace + set(protobuf_target_name "protobuf::${protobuf_target_name}") endif() - # prptobuf generated code emits -Wsuggest-override error + link_system_libraries(${TARGET_NAME} PRIVATE ${protobuf_target_name}) + + # protobuf generated code emits -Wsuggest-override error if(SUGGEST_OVERRIDE_SUPPORTED) target_compile_options(${TARGET_NAME} PRIVATE -Wno-suggest-override) endif() + + # install protobuf if it is not installed yet + if(NOT ${protobuf_install_name}) + if(ENABLE_SYSTEM_PROTOBUF) + # we have to add find_package(Protobuf) to the OpenVINOConfig.cmake for static build + # no needs to install protobuf + else() + ov_install_static_lib(${protobuf_target_name} ${OV_CPACK_COMP_CORE}) + set("${protobuf_install_name}" ON CACHE INTERNAL "" FORCE) + endif() + endif() endif() if(flatbuffers_schema_files) diff --git a/cmake/developer_package/linux_name.cmake b/cmake/developer_package/linux_name.cmake index de9827ee921..9cd0ff82cde 100644 --- a/cmake/developer_package/linux_name.cmake +++ b/cmake/developer_package/linux_name.cmake @@ -2,41 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # -include(target_flags) - -# TODO: remove this function: we must not have conditions for particular OS names or versions - -# cmake needs to look at /etc files only when we build for Linux on Linux -if(CMAKE_HOST_LINUX AND LINUX) - function(get_linux_name res_var) - 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]+)?)") - 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}) - - string(REGEX MATCH ${version_regex} version ${release_data}) - set(os_name "${os_name} ${CMAKE_MATCH_1}") - - if(os_name) - set(${res_var} ${os_name} PARENT_SCOPE) - else () - set(${res_var} NOTFOUND PARENT_SCOPE) - endif () - endfunction() -else() - function(get_linux_name res_var) - set(${res_var} NOTFOUND PARENT_SCOPE) - endfunction() -endif () +function(get_linux_name res_var) + set(${res_var} NOTFOUND PARENT_SCOPE) +endfunction() diff --git a/cmake/developer_package/packaging/common-libraries.cmake b/cmake/developer_package/packaging/common-libraries.cmake index 26bee3ca8a9..34cc0beb28e 100644 --- a/cmake/developer_package/packaging/common-libraries.cmake +++ b/cmake/developer_package/packaging/common-libraries.cmake @@ -25,7 +25,7 @@ macro(ov_common_libraries_cpack_set_dirs) 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_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc/openvino-${OpenVINO_VERSION}) + set(OV_CPACK_LICENSESDIR licenses) ov_get_pyversion(pyversion) if(pyversion) diff --git a/cmake/developer_package/packaging/debian/debian.cmake b/cmake/developer_package/packaging/debian/debian.cmake index 64598f119cd..a649ab6c59c 100644 --- a/cmake/developer_package/packaging/debian/debian.cmake +++ b/cmake/developer_package/packaging/debian/debian.cmake @@ -31,6 +31,7 @@ macro(ov_debian_cpack_set_dirs) 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_LICENSESDIR ${OV_CPACK_DOCDIR}/licenses) set(OV_CPACK_PYTHONDIR lib/python3/dist-packages) # non-native stuff diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake index 8925f576f1e..076cb9a612f 100644 --- a/cmake/developer_package/packaging/packaging.cmake +++ b/cmake/developer_package/packaging/packaging.cmake @@ -29,6 +29,7 @@ macro(ov_cpack_set_dirs) set(OV_CPACK_NGRAPH_CMAKEDIR runtime/cmake) set(OV_CPACK_OPENVINO_CMAKEDIR runtime/cmake) set(OV_CPACK_DOCDIR docs) + set(OV_CPACK_LICENSESDIR ${OV_CPACK_DOCDIR}/licenses) set(OV_CPACK_SAMPLESDIR samples) set(OV_CPACK_WHEELSDIR tools) set(OV_CPACK_TOOLSDIR tools) @@ -99,10 +100,10 @@ endif() # if is a symlink, we resolve it, but install file with a name of symlink # function(ov_install_with_name file component) - if((APPLE AND file MATCHES "^[^\.]+\.[0-9]+${CMAKE_SHARED_LIBRARY_SUFFIX}$") OR - (file MATCHES "^.*\.${CMAKE_SHARED_LIBRARY_SUFFIX}\.[0-9]+$")) + get_filename_component(actual_name "${file}" NAME) + if((APPLE AND actual_name MATCHES "^[^\.]+\.[0-9]+${CMAKE_SHARED_LIBRARY_SUFFIX}$") OR + (actual_name MATCHES "^.*\.${CMAKE_SHARED_LIBRARY_SUFFIX}\.[0-9]+$")) if(IS_SYMLINK "${file}") - get_filename_component(actual_name "${file}" NAME) get_filename_component(file "${file}" REALPATH) set(install_rename RENAME "${actual_name}") endif() @@ -162,7 +163,7 @@ elseif(CPACK_GENERATOR STREQUAL "RPM") include(packaging/rpm/rpm) elseif(CPACK_GENERATOR STREQUAL "NSIS") include(packaging/nsis) -elseif(CPACK_GENERATOR MATCHES "^(CONDA-FORGE|BREW)$") +elseif(CPACK_GENERATOR MATCHES "^(CONDA-FORGE|BREW|CONAN)$") include(packaging/common-libraries) endif() diff --git a/cmake/developer_package/packaging/rpm/rpm.cmake b/cmake/developer_package/packaging/rpm/rpm.cmake index 22a83a77386..f884341987f 100644 --- a/cmake/developer_package/packaging/rpm/rpm.cmake +++ b/cmake/developer_package/packaging/rpm/rpm.cmake @@ -22,6 +22,11 @@ macro(ov_rpm_cpack_set_dirs) 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_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc/openvino-${OpenVINO_VERSION}) + set(OV_CPACK_LICENSESDIR ${OV_CPACK_DOCDIR}/licenses) + + # TODO: + # 1. define python installation directories for RPM packages + # 2. make sure only a single version of python API can be installed at the same time (define conflicts section) # set(OV_CPACK_PYTHONDIR lib/python3/dist-packages) ov_get_pyversion(pyversion) diff --git a/cmake/developer_package/target_flags.cmake b/cmake/developer_package/target_flags.cmake index 0a37c910ae8..ced8d519da3 100644 --- a/cmake/developer_package/target_flags.cmake +++ b/cmake/developer_package/target_flags.cmake @@ -17,20 +17,44 @@ if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") - set(arch_flag X86_64) + set(host_arch_flag X86_64) elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*") - set(arch_flag X86) + set(host_arch_flag X86) elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(arm64.*|aarch64.*|AARCH64.*|ARM64.*)") - set(arch_flag AARCH64) + set(host_arch_flag AARCH64) elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") - set(arch_flag ARM) + set(host_arch_flag ARM) elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^riscv64$") - set(arch_flag RISCV64) + set(host_arch_flag RISCV64) endif() -set(HOST_${arch_flag} ON) +set(HOST_${host_arch_flag} ON) -macro(_ie_process_msvc_generator_platform arch_flag) +macro(_ov_detect_arch_by_processor_type) + if(CMAKE_OSX_ARCHITECTURES AND APPLE) + if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") + set(AARCH64 ON) + elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64") + set(X86_64 ON) + elseif(CMAKE_OSX_ARCHITECTURES MATCHES ".*x86_64.*" AND CMAKE_OSX_ARCHITECTURES MATCHES ".*arm64.*") + set(UNIVERSAL2 ON) + else() + message(FATAL_ERROR "Unsupported value: CMAKE_OSX_ARCHITECTURES = ${CMAKE_OSX_ARCHITECTURES}") + endif() + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") + set(X86_64 ON) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*|wasm") + set(X86 ON) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64.*|aarch64.*|AARCH64.*|ARM64.*|armv8)") + set(AARCH64 ON) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") + set(ARM ON) + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64$") + set(RISCV64 ON) + endif() +endmacro() + +macro(_ov_process_msvc_generator_platform) # if cmake -A is passed if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") set(AARCH64 ON) @@ -41,45 +65,30 @@ macro(_ie_process_msvc_generator_platform arch_flag) elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32") set(X86 ON) else() - set(${arch_flag} ON) + _ov_detect_arch_by_processor_type() endif() endmacro() +# TODO: why OpenCV is found by cmake if(MSVC64 OR MINGW64) - _ie_process_msvc_generator_platform(${arch_flag}) + _ov_process_msvc_generator_platform() elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING)) - _ie_process_msvc_generator_platform(${arch_flag}) -elseif(CMAKE_OSX_ARCHITECTURES AND APPLE) - if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") - set(AARCH64 ON) - elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64") - set(X86_64 ON) - elseif(CMAKE_OSX_ARCHITECTURES MATCHES ".*x86_64.*" AND CMAKE_OSX_ARCHITECTURES MATCHES ".*arm64.*") - set(UNIVERSAL2 ON) - else() - message(FATAL_ERROR "Unsupported value: CMAKE_OSX_ARCHITECTURES = ${CMAKE_OSX_ARCHITECTURES}") - endif() -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") - set(X86_64 ON) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*") - set(X86 ON) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64.*|aarch64.*|AARCH64.*|ARM64.*)") - set(AARCH64 ON) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") - set(ARM ON) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64$") - set(RISCV64 ON) + _ov_process_msvc_generator_platform() +else() + _ov_detect_arch_by_processor_type() endif() if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") set(EMSCRIPTEN ON) endif() -if(UNIX AND NOT (APPLE OR ANDROID OR EMSCRIPTEN)) +if(UNIX AND NOT (APPLE OR ANDROID OR EMSCRIPTEN OR CYGWIN)) set(LINUX ON) endif() -if(NOT DEFINED CMAKE_HOST_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") +if(CMAKE_VERSION VERSION_LESS 3.25 AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + # the variable is available since 3.25 + # https://cmake.org/cmake/help/latest/variable/CMAKE_HOST_LINUX.html set(CMAKE_HOST_LINUX ON) endif() diff --git a/cmake/developer_package/whole_archive.cmake b/cmake/developer_package/whole_archive.cmake index b1d6f72b87c..ae5d56aa5d0 100644 --- a/cmake/developer_package/whole_archive.cmake +++ b/cmake/developer_package/whole_archive.cmake @@ -40,6 +40,7 @@ function(ieTargetLinkWholeArchive targetName) "-Wl,-noall_load" ) else() + # non-Apple Clang and GCC / MinGW list(APPEND libs "-Wl,--whole-archive" ${staticLib} diff --git a/cmake/features.cmake b/cmake/features.cmake index 99a49a3fde4..e896294bf14 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -22,7 +22,7 @@ else() set(ENABLE_INTEL_GPU_DEFAULT OFF) endif() -ie_dependent_option (ENABLE_INTEL_GPU "GPU OpenCL-based plugin for OpenVINO Runtime" ${ENABLE_INTEL_GPU_DEFAULT} "X86_64 OR AARCH64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) +ie_dependent_option (ENABLE_INTEL_GPU "GPU OpenCL-based plugin for OpenVINO Runtime" ${ENABLE_INTEL_GPU_DEFAULT} "X86_64 OR AARCH64;NOT APPLE;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) if (ANDROID OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)) # oneDNN doesn't support old compilers and android builds for now, so we'll @@ -34,6 +34,10 @@ endif() ie_dependent_option (ENABLE_ONEDNN_FOR_GPU "Enable oneDNN with GPU support" ${ENABLE_ONEDNN_FOR_GPU_DEFAULT} "ENABLE_INTEL_GPU" OFF) +ie_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF) +ie_dependent_option (ENABLE_GPU_DEBUG_CAPS "enable GPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS;ENABLE_INTEL_CPU" OFF) +ie_dependent_option (ENABLE_CPU_DEBUG_CAPS "enable CPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS;ENABLE_INTEL_GPU" OFF) + ie_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pre-built ittnotify library though INTEL_VTUNE_DIR variable." OFF) ie_option_enum(ENABLE_PROFILING_FILTER "Enable or disable ITT counter groups.\ @@ -81,19 +85,16 @@ ie_dependent_option (ENABLE_TBBBIND_2_5 "Enable TBBBind_2_5 static usage in Open ie_dependent_option (ENABLE_INTEL_GNA "GNA support for OpenVINO Runtime" ON "NOT APPLE;NOT ANDROID;X86_64;CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.4" OFF) -ie_option (ENABLE_INTEL_GNA_DEBUG "GNA debug build" OFF) - +ie_dependent_option (ENABLE_INTEL_GNA_DEBUG "GNA debug build" OFF "ENABLE_INTEL_GNA" OFF) +ie_dependent_option (ENABLE_V7_SERIALIZE "enables serialization to IR v7" OFF "ENABLE_INTEL_GNA" OFF) ie_dependent_option (ENABLE_IR_V7_READER "Enables IR v7 reader" ${BUILD_SHARED_LIBS} "ENABLE_TESTS;ENABLE_INTEL_GNA" OFF) -ie_option (ENABLE_GAPI_PREPROCESSING "Enables G-API preprocessing" ON) +ie_dependent_option (ENABLE_GAPI_PREPROCESSING "Enables G-API preprocessing" ON "NOT MINGW64" OFF) ie_option (ENABLE_MULTI "Enables MULTI Device Plugin" ON) ie_option (ENABLE_AUTO "Enables AUTO Device Plugin" ON) - ie_option (ENABLE_AUTO_BATCH "Enables Auto-Batching Plugin" ON) - ie_option (ENABLE_HETERO "Enables Hetero Device Plugin" ON) - ie_option (ENABLE_TEMPLATE "Enable template plugin" ON) ie_dependent_option (ENABLE_PLUGINS_XML "Generate plugins.xml configuration file or not" OFF "BUILD_SHARED_LIBS" OFF) @@ -102,20 +103,27 @@ ie_dependent_option (GAPI_TEST_PERF "if GAPI unit tests should examine performan ie_dependent_option (ENABLE_DATA "fetch models from testdata repo" ON "ENABLE_FUNCTIONAL_TESTS;NOT ANDROID" OFF) -ie_dependent_option (ENABLE_BEH_TESTS "tests oriented to check OpenVINO Runtime API correctness" ON "ENABLE_TESTS" OFF) - ie_dependent_option (ENABLE_FUNCTIONAL_TESTS "functional tests" ON "ENABLE_TESTS" OFF) ie_option (ENABLE_SAMPLES "console samples are part of OpenVINO Runtime package" ON) ie_option (ENABLE_OPENCV "enables custom OpenCV download" OFF) -ie_option (ENABLE_V7_SERIALIZE "enables serialization to IR v7" OFF) - set(OPENVINO_EXTRA_MODULES "" CACHE STRING "Extra paths for extra modules to include into OpenVINO build") ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are linked to the OpenVINO Runtime binaries" ON "THREADING MATCHES TBB;LINUX" OFF) +find_host_package(PythonInterp 3 QUIET) +ie_option(ENABLE_OV_ONNX_FRONTEND "Enable ONNX FrontEnd" ${PYTHONINTERP_FOUND}) +ie_option(ENABLE_OV_PADDLE_FRONTEND "Enable PaddlePaddle FrontEnd" ON) +ie_option(ENABLE_OV_IR_FRONTEND "Enable IR FrontEnd" ON) +ie_option(ENABLE_OV_PYTORCH_FRONTEND "Enable PyTorch FrontEnd" ON) +ie_option(ENABLE_OV_IR_FRONTEND "Enable IR FrontEnd" ON) +ie_option(ENABLE_OV_TF_FRONTEND "Enable TensorFlow FrontEnd" ON) +ie_option(ENABLE_OV_TF_LITE_FRONTEND "Enable TensorFlow Lite FrontEnd" ON) +ie_dependent_option(ENABLE_SNAPPY_COMPRESSION "Enables compression support for TF FE" ON + "ENABLE_OV_TF_FRONTEND" ON) + if(CMAKE_HOST_LINUX AND LINUX) # Debian packages are enabled on Ubuntu systems # so, system TBB / pugixml / OpenCL can be tried for usage @@ -131,40 +139,37 @@ else() set(ENABLE_SYSTEM_TBB_DEFAULT ${ENABLE_SYSTEM_LIBS_DEFAULT}) endif() +if(BUILD_SHARED_LIBS) + set(ENABLE_SYSTEM_PUGIXML_DEFAULT ${ENABLE_SYSTEM_LIBS_DEFAULT}) +else() + # for static libraries case libpugixml.a must be compiled with -fPIC + # but we still need an ability to compile with system PugiXML and BUILD_SHARED_LIBS + # for Conan case where everything is compiled statically + set(ENABLE_SYSTEM_PUGIXML_DEFAULT OFF) +endif() + # users wants to use his own TBB version, specific either via env vars or cmake options if(DEFINED ENV{TBBROOT} OR DEFINED ENV{TBB_DIR} OR DEFINED TBB_DIR OR DEFINED TBBROOT) set(ENABLE_SYSTEM_TBB_DEFAULT OFF) endif() -# for static libraries case libpugixml.a must be compiled with -fPIC -ie_dependent_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" ${ENABLE_SYSTEM_LIBS_DEFAULT} "BUILD_SHARED_LIBS" OFF) - -ie_dependent_option (ENABLE_SYSTEM_TBB "use the system version of TBB" ${ENABLE_SYSTEM_TBB_DEFAULT} "THREADING MATCHES TBB" OFF) - -ie_dependent_option (ENABLE_SYSTEM_OPENCL "Use the system version of OpenCL" ${ENABLE_SYSTEM_LIBS_DEFAULT} "BUILD_SHARED_LIBS;ENABLE_INTEL_GPU" OFF) - -ie_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF) - -ie_dependent_option (ENABLE_GPU_DEBUG_CAPS "enable GPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS" OFF) - -ie_dependent_option (ENABLE_CPU_DEBUG_CAPS "enable CPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS" OFF) - -find_host_package(PythonInterp 3 QUIET) -ie_option(ENABLE_OV_ONNX_FRONTEND "Enable ONNX FrontEnd" ${PYTHONINTERP_FOUND}) -ie_option(ENABLE_OV_PADDLE_FRONTEND "Enable PaddlePaddle FrontEnd" ON) -ie_option(ENABLE_OV_IR_FRONTEND "Enable IR FrontEnd" ON) -ie_option(ENABLE_OV_PYTORCH_FRONTEND "Enable PyTorch FrontEnd" ON) -ie_option(ENABLE_OV_TF_FRONTEND "Enable TensorFlow FrontEnd" ON) -ie_option(ENABLE_OV_TF_LITE_FRONTEND "Enable TensorFlow Lite FrontEnd" ON) -ie_option(ENABLE_OV_IR_FRONTEND "Enable IR FrontEnd" ON) - -ie_dependent_option(ENABLE_SNAPPY_COMPRESSION "Enables compression support for TF FE" ON - "ENABLE_OV_TF_FRONTEND" ON) -ie_dependent_option(ENABLE_SYSTEM_PROTOBUF "Enables use of system protobuf" OFF - "ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_TF_FRONTEND;BUILD_SHARED_LIBS" OFF) +ie_dependent_option (ENABLE_SYSTEM_TBB "Enables use of system TBB" ${ENABLE_SYSTEM_TBB_DEFAULT} + "THREADING MATCHES TBB" OFF) +# TODO: turn it off by default during the work on cross-os distribution, because pugixml is not +# available out of box on all systems (like RHEL, UBI) +ie_option (ENABLE_SYSTEM_PUGIXML "Enables use of system PugiXML" ${ENABLE_SYSTEM_PUGIXML_DEFAULT}) +# the option is on by default, because we use only flatc compiler and don't use any libraries ie_dependent_option(ENABLE_SYSTEM_FLATBUFFERS "Enables use of system flatbuffers" ON "ENABLE_OV_TF_LITE_FRONTEND" OFF) -ie_dependent_option(ENABLE_SYSTEM_SNAPPY "Enables use of system version of snappy" OFF "ENABLE_SNAPPY_COMPRESSION;BUILD_SHARED_LIBS" OFF) +ie_dependent_option (ENABLE_SYSTEM_OPENCL "Enables use of system OpenCL" ${ENABLE_SYSTEM_LIBS_DEFAULT} + "ENABLE_INTEL_GPU" OFF) +# the option is turned off by default, because we compile our own static version of protobuf +# with LTO and -fPIC options, while system one does not have such flags +ie_dependent_option (ENABLE_SYSTEM_PROTOBUF "Enables use of system Protobuf" OFF + "ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_TF_FRONTEND" OFF) +# the option is turned off by default, because we don't want to have a dependency on libsnappy.so +ie_dependent_option (ENABLE_SYSTEM_SNAPPY "Enables use of system version of Snappy" OFF + "ENABLE_SNAPPY_COMPRESSION" OFF) ie_option(ENABLE_OPENVINO_DEBUG "Enable output for OPENVINO_DEBUG statements" OFF) diff --git a/cmake/packaging/common-libraries.cmake b/cmake/packaging/common-libraries.cmake index d95f467a97b..26dfdea0620 100644 --- a/cmake/packaging/common-libraries.cmake +++ b/cmake/packaging/common-libraries.cmake @@ -10,8 +10,8 @@ macro(ov_cpack_settings) set(cpack_components_all ${CPACK_COMPONENTS_ALL}) unset(CPACK_COMPONENTS_ALL) foreach(item IN LISTS cpack_components_all) - # filter out some components, which are not needed to be wrapped to conda-forge | brew - if(# python is not a part of conda | brew + # filter out some components, which are not needed to be wrapped to conda-forge | brew | conan + if(# python is not a part of conda | brew | conan NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO}_python.*" AND # python wheels are not needed to be wrapped by conda | brew packages NOT item STREQUAL OV_CPACK_COMP_PYTHON_WHEELS AND diff --git a/cmake/packaging/packaging.cmake b/cmake/packaging/packaging.cmake index 86e0bb91737..7ebbf6f9bc0 100644 --- a/cmake/packaging/packaging.cmake +++ b/cmake/packaging/packaging.cmake @@ -6,7 +6,7 @@ if(CPACK_GENERATOR STREQUAL "DEB") include(cmake/packaging/debian.cmake) elseif(CPACK_GENERATOR STREQUAL "RPM") include(cmake/packaging/rpm.cmake) -elseif(CPACK_GENERATOR MATCHES "^(CONDA-FORGE|BREW)$") +elseif(CPACK_GENERATOR MATCHES "^(CONDA-FORGE|BREW|CONAN)$") include(cmake/packaging/common-libraries.cmake) elseif(CPACK_GENERATOR STREQUAL "NSIS") include(cmake/packaging/nsis.cmake) diff --git a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in index 8708f9164be..56a610cc39e 100644 --- a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in +++ b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in @@ -142,6 +142,14 @@ if(ENABLE_SYSTEM_PUGIXML) endif() endif() +set(_IE_nlohmann_json_FOUND "@nlohmann_json_FOUND@") +if(_IE_nlohmann_json_FOUND) + find_dependency(nlohmann_json) + set_target_properties(nlohmann_json::nlohmann_json PROPERTIES IMPORTED_GLOBAL ON) + add_library(IE::nlohmann_json ALIAS nlohmann_json::nlohmann_json) +endif() +unset(_IE_nlohmann_json_FOUND) + # inherit OpenCV from main IE project if enabled if ("@OpenCV_FOUND@") load_cache("${cache_path}" READ_WITH_PREFIX "" OpenCV_DIR) diff --git a/cmake/templates/OpenVINOConfig.cmake.in b/cmake/templates/OpenVINOConfig.cmake.in index cf1f321ae35..bd986a23943 100644 --- a/cmake/templates/OpenVINOConfig.cmake.in +++ b/cmake/templates/OpenVINOConfig.cmake.in @@ -85,9 +85,9 @@ # # `OpenVINO_VERSION_MAJOR` # Major version component -# +# # `OpenVINO_VERSION_MINOR` -# minor version component +# Minor version component # # `OpenVINO_VERSION_PATCH` # Patch version component @@ -138,7 +138,7 @@ endmacro() macro(_ov_find_tbb) set(THREADING "@THREADING@") - if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND NOT TBB_FOUND) + if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") set(enable_pkgconfig_tbb "@tbb_FOUND@") # try tbb.pc @@ -153,10 +153,10 @@ macro(_ov_find_tbb) endif() pkg_search_module(tbb - ${pkg_config_quiet_arg} - ${pkg_config_required_arg} - IMPORTED_TARGET - tbb) + ${pkg_config_quiet_arg} + ${pkg_config_required_arg} + IMPORTED_TARGET + tbb) unset(pkg_config_quiet_arg) unset(pkg_config_required_arg) @@ -223,28 +223,185 @@ macro(_ov_find_tbb) PATHS ${_tbb_bind_dir} NO_CMAKE_FIND_ROOT_PATH NO_DEFAULT_PATH) - set_target_properties(${TBBBIND_2_5_IMPORTED_TARGETS} PROPERTIES IMPORTED_GLOBAL ON) unset(_tbb_bind_dir) endif() unset(install_tbbbind) endif() endmacro() +macro(_ov_find_pugixml) + set(_OV_ENABLE_SYSTEM_PUGIXML "@ENABLE_SYSTEM_PUGIXML@") + if(_OV_ENABLE_SYSTEM_PUGIXML) + set(_ov_pugixml_pkgconfig_interface "@pugixml_FOUND@") + set(_ov_pugixml_cmake_interface "@PugiXML_FOUND@") + + if(_ov_pugixml_pkgconfig_interface AND NOT ANDROID) + _ov_find_dependency(PkgConfig) + elseif(_ov_pugixml_cmake_interface) + _ov_find_dependency(PugiXML REQUIRED) + endif() + + if(PugiXML_FOUND) + if(TARGET pugixml) + set(_ov_pugixml_target pugixml) + elseif(TARGET pugixml::pugixml) + set(_ov_pugixml_target pugixml::pugixml) + endif() + if(OpenVINODeveloperPackage_DIR) + set_property(TARGET ${_ov_pugixml_target} PROPERTY IMPORTED_GLOBAL ON) + # align with build tree + add_library(openvino::pugixml ALIAS ${_ov_pugixml_target}) + endif() + unset(_ov_pugixml_target) + elseif(PkgConfig_FOUND) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(pkg_config_quiet_arg QUIET) + endif() + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + set(pkg_config_required_arg REQUIRED) + endif() + + pkg_search_module(pugixml + ${pkg_config_quiet_arg} + ${pkg_config_required_arg} + IMPORTED_TARGET + GLOBAL + pugixml) + + unset(pkg_config_quiet_arg) + unset(pkg_config_required_arg) + + if(pugixml_FOUND) + if(OpenVINODeveloperPackage_DIR) + add_library(openvino::pugixml ALIAS PkgConfig::pugixml) + endif() + + # PATCH: on Ubuntu 18.04 pugixml.pc contains incorrect include directories + get_target_property(interface_include_dir PkgConfig::pugixml INTERFACE_INCLUDE_DIRECTORIES) + if(interface_include_dir AND NOT EXISTS "${interface_include_dir}") + set_target_properties(PkgConfig::pugixml PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "") + endif() + endif() + endif() + + # debian 9 case: no cmake, no pkg-config files + if(NOT TARGET openvino::pugixml) + find_library(PUGIXML_LIBRARY NAMES pugixml DOC "Path to pugixml library") + if(PUGIXML_LIBRARY) + add_library(openvino::pugixml INTERFACE IMPORTED) + set_target_properties(openvino::pugixml PROPERTIES INTERFACE_LINK_LIBRARIES "${PUGIXML_LIBRARY}") + else() + message(FATAL_ERROR "Failed to find system pugixml in OpenVINO Developer Package") + endif() + endif() + endif() +endmacro() + +macro(_ov_find_itt) + set(_ENABLE_PROFILING_ITT "@ENABLE_PROFILING_ITT@") + # whether 'ittapi' is found via find_package + set(_ENABLE_SYSTEM_ITTAPI "@ittapi_FOUND@") + if(_ENABLE_PROFILING_ITT AND _ENABLE_SYSTEM_ITTAPI) + _ov_find_dependency(ittapi) + endif() + unset(_ENABLE_PROFILING_ITT) + unset(_ENABLE_SYSTEM_ITTAPI) +endmacro() + +macro(_ov_find_ade) + set(_OV_ENABLE_GAPI_PREPROCESSING "@ENABLE_GAPI_PREPROCESSING@") + # whether 'ade' is found via find_package + set(_ENABLE_SYSTEM_ADE "@ade_FOUND@") + if(_OV_ENABLE_GAPI_PREPROCESSING AND _ENABLE_SYSTEM_ADE) + _ov_find_dependency(ade 0.1.2) + endif() + unset(_OV_ENABLE_GAPI_PREPROCESSING) + unset(_ENABLE_SYSTEM_ADE) +endmacro() + +macro(_ov_find_intel_cpu_dependencies) + set(_OV_ENABLE_CPU_ACL "@DNNL_USE_ACL@") + if(_OV_ENABLE_CPU_ACL) + if(_ov_as_external_package) + set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_ARM_COMPUTE_LIB_DIR@") + set(_ov_find_acl_options NO_DEFAULT_PATH) + set(_ov_find_acl_path "${CMAKE_CURRENT_LIST_DIR}") + else() + set_and_check(_ov_find_acl_path "@PACKAGE_FIND_ACL_PATH@") + endif() + + _ov_find_dependency(ACL + NO_MODULE + PATHS "${_ov_find_acl_path}" + ${_ov_find_acl_options}) + + unset(ARM_COMPUTE_LIB_DIR) + unset(_ov_find_acl_path) + unset(_ov_find_acl_options) + endif() + unset(_OV_ENABLE_CPU_ACL) +endmacro() + +macro(_ov_find_intel_gpu_dependencies) + set(_OV_ENABLE_INTEL_GPU "@ENABLE_INTEL_GPU@") + set(_OV_ENABLE_SYSTEM_OPENCL "@ENABLE_SYSTEM_OPENCL@") + if(_OV_ENABLE_INTEL_GPU AND _OV_ENABLE_SYSTEM_OPENCL) + set(_OV_OpenCLICDLoader_FOUND "@OpenCLICDLoader_FOUND@") + if(_OV_OpenCLICDLoader_FOUND) + _ov_find_dependency(OpenCLICDLoader) + else() + _ov_find_dependency(OpenCL) + endif() + unset(_OV_OpenCLICDLoader_FOUND) + endif() + unset(_OV_ENABLE_INTEL_GPU) + unset(_OV_ENABLE_SYSTEM_OPENCL) +endmacro() + macro(_ov_find_intel_gna_dependencies) set(_OV_ENABLE_INTEL_GNA "@ENABLE_INTEL_GNA@") - if(_OV_ENABLE_INTEL_GNA AND NOT libGNA_FOUND) + if(_OV_ENABLE_INTEL_GNA) set_and_check(GNA_PATH "@PACKAGE_GNA_PATH@") _ov_find_dependency(libGNA COMPONENTS KERNEL CONFIG PATHS "${CMAKE_CURRENT_LIST_DIR}" - NO_CMAKE_FIND_ROOT_PATH NO_DEFAULT_PATH) unset(GNA_PATH) endif() unset(_OV_ENABLE_INTEL_GNA) endmacro() +macro(_ov_find_protobuf_frontend_dependency) + set(_OV_ENABLE_SYSTEM_PROTOBUF "@ENABLE_SYSTEM_PROTOBUF@") + # TODO: remove check for target existence + if(_OV_ENABLE_SYSTEM_PROTOBUF AND NOT TARGET protobuf::libprotobuf) + _ov_find_dependency(Protobuf @Protobuf_VERSION@ EXACT) + endif() + unset(_OV_ENABLE_SYSTEM_PROTOBUF) +endmacro() + +macro(_ov_find_tensorflow_frontend_dependencies) + set(_OV_ENABLE_SYSTEM_SNAPPY "@ENABLE_SYSTEM_SNAPPY@") + set(_ov_snappy_lib "@ov_snappy_lib@") + # TODO: remove check for target existence + if(_OV_ENABLE_SYSTEM_SNAPPY AND NOT TARGET ${_ov_snappy_lib}) + _ov_find_dependency(Snappy @Snappy_VERSION@ EXACT) + endif() + unset(_OV_ENABLE_SYSTEM_SNAPPY) + unset(_ov_snappy_lib) + set(PACKAGE_PREFIX_DIR ${_ov_package_prefix_dir}) +endmacro() + +macro(_ov_find_onnx_frontend_dependencies) + set(_OV_ENABLE_SYSTEM_ONNX "@ENABLE_SYSTEM_ONNX@") + if(_OV_ENABLE_SYSTEM_ONNX) + _ov_find_dependency(ONNX @ONNX_VERSION@ EXACT) + endif() + unset(_OV_ENABLE_SYSTEM_ONNX) +endmacro() + function(_ov_target_no_deprecation_error) if(NOT MSVC) if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") @@ -270,8 +427,28 @@ set(_ov_package_prefix_dir "${PACKAGE_PREFIX_DIR}") set(_OV_ENABLE_OPENVINO_BUILD_SHARED "@BUILD_SHARED_LIBS@") +if(NOT TARGET openvino) + set(_ov_as_external_package ON) +endif() + if(NOT _OV_ENABLE_OPENVINO_BUILD_SHARED) + # common openvino dependencies _ov_find_tbb() + + _ov_find_itt() + _ov_find_pugixml() + + # preprocessing dependencies + _ov_find_ade() + + # frontend dependencies + _ov_find_protobuf_frontend_dependency() + _ov_find_tensorflow_frontend_dependencies() + _ov_find_onnx_frontend_dependencies() + + # plugin dependencies + _ov_find_intel_cpu_dependencies() + _ov_find_intel_gpu_dependencies() _ov_find_intel_gna_dependencies() endif() @@ -279,13 +456,26 @@ _ov_find_dependency(Threads) unset(_OV_ENABLE_OPENVINO_BUILD_SHARED) -if(NOT TARGET openvino) - set(_ov_as_external_package ON) +set(_ov_imported_libs openvino::runtime openvino::runtime::c + openvino::frontend::onnx openvino::frontend::paddle openvino::frontend::tensorflow + openvino::frontend::pytorch openvino::frontend::tensorflow_lite) + +if(_ov_as_external_package) include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake") + foreach(target IN LISTS _ov_imported_libs) + if(TARGET ${target}) + get_target_property(imported_configs ${target} IMPORTED_CONFIGURATIONS) + if(NOT RELWITHDEBINFO IN_LIST imported_configs) + set_property(TARGET ${target} PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE) + endif() + unset(imported_configs) + endif() + endforeach() + # WA for cmake version < 3.16 which does not export # IMPORTED_LINK_DEPENDENT_LIBRARIES_** properties if no PUBLIC dependencies for the library - if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND TBB_FOUND) + if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") foreach(type RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) foreach(tbb_target TBB::tbb TBB::tbbmalloc PkgConfig::tbb) if(TARGET ${tbb_target}) @@ -326,12 +516,12 @@ endif() # Apply common functions # -foreach(target openvino::runtime openvino::runtime::c - openvino::frontend::onnx openvino::frontend::paddle openvino::frontend::tensorflow) +foreach(target IN LISTS _ov_imported_libs) if(TARGET ${target} AND _ov_as_external_package) _ov_target_no_deprecation_error(${target}) endif() endforeach() +unset(_ov_imported_libs) unset(_ov_as_external_package) # restore PACKAGE_PREFIX_DIR diff --git a/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in b/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in index d530ea36d1d..277873a29bc 100644 --- a/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in +++ b/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in @@ -56,6 +56,7 @@ find_dependency(OpenVINO NO_DEFAULT_PATH) _ov_find_tbb() +_ov_find_pugixml() foreach(component @openvino_export_components@) # TODO: remove legacy targets from some tests @@ -65,58 +66,6 @@ foreach(component @openvino_export_components@) # endif() endforeach() -if(ENABLE_SYSTEM_PUGIXML) - set(_ov_pugixml_pkgconfig_interface "@pugixml_FOUND@") - set(_ov_pugixml_cmake_interface "@PugiXML_FOUND@") - if(_ov_pugixml_pkgconfig_interface) - find_dependency(PkgConfig) - elseif(_ov_pugixml_cmake_interface) - find_dependency(PugiXML) - endif() - if(PugiXML_FOUND) - set_property(TARGET pugixml PROPERTY IMPORTED_GLOBAL TRUE) - add_library(openvino::pugixml ALIAS pugixml) - elseif(PkgConfig_FOUND) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(pkg_config_quiet_arg QUIET) - endif() - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(pkg_config_required_arg REQUIRED) - endif() - - pkg_search_module(pugixml - ${pkg_config_quiet_arg} - ${pkg_config_required_arg} - IMPORTED_TARGET GLOBAL - pugixml) - - unset(pkg_config_quiet_arg) - unset(pkg_config_required_arg) - - if(pugixml_FOUND) - add_library(openvino::pugixml ALIAS PkgConfig::pugixml) - - # PATCH: on Ubuntu 18.04 pugixml.pc contains incorrect include directories - get_target_property(interface_include_dir PkgConfig::pugixml INTERFACE_INCLUDE_DIRECTORIES) - if(interface_include_dir AND NOT EXISTS "${interface_include_dir}") - set_target_properties(PkgConfig::pugixml PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "") - endif() - endif() - endif() - - # debian 9 case: no cmake, no pkg-config files - if(NOT TARGET openvino::pugixml) - find_library(PUGIXML_LIBRARY NAMES pugixml DOC "Path to pugixml library") - if(PUGIXML_LIBRARY) - add_library(openvino::pugixml INTERFACE IMPORTED GLOBAL) - set_target_properties(openvino::pugixml PROPERTIES INTERFACE_LINK_LIBRARIES "${PUGIXML_LIBRARY}") - else() - message(FATAL_ERROR "Failed to find system pugixml in OpenVINO Developer Package") - endif() - endif() -endif() - # inherit OpenCV from main OpenVINO project if enabled if ("@OpenCV_FOUND@") load_cache("${cache_path}" READ_WITH_PREFIX "" OpenCV_DIR) diff --git a/cmake/toolchains/mingw-w64.toolchain.cmake b/cmake/toolchains/mingw-w64.toolchain.cmake new file mode 100644 index 00000000000..72aba14bc84 --- /dev/null +++ b/cmake/toolchains/mingw-w64.toolchain.cmake @@ -0,0 +1,95 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +# Prerequisites: +# +# Build platform: Ubuntu +# apt-get install mingw-w64 mingw-w64-tools g++-mingw-w64-x86-64 gcc-mingw-w64-x86-64 +# +# Build platform: macOS +# brew install mingw-w64 +# + +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix) +set(PKG_CONFIG_EXECUTABLE x86_64-w64-mingw32-pkg-config CACHE PATH "Path to Windows x86_64 pkg-config") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +macro(__cmake_find_root_save_and_reset) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(__save_${v} ${${v}}) + set(${v} NEVER) + endforeach() +endmacro() + +macro(__cmake_find_root_restore) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(${v} ${__save_${v}}) + unset(__save_${v}) + endforeach() +endmacro() + + +# macro to find programs on the host OS +macro(find_host_program) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + SET(APPLE) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + SET(WIN32) + elseif(CMAKE_HOST_UNIX) + SET(UNIX 1) + SET(WIN32) + SET(APPLE) + endif() + find_program(${ARGN}) + SET(WIN32 1) + SET(APPLE) + SET(UNIX) + __cmake_find_root_restore() +endmacro() + +# macro to find packages on the host OS +macro(find_host_package) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + SET(APPLE) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(WIN32) + SET(UNIX) + elseif(CMAKE_HOST_UNIX) + SET(UNIX 1) + SET(WIN32) + SET(APPLE) + endif() + find_package(${ARGN}) + SET(WIN32 1) + SET(APPLE) + SET(UNIX) + __cmake_find_root_restore() +endmacro() diff --git a/cmake/toolchains/riscv64-gnu.toolchain.cmake b/cmake/toolchains/riscv64-gnu.toolchain.cmake index b65b71c1919..eca47d1b950 100644 --- a/cmake/toolchains/riscv64-gnu.toolchain.cmake +++ b/cmake/toolchains/riscv64-gnu.toolchain.cmake @@ -24,7 +24,7 @@ set(CMAKE_LINKER ${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-ld) set(CMAKE_OBJCOPY ${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-objcopy) set(CMAKE_OBJDUMP ${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-objdump) set(CMAKE_READELF ${RISCV_TOOLCHAIN_ROOT}/bin/riscv64-unknown-linux-gnu-readelf) -set(PKG_CONFIG_EXECUTABLE "NOT-FOUND" CACHE PATH "Path to ARM64 pkg-config") +set(PKG_CONFIG_EXECUTABLE "NOT-FOUND" CACHE PATH "Path to RISC-V pkg-config") # Don't run the linker on compiler check set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) diff --git a/cmake/toolchains/x86_64.linux.toolchain.cmake b/cmake/toolchains/x86_64.linux.toolchain.cmake new file mode 100644 index 00000000000..7ce73bc1e71 --- /dev/null +++ b/cmake/toolchains/x86_64.linux.toolchain.cmake @@ -0,0 +1,75 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR amd64) + +set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) +set(CMAKE_STRIP x86_64-linux-gnu-strip) +set(PKG_CONFIG_EXECUTABLE "NOT-FOUND" CACHE PATH "Path to amd64 pkg-config") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +macro(__cmake_find_root_save_and_reset) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(__save_${v} ${${v}}) + set(${v} NEVER) + endforeach() +endmacro() + +macro(__cmake_find_root_restore) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(${v} ${__save_${v}}) + unset(__save_${v}) + endforeach() +endmacro() + + +# macro to find programs on the host OS +macro(find_host_program) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + endif() + find_program(${ARGN}) + SET(WIN32) + SET(APPLE) + SET(UNIX 1) + __cmake_find_root_restore() +endmacro() + +# macro to find packages on the host OS +macro(find_host_package) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + endif() + find_package(${ARGN}) + SET(WIN32) + SET(APPLE) + SET(UNIX 1) + __cmake_find_root_restore() +endmacro() diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 00000000000..085464edcdb --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,33 @@ +[requires] +ade/0.1.2a +onetbb/[>=2021.2.1] +pugixml/[>=1.10] +protobuf/[>=3.20.3] +ittapi/[>=3.23.0] +zlib/[>=1.2.8] +opencl-icd-loader/[>=2022.09.30] +# opencl-clhpp-headers/[>=2022.09.30] +opencl-headers/[>=2022.09.30] +xbyak/[>=6.62] +snappy/[>=1.1.7] +gflags/2.2.2 +onnx/1.13.1 +nlohmann_json/[>=3.1.1] +pybind11/[>=2.10.1] +flatbuffers/[>=22.9.24] + +[tool_requires] +cmake/[>=3.15] +patchelf/[>=0.12] +protobuf/[>=3.20.3] +flatbuffers/[>=22.9.24] + +[options] +protobuf/*:lite=True +onetbb/*:tbbmalloc=True +onetbb/*:tbbproxy=True +flatbuffers/*:header_only=True + +[generators] +CMakeDeps +CMakeToolchain \ No newline at end of file diff --git a/docs/snippets/example_ngraph_utils.cpp b/docs/snippets/example_ngraph_utils.cpp index ce429f85e3e..5e6a06b988f 100644 --- a/docs/snippets/example_ngraph_utils.cpp +++ b/docs/snippets/example_ngraph_utils.cpp @@ -43,6 +43,8 @@ parent_output = node->input_value(0); // Getting all consumers for output port auto consumers = output.get_target_inputs(); // ! [ngraph:ports_example] +(void)el_type; +(void)pshape; } { diff --git a/licensing/CMakeLists.txt b/licensing/CMakeLists.txt index 7ba3293acd7..632eb183595 100644 --- a/licensing/CMakeLists.txt +++ b/licensing/CMakeLists.txt @@ -9,7 +9,7 @@ ov_cpack_add_component(${OV_CPACK_COMP_LICENSING} HIDDEN) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${OV_CPACK_DOCDIR}/licensing + DESTINATION ${OV_CPACK_LICENSESDIR} COMPONENT ${OV_CPACK_COMP_LICENSING} PATTERN CMakeLists.txt EXCLUDE PATTERN dev-third-party-programs.txt EXCLUDE diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index d2a65618071..37eb0250112 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -54,23 +54,18 @@ set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}) set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}) -if (WIN32) - set_property (DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS") +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") # no asynchronous structured exception handling set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qdiag-disable:177") - endif() - # disable some noisy warnings - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275 /wd4267 /wd4819") - endif() -else() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable:177") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275 /wd4267 /wd4819") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qdiag-disable:177") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable:177") endif() endif() @@ -120,6 +115,9 @@ elseif(gflags_required) elseif(TARGET gflags-shared) # gflags shared case for CentOS / RHEL / Fedora set(GFLAGS_TARGET gflags-shared) + elseif(TARGET gflags::gflags) + # gflags case for Conan + set(GFLAGS_TARGET gflags::gflags) else() message(FATAL_ERROR "Internal error: failed to find imported target 'gflags' using '${gflags_component}' component") endif() diff --git a/samples/cpp/common/utils/include/samples/os/windows/w_dirent.h b/samples/cpp/common/utils/include/samples/os/windows/w_dirent.h index 897fd8407b0..dad337c1736 100644 --- a/samples/cpp/common/utils/include/samples/os/windows/w_dirent.h +++ b/samples/cpp/common/utils/include/samples/os/windows/w_dirent.h @@ -36,7 +36,7 @@ #include #include #include - #include + #include #include // clang-format on @@ -131,7 +131,7 @@ public: * @param string directory path * @return pointer to directory data struct element */ -static DIR* opendir(const char* dirPath) { +inline DIR* opendir(const char* dirPath) { auto dp = new DIR(dirPath); if (!dp->isValid()) { delete dp; @@ -145,7 +145,7 @@ static DIR* opendir(const char* dirPath) { * @param pointer to directory data struct * @return pointer to directory data struct next element */ -static struct dirent* readdir(DIR* dp) { +inline struct dirent* readdir(DIR* dp) { return dp->nextEnt(); } @@ -154,7 +154,7 @@ static struct dirent* readdir(DIR* dp) { * @param pointer to struct directory data * @return void */ -static void closedir(DIR* dp) { +inline void closedir(DIR* dp) { delete dp; } diff --git a/samples/cpp/speech_sample/CMakeLists.txt b/samples/cpp/speech_sample/CMakeLists.txt index 2b99a9fe136..1cae2491195 100644 --- a/samples/cpp/speech_sample/CMakeLists.txt +++ b/samples/cpp/speech_sample/CMakeLists.txt @@ -12,13 +12,15 @@ if(NOT ANDROID) find_package(PkgConfig QUIET) endif() -if(NOT TARGET zlib::zlib) +find_package(ZLIB QUIET) + +if(NOT TARGET ZLIB::ZLIB) if(PkgConfig_FOUND) pkg_search_module(zlib QUIET IMPORTED_TARGET GLOBAL zlib) if(zlib_FOUND) - add_library(zlib::zlib ALIAS PkgConfig::zlib) + add_library(ZLIB::ZLIB ALIAS PkgConfig::zlib) endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31f93f7f05d..658addde5bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,6 @@ include(cmake/install_tbb.cmake) # CC library should be registered before other cc targets add_subdirectory(common) -# TODO: Fix Wall for core, frontends and tests add_subdirectory(core) add_subdirectory(frontends) # TODO: remove ngraph/ngraph.hpp usage @@ -17,7 +16,6 @@ if(ENABLE_TESTS) endif() if(CMAKE_COMPILER_IS_GNUCXX) - ie_add_compiler_flags(-Wall) ie_add_compiler_flags(-Wmissing-declarations) endif() diff --git a/src/bindings/c/include/c_api/ie_c_api.h b/src/bindings/c/include/c_api/ie_c_api.h index 507675379fd..43ec4f97c29 100644 --- a/src/bindings/c/include/c_api/ie_c_api.h +++ b/src/bindings/c/include/c_api/ie_c_api.h @@ -37,7 +37,7 @@ # define INFERENCE_ENGINE_C_API(...) INFERENCE_ENGINE_C_API_EXTERN __VA_ARGS__ # define IE_NODISCARD #else -# if defined(_WIN32) +# if defined(_WIN32) || defined(__CYGWIN__) # define INFERENCE_ENGINE_C_API_CALLBACK __cdecl # ifdef openvino_c_EXPORTS # define INFERENCE_ENGINE_C_API(...) INFERENCE_ENGINE_C_API_EXTERN __declspec(dllexport) __VA_ARGS__ __cdecl diff --git a/src/bindings/c/include/openvino/c/deprecated.h b/src/bindings/c/include/openvino/c/deprecated.h index 0ca04b53d15..c06dbd36dc7 100644 --- a/src/bindings/c/include/openvino/c/deprecated.h +++ b/src/bindings/c/include/openvino/c/deprecated.h @@ -38,7 +38,14 @@ // so any use of `frobnicate` will produce a compiler warning. // -#if defined(_WIN32) +#if defined(__GNUC__) +# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) +# if __GNUC__ >= 6 || defined(__clang__) +# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +# else +# define OPENVINO_ENUM_DEPRECATED(msg) +# endif +#elif defined(_MSC_VER) # define OPENVINO_DEPRECATED(msg) __declspec(deprecated(msg)) # if __cplusplus >= 201402L # define OPENVINO_ENUM_DEPRECATED(msg) [[deprecated(msg)]] @@ -48,43 +55,36 @@ #elif defined(__INTEL_COMPILER) # define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) # define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) -#elif defined(__GNUC__) -# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) -# if __GNUC__ < 6 && !defined(__clang__) -# define OPENVINO_ENUM_DEPRECATED(msg) -# else -# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) -# endif #else # define OPENVINO_DEPRECATED(msg) # define OPENVINO_ENUM_DEPRECATED(msg) #endif // Suppress warning "-Wdeprecated-declarations" / C4996 -#if defined(_MSC_VER) -# define OPENVINO_DO_PRAGMA(x) __pragma(x) -#elif defined(__GNUC__) +#if defined(__GNUC__) # define OPENVINO_DO_PRAGMA(x) _Pragma(# x) +#elif defined(_MSC_VER) +# define OPENVINO_DO_PRAGMA(x) __pragma(x) #else # define OPENVINO_DO_PRAGMA(x) #endif -#if defined(_MSC_VER) && !defined(__clang__) +#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) || defined(__clang__) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(GCC diagnostic push) \ + OPENVINO_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(GCC diagnostic pop) +#elif defined(_MSC_VER) # define OPENVINO_SUPPRESS_DEPRECATED_START \ OPENVINO_DO_PRAGMA(warning(push)) \ OPENVINO_DO_PRAGMA(warning(disable : 4996)) # define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) #elif defined(__INTEL_COMPILER) -# define OPENVINO_SUPPRESS_DEPRECATED_START \ - OPENVINO_DO_PRAGMA(warning(push)) \ - OPENVINO_DO_PRAGMA(warning(disable : 1478)) -OPENVINO_DO_PRAGMA(warning(disable : 1786)) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(warning(push)) \ + OPENVINO_DO_PRAGMA(warning(disable : 1478)) \ + OPENVINO_DO_PRAGMA(warning(disable : 1786)) # define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) -#elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) -# define OPENVINO_SUPPRESS_DEPRECATED_START \ - OPENVINO_DO_PRAGMA(GCC diagnostic push) \ - OPENVINO_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") -# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(GCC diagnostic pop) #else # define OPENVINO_SUPPRESS_DEPRECATED_START # define OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/bindings/c/include/openvino/c/ov_common.h b/src/bindings/c/include/openvino/c/ov_common.h index 99f9322bfa9..b588abc58ed 100644 --- a/src/bindings/c/include/openvino/c/ov_common.h +++ b/src/bindings/c/include/openvino/c/ov_common.h @@ -14,18 +14,19 @@ #include #include -#ifndef ENABLE_UNICODE_PATH_SUPPORT +#ifndef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # ifdef _WIN32 -# if defined __INTEL_COMPILER || defined _MSC_VER -# define ENABLE_UNICODE_PATH_SUPPORT +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__GNUC__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif -# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__) -# define ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__clang__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif #endif -#ifdef ENABLE_UNICODE_PATH_SUPPORT -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # include #endif @@ -40,7 +41,7 @@ # define OPENVINO_C_VAR(...) OPENVINO_C_API_EXTERN __VA_ARGS__ # define OV_NODISCARD #else -# if defined(_WIN32) +# if defined(_WIN32) || defined(__CYGWIN__) # define OPENVINO_C_API_CALLBACK __cdecl # ifdef openvino_c_EXPORTS # define OPENVINO_C_API(...) OPENVINO_C_API_EXTERN __declspec(dllexport) __VA_ARGS__ __cdecl diff --git a/src/bindings/c/tests/ov_test.hpp b/src/bindings/c/tests/ov_test.hpp index db2f95563f5..66b829f8a9e 100644 --- a/src/bindings/c/tests/ov_test.hpp +++ b/src/bindings/c/tests/ov_test.hpp @@ -18,18 +18,7 @@ #define OV_EXPECT_NOT_OK(...) EXPECT_NE(ov_status_e::OK, __VA_ARGS__) #define OV_EXPECT_ARREQ(arr1, arr2) EXPECT_TRUE(std::equal(std::begin(arr1), std::end(arr1), std::begin(arr2))) -#ifndef ENABLE_UNICODE_PATH_SUPPORT -# ifdef _WIN32 -# if defined __INTEL_COMPILER || defined _MSC_VER -# define ENABLE_UNICODE_PATH_SUPPORT -# endif -# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__) -# define ENABLE_UNICODE_PATH_SUPPORT -# endif -#endif - -#ifdef ENABLE_UNICODE_PATH_SUPPORT -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # include #endif @@ -88,14 +77,14 @@ inline void fix_slashes(std::wstring& str) { } inline bool copy_file(std::string source_path, std::wstring dest_path) { -# ifndef _WIN32 - std::ifstream source(source_path, std::ios::binary); - std::ofstream dest(ov::util::wstring_to_string(dest_path), std::ios::binary); -# else +# ifdef _WIN32 fix_slashes(source_path); fix_slashes(dest_path); std::ifstream source(source_path, std::ios::binary); std::ofstream dest(dest_path, std::ios::binary); +# else + std::ifstream source(source_path, std::ios::binary); + std::ofstream dest(ov::util::wstring_to_string(dest_path), std::ios::binary); # endif bool result = source && dest; std::istreambuf_iterator begin_source(source); diff --git a/src/bindings/python/wheel/CMakeLists.txt b/src/bindings/python/wheel/CMakeLists.txt index 197bc5a3266..3b3ad6b1842 100644 --- a/src/bindings/python/wheel/CMakeLists.txt +++ b/src/bindings/python/wheel/CMakeLists.txt @@ -73,6 +73,8 @@ macro(_ov_platform_arch) else() set(_arch "aarch64") endif() + elseif(UNIVERSAL2) + set(_arch "universal2") elseif(ARM) set(_arch "armvl7") elseif(X86_64) diff --git a/src/cmake/ie_parallel.cmake b/src/cmake/ie_parallel.cmake index 211b9008a30..0268d4d5b8f 100644 --- a/src/cmake/ie_parallel.cmake +++ b/src/cmake/ie_parallel.cmake @@ -11,34 +11,72 @@ function(_ov_get_tbb_location tbb_target _tbb_lib_location_var) return() endif() - foreach(property INTERFACE_LINK_LIBRARIES - IMPORTED_LOCATION_RELEASE - IMPORTED_LOCATION_RELWITHDEBINFO - IMPORTED_LOCATION_NONE - IMPORTED_LOCATION) - get_target_property(_tbb_lib_location ${tbb_target} ${property}) - if(_tbb_lib_location) - if(property STREQUAL INTERFACE_LINK_LIBRARIES) - # pkg-config can set multiple libraries as interface, need to filter out - foreach(tbb_lib IN LISTS _tbb_lib_location) - if(tbb_lib MATCHES "${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}") - set(${_tbb_lib_location_var} "${tbb_lib}" PARENT_SCOPE) - return() - endif() - endforeach() - else() - set(${_tbb_lib_location_var} "${_tbb_lib_location}" PARENT_SCOPE) - return() + function(_get_target_location target lib_location_var) + if(NOT TARGET ${target}) + message(FATAL_ERROR "Internal error: ${target} does not represent a target") + endif() + + get_target_property(_imported_configs ${target} IMPORTED_CONFIGURATIONS) + if(NOT _imported_configs) + # if IMPORTED_CONFIGURATIONS property is not set, then set a common list + set(_imported_configs RELEASE NONE) + endif() + + # generate a list of locations + foreach(_imported_config IN LISTS _imported_configs) + list(APPEND _location_properties IMPORTED_LOCATION_${_imported_config}) + endforeach() + # add some more locations which are used by package managers + list(APPEND _location_properties IMPORTED_LOCATION) + + foreach(_location_property IN LISTS _location_properties) + get_target_property(_lib_location ${target} ${_location_property}) + if(_lib_location) + set(${lib_location_var} "${_lib_location}" PARENT_SCOPE) + break() endif() + endforeach() + endfunction() + + macro(_handle_tbb_target _tbb_target) + _get_target_location(${_tbb_target} "_tbb_lib_location") + if(_tbb_lib_location) + set(${_tbb_lib_location_var} "${_tbb_lib_location}" PARENT_SCOPE) + return() + endif() + endmacro() + + # handle INTERFACE_LINK_LIBRARIES + get_target_property(_tbb_interface_link_libraries ${tbb_target} INTERFACE_LINK_LIBRARIES) + # pkg-config can set multiple libraries as interface, need to filter out + foreach(tbb_lib IN LISTS _tbb_interface_link_libraries) + # handle cases like in conan: $<$:CONAN_LIB::onetbb_TBB_tbb_tbb_RELEASE> + if(${tbb_lib} MATCHES "CONAN_LIB::([A-Za-z0-9_]*)") + set(tbb_lib_parsed "CONAN_LIB::${CMAKE_MATCH_1}") + _handle_tbb_target(${tbb_lib_parsed}) + elseif(tbb_lib MATCHES "${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}") + # tbb_lib just a full path to a library itself + set(${_tbb_lib_location_var} "${tbb_lib}" PARENT_SCOPE) + return() endif() endforeach() + # handle case of usual target + _handle_tbb_target(${tbb_target}) + message(FATAL_ERROR "Failed to detect TBB library location") endfunction() macro(ov_find_package_tbb) if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND) - set(_ov_minimal_tbb_version 2017.0) + # conan generates TBBConfig.cmake files, which follows cmake's + # SameMajorVersion scheme, while TBB itself follows AnyNewerVersion one + # see https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#generating-a-package-version-file + if(CMAKE_TOOLCHAIN_FILE MATCHES "conan_toolchain.cmake" OR CONAN_EXPORTED) + set(_ov_minimal_tbb_version 2021.0) + else() + set(_ov_minimal_tbb_version 2017.0) + endif() if(NOT ENABLE_SYSTEM_TBB) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) @@ -74,7 +112,10 @@ macro(ov_find_package_tbb) unset(tbb_FOUND CACHE) endmacro() pkg_search_module(tbb QUIET - IMPORTED_TARGET GLOBAL + IMPORTED_TARGET + # we need to set GLOBAL in order to create ALIAS later + # ALIAS creation for non-GLOBAL targets is available since cmake 3.18 + GLOBAL tbb) if(tbb_FOUND) # parse version @@ -99,7 +140,7 @@ macro(ov_find_package_tbb) else() _ov_pkg_config_tbb_unset() - if(CPACK_GENERATOR STREQUAL "^(DEB|RPM|CONDA-FORGE|BREW)$") + if(CPACK_GENERATOR STREQUAL "^(DEB|RPM|CONDA-FORGE|BREW|CONAN)$") # package managers require system TBB set(message_type FATAL_ERROR) else() @@ -148,12 +189,14 @@ macro(ov_find_package_tbb) # let's try it first if(PkgConfig_FOUND) pkg_search_module(HWLOC QUIET - IMPORTED_TARGET GLOBAL + IMPORTED_TARGET + GLOBAL hwloc) endif() if(TARGET PkgConfig::HWLOC) # dependency is satisfied + add_library(HWLOC::hwloc_2_5 ALIAS PkgConfig::HWLOC) else() # Add HWLOC::hwloc_2_5 target to check via ApiValidator get_target_property(imported_configs TBB::tbbbind_2_5 IMPORTED_CONFIGURATIONS) @@ -168,9 +211,7 @@ macro(ov_find_package_tbb) set(hwloc_dll_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwloc${CMAKE_SHARED_LIBRARY_SUFFIX}") find_file(HWLOC_DLL NAMES ${hwloc_dll_name} PATHS "${TBB_dir}" DOC "Path to hwloc.dll") - if(NOT HWLOC_DLL) - message(WARNING "Failed to find ${hwloc_dll_name} in ${TBB_dir}") - else() + if(HWLOC_DLL) add_library(HWLOC::hwloc_2_5 SHARED IMPORTED) set_property(TARGET HWLOC::hwloc_2_5 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(HWLOC::hwloc_2_5 PROPERTIES IMPORTED_LOCATION_RELEASE "${HWLOC_DLL}") diff --git a/src/cmake/install_tbb.cmake b/src/cmake/install_tbb.cmake index 0a1cce51a4f..fea3737cd75 100644 --- a/src/cmake/install_tbb.cmake +++ b/src/cmake/install_tbb.cmake @@ -96,7 +96,7 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND set(_ov_system_tbb_is_obsolete ON) endif() - if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW)$" AND + if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW|CONAN)$" AND NOT ENABLE_SYSTEM_TBB AND NOT _ov_system_tbb_is_obsolete) message(FATAL_ERROR "Debian | RPM | Conda-forge | Brew packages can be built only with system TBB. Use -DENABLE_SYSTEM_TBB=ON") diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index acfdbdcfbb3..78b10ca0e2e 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -118,14 +118,8 @@ ov_install_static_lib(${TARGET_NAME}_dev ${OV_CPACK_COMP_CORE}) # Install OpenVINO runtime # -list(APPEND PATH_VARS "IE_INCLUDE_DIR") - ov_add_library_version(${TARGET_NAME}) -if(ENABLE_INTEL_GNA) - list(APPEND PATH_VARS "GNA_PATH") -endif() - ov_cpack_add_component(${OV_CPACK_COMP_CORE} HIDDEN DEPENDS ${core_components}) @@ -145,7 +139,9 @@ if(ENABLE_PLUGINS_XML) endif() endif() +# # Install cmake scripts +# install(EXPORT OpenVINOTargets FILE OpenVINOTargets.cmake @@ -153,6 +149,17 @@ install(EXPORT OpenVINOTargets DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} COMPONENT ${OV_CPACK_COMP_CORE_DEV}) +# build tree + +list(APPEND PATH_VARS "IE_INCLUDE_DIR") +if(ENABLE_INTEL_GNA) + list(APPEND PATH_VARS "GNA_PATH") +endif() +if(DNNL_USE_ACL) + list(APPEND BUILD_PATH_VARS "FIND_ACL_PATH") + set(FIND_ACL_PATH "${intel_cpu_thirdparty_SOURCE_DIR}") +endif() + set(PUBLIC_HEADERS_DIR "${OpenVINO_SOURCE_DIR}/src/inference/include") set(IE_INCLUDE_DIR "${PUBLIC_HEADERS_DIR}/ie") set(IE_TBB_DIR "${TBB_DIR}") @@ -160,12 +167,21 @@ set(IE_TBB_DIR "${TBB_DIR}") configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig.cmake.in" "${CMAKE_BINARY_DIR}/InferenceEngineConfig.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}" - PATH_VARS ${PATH_VARS}) + PATH_VARS ${PATH_VARS} ${BUILD_PATH_VARS}) configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenVINOConfig.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}" - PATH_VARS ${PATH_VARS}) + PATH_VARS ${PATH_VARS} ${BUILD_PATH_VARS}) + +# install tree + +if(DNNL_USE_ACL) + list(APPEND INSTALL_PATH_VARS "ARM_COMPUTE_LIB_DIR") + # remove generator expression at the end, because searching in Release / Debug will be + # done by ACLConfig.cmake itself + string(REPLACE "$" "" ARM_COMPUTE_LIB_DIR "${OV_CPACK_LIBRARYDIR}") +endif() set(IE_INCLUDE_DIR "${OV_CPACK_INCLUDEDIR}/ie") set(IE_TBB_DIR "${IE_TBB_DIR_INSTALL}") @@ -178,12 +194,12 @@ endif() configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig.cmake.in" "${CMAKE_BINARY_DIR}/share/InferenceEngineConfig.cmake" INSTALL_DESTINATION ${OV_CPACK_IE_CMAKEDIR} - PATH_VARS ${PATH_VARS}) + PATH_VARS ${PATH_VARS} ${INSTALL_PATH_VARS}) configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOConfig.cmake.in" "${CMAKE_BINARY_DIR}/share/OpenVINOConfig.cmake" INSTALL_DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} - PATH_VARS ${PATH_VARS}) + PATH_VARS ${PATH_VARS} ${INSTALL_PATH_VARS}) configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/InferenceEngineConfig-version.cmake" @ONLY) @@ -200,7 +216,9 @@ install(FILES "${CMAKE_BINARY_DIR}/share/OpenVINOConfig.cmake" DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} COMPONENT ${OV_CPACK_COMP_CORE_DEV}) +# # Generate and install openvino.pc pkg-config file +# if(ENABLE_PKGCONFIG_GEN) # fill in PKGCONFIG_OpenVINO_DEFINITIONS diff --git a/src/common/itt/CMakeLists.txt b/src/common/itt/CMakeLists.txt index e47689a909a..6e5727cd855 100644 --- a/src/common/itt/CMakeLists.txt +++ b/src/common/itt/CMakeLists.txt @@ -7,13 +7,12 @@ set(TARGET_NAME itt) file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.hpp") add_library(${TARGET_NAME} STATIC ${SOURCES}) - add_library(openvino::itt ALIAS ${TARGET_NAME}) target_link_libraries(${TARGET_NAME} PUBLIC openvino::util) -if(TARGET ittnotify) - target_link_libraries(${TARGET_NAME} PUBLIC ittnotify) +if(ENABLE_PROFILING_ITT) + target_link_libraries(${TARGET_NAME} PUBLIC ittapi::ittnotify) if(ENABLE_PROFILING_FILTER STREQUAL "ALL") target_compile_definitions(${TARGET_NAME} PUBLIC ENABLE_PROFILING_ALL diff --git a/src/common/itt/cmake/ITTConfig.cmake b/src/common/itt/cmake/ITTConfig.cmake index f3e6e03143f..659fdc8b86a 100644 --- a/src/common/itt/cmake/ITTConfig.cmake +++ b/src/common/itt/cmake/ITTConfig.cmake @@ -48,12 +48,12 @@ find_package_handle_standard_args(ITT if(ITT_FOUND) set(INTEL_ITT_FOUND ${ITT_FOUND}) - add_library(ittnotify STATIC IMPORTED GLOBAL) - set_target_properties(ittnotify PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}" - INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS} - INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT) + add_library(ittapi::ittnotify STATIC IMPORTED GLOBAL) + set_target_properties(ittapi::ittnotify PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}" + INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS} + INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT) if(UNIX) - set_target_properties(ittnotify PROPERTIES INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads") + set_target_properties(ittapi::ittnotify PROPERTIES INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads") endif() endif() diff --git a/src/common/preprocessing/src/CMakeLists.txt b/src/common/preprocessing/src/CMakeLists.txt index 8c317e69547..876ace337da 100644 --- a/src/common/preprocessing/src/CMakeLists.txt +++ b/src/common/preprocessing/src/CMakeLists.txt @@ -12,23 +12,21 @@ file(GLOB LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) # instructions support depending on an OS and a compiler # macro(ie_avx512_core_optimization_flags flags) - if(WIN32) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(${flags} /arch:AVX512) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(WIN32) set(${flags} /QxCORE-AVX512) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(${flags} /arch:AVX512) else() - message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") + set(${flags} -xCORE-AVX512) + endif() + elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) + set(${flags} -mavx512f -mavx512bw -mavx512dq -mfma) + if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + list(APPEND ${flags} -Wno-error=maybe-uninitialized -Wno-maybe-uninitialized) endif() else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(${flags} -xCORE-AVX512) - else() - set(${flags} -mavx512f -mavx512bw -mavx512dq -mfma) - if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) - list(APPEND ${flags} -Wno-error=maybe-uninitialized -Wno-maybe-uninitialized) - endif() - endif() + message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() endmacro() diff --git a/src/common/util/include/openvino/util/env_util.hpp b/src/common/util/include/openvino/util/env_util.hpp index 0b584f2825f..5470b59d02c 100644 --- a/src/common/util/include/openvino/util/env_util.hpp +++ b/src/common/util/include/openvino/util/env_util.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include namespace ov { diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index 98f5a3e8604..094a925b0b8 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -37,7 +37,11 @@ struct FileTraits { } static std::string library_prefix() { #ifdef _WIN32 +# if defined(__MINGW32__) || defined(__MINGW64__) + return {"lib"}; +# else return {""}; +# endif #else return {"lib"}; #endif @@ -62,7 +66,11 @@ struct FileTraits { } static std::wstring library_prefix() { #ifdef _WIN32 +# if defined(__MINGW32__) || defined(__MINGW64__) + return {L"lib"}; +# else return {L""}; +# endif #else return {L"lib"}; #endif diff --git a/src/common/util/include/openvino/util/util.hpp b/src/common/util/include/openvino/util/util.hpp index 3f15730609d..0ff8c7fb063 100644 --- a/src/common/util/include/openvino/util/util.hpp +++ b/src/common/util/include/openvino/util/util.hpp @@ -6,19 +6,21 @@ #ifndef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # ifdef _WIN32 -# if defined __INTEL_COMPILER || defined _MSC_VER +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__GNUC__) # define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif -# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__) +# elif defined(__clang__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) # define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif #endif // Disabled MSVC warning #if defined(_MSC_VER) -# define DISABLE_WARNING_MSVC_BEGIN(id) __pragma(warning(push)) __pragma(warning(disable : id)) -# define DISABLE_WARNING_MSVC_END(id) __pragma(warning(pop)) +# define OPENVINO_DISABLE_WARNING_MSVC_BEGIN(id) __pragma(warning(push)) __pragma(warning(disable : id)) +# define OPENVINO_DISABLE_WARNING_MSVC_END(id) __pragma(warning(pop)) #else -# define DISABLE_WARNING_MSVC_BEGIN(id) -# define DISABLE_WARNING_MSVC_END(id) +# define OPENVINO_DISABLE_WARNING_MSVC_BEGIN(id) +# define OPENVINO_DISABLE_WARNING_MSVC_END(id) #endif diff --git a/src/core/include/ngraph/ngraph_visibility.hpp b/src/core/include/ngraph/ngraph_visibility.hpp index 4fc268f9358..05acb51c3d4 100644 --- a/src/core/include/ngraph/ngraph_visibility.hpp +++ b/src/core/include/ngraph/ngraph_visibility.hpp @@ -10,5 +10,7 @@ #define NGRAPH_EXTERN_C OPENVINO_EXTERN_C #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# define ENABLE_UNICODE_PATH_SUPPORT +# ifndef ENABLE_UNICODE_PATH_SUPPORT +# define ENABLE_UNICODE_PATH_SUPPORT +# endif #endif diff --git a/src/core/include/openvino/core/core_visibility.hpp b/src/core/include/openvino/core/core_visibility.hpp index 3d053a00c35..705bdd28e17 100644 --- a/src/core/include/openvino/core/core_visibility.hpp +++ b/src/core/include/openvino/core/core_visibility.hpp @@ -43,7 +43,7 @@ */ namespace ov {} // namespace ov -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(disable : 4251) # pragma warning(disable : 4275) #endif diff --git a/src/core/include/openvino/core/deprecated.hpp b/src/core/include/openvino/core/deprecated.hpp index 9a46c80c69f..c9e41faf59a 100644 --- a/src/core/include/openvino/core/deprecated.hpp +++ b/src/core/include/openvino/core/deprecated.hpp @@ -14,7 +14,14 @@ // so any use of `frobnicate` will produce a compiler warning. // -#if defined(_WIN32) +#if defined(__GNUC__) +# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) +# if __GNUC__ >= 6 || defined(__clang__) +# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +# else +# define OPENVINO_ENUM_DEPRECATED(msg) +# endif +#elif defined(_MSC_VER) # define OPENVINO_DEPRECATED(msg) __declspec(deprecated(msg)) # if __cplusplus >= 201402L # define OPENVINO_ENUM_DEPRECATED(msg) [[deprecated(msg)]] @@ -24,43 +31,36 @@ #elif defined(__INTEL_COMPILER) # define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) # define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) -#elif defined(__GNUC__) -# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) -# if __GNUC__ < 6 && !defined(__clang__) -# define OPENVINO_ENUM_DEPRECATED(msg) -# else -# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) -# endif #else # define OPENVINO_DEPRECATED(msg) # define OPENVINO_ENUM_DEPRECATED(msg) #endif // Suppress warning "-Wdeprecated-declarations" / C4996 -#if defined(_MSC_VER) -# define OPENVINO_DO_PRAGMA(x) __pragma(x) -#elif defined(__GNUC__) +#if defined(__GNUC__) # define OPENVINO_DO_PRAGMA(x) _Pragma(# x) +#elif defined(_MSC_VER) +# define OPENVINO_DO_PRAGMA(x) __pragma(x) #else # define OPENVINO_DO_PRAGMA(x) #endif -#if defined(_MSC_VER) && !defined(__clang__) +#if defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(GCC diagnostic push) \ + OPENVINO_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(GCC diagnostic pop) +#elif defined(_MSC_VER) # define OPENVINO_SUPPRESS_DEPRECATED_START \ OPENVINO_DO_PRAGMA(warning(push)) \ OPENVINO_DO_PRAGMA(warning(disable : 4996)) # define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) #elif defined(__INTEL_COMPILER) -# define OPENVINO_SUPPRESS_DEPRECATED_START \ - OPENVINO_DO_PRAGMA(warning(push)) \ - OPENVINO_DO_PRAGMA(warning(disable : 1478)) -OPENVINO_DO_PRAGMA(warning(disable : 1786)) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(warning(push)) \ + OPENVINO_DO_PRAGMA(warning(disable : 1478)) \ + OPENVINO_DO_PRAGMA(warning(disable : 1786)) # define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) -#elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) -# define OPENVINO_SUPPRESS_DEPRECATED_START \ - OPENVINO_DO_PRAGMA(GCC diagnostic push) \ - OPENVINO_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") -# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(GCC diagnostic pop) #else # define OPENVINO_SUPPRESS_DEPRECATED_START # define OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/core/include/openvino/core/except.hpp b/src/core/include/openvino/core/except.hpp index 9bef38c30dc..cc84fa818be 100644 --- a/src/core/include/openvino/core/except.hpp +++ b/src/core/include/openvino/core/except.hpp @@ -22,9 +22,9 @@ struct CheckLocInfo { class OPENVINO_API Exception : public std::runtime_error { public: OPENVINO_DEPRECATED("This constructor is deprecated and will be removed, please use OPENVINO_THROW instead") - explicit Exception(const std::string& what_arg) : std::runtime_error(what_arg) {} + explicit Exception(const std::string& what_arg); OPENVINO_DEPRECATED("This constructor is deprecated and will be removed, please use OPENVINO_THROW instead") - explicit Exception(const std::stringstream& what_arg) : std::runtime_error(what_arg.str()) {} + explicit Exception(const std::stringstream& what_arg); [[noreturn]] static void create(const CheckLocInfo& check_loc_info, const std::string& context_info, const std::string& explanation); diff --git a/src/core/include/openvino/core/extension.hpp b/src/core/include/openvino/core/extension.hpp index 5de518ad88f..7e02703e628 100644 --- a/src/core/include/openvino/core/extension.hpp +++ b/src/core/include/openvino/core/extension.hpp @@ -11,14 +11,8 @@ #include "openvino/core/core_visibility.hpp" #include "openvino/core/type.hpp" -// Use extern "C" in order to avoid issues with mangling -#if defined(_WIN32) && defined(IMPLEMENT_OPENVINO_EXTENSION_API) -# define OPENVINO_EXTENSION_C_API OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS -# define OPENVINO_EXTENSION_API OPENVINO_CORE_EXPORTS -#else -# define OPENVINO_EXTENSION_C_API OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS -# define OPENVINO_EXTENSION_API OPENVINO_CORE_EXPORTS -#endif +#define OPENVINO_EXTENSION_C_API OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS +#define OPENVINO_EXTENSION_API OPENVINO_CORE_EXPORTS namespace ov { diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index 11c132b7a7e..dbe1156abb1 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -23,19 +23,21 @@ #ifndef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # ifdef _WIN32 -# if defined __INTEL_COMPILER || defined _MSC_VER +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__GNUC__) # define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif -# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__) +# elif defined(__clang__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) # define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif #endif -#if defined _WIN32 || defined __CYGWIN__ +#if defined(_WIN32) || defined(__CYGWIN__) # define OPENVINO_CORE_IMPORTS __declspec(dllimport) # define OPENVINO_CORE_EXPORTS __declspec(dllexport) # define _OPENVINO_HIDDEN_METHOD -#elif defined(__GNUC__) && __GNUC__ >= 4 +#elif defined(__GNUC__) && (__GNUC__ >= 4) || defined(__clang__) # define OPENVINO_CORE_IMPORTS __attribute__((visibility("default"))) # define OPENVINO_CORE_EXPORTS __attribute__((visibility("default"))) # define _OPENVINO_HIDDEN_METHOD __attribute__((visibility("hidden"))) diff --git a/src/core/include/openvino/op/constant.hpp b/src/core/include/openvino/op/constant.hpp index b157461e7ba..16965609ab7 100644 --- a/src/core/include/openvino/op/constant.hpp +++ b/src/core/include/openvino/op/constant.hpp @@ -520,12 +520,12 @@ private: std::numeric_limits::lowest() <= value); OPENVINO_ASSERT(std::numeric_limits::max() >= value); } -#if defined(_MSC_VER) -# pragma warning(pop) -#elif defined(__clang__) +#if defined(__clang__) # pragma clang diagnostic pop #elif defined(__GNUC__) # pragma GCC diagnostic pop +#elif defined(_MSC_VER) +# pragma warning(pop) #endif const auto size = shape_size(m_shape); diff --git a/src/core/include/openvino/op/util/activation_functions.hpp b/src/core/include/openvino/op/util/activation_functions.hpp index 66133049790..05f6d837bf2 100644 --- a/src/core/include/openvino/op/util/activation_functions.hpp +++ b/src/core/include/openvino/op/util/activation_functions.hpp @@ -11,9 +11,8 @@ #include "openvino/core/except.hpp" #include "openvino/core/node.hpp" -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(push) - # pragma warning(disable : 4100) #endif @@ -83,6 +82,6 @@ ActivationFunction get_activation_func_by_name(const std::string& func_name); } // namespace ov -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(pop) #endif diff --git a/src/core/reference/CMakeLists.txt b/src/core/reference/CMakeLists.txt index 60ee5956ac9..6608cf3c784 100644 --- a/src/core/reference/CMakeLists.txt +++ b/src/core/reference/CMakeLists.txt @@ -32,7 +32,8 @@ target_include_directories(${TARGET_NAME} PUBLIC $ $) -link_system_libraries(${TARGET_NAME} PRIVATE xbyak) +target_include_directories(${TARGET_NAME} SYSTEM PRIVATE + $:$>>) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) diff --git a/src/core/reference/include/ngraph/runtime/reference/convolution.hpp b/src/core/reference/include/ngraph/runtime/reference/convolution.hpp index 48c8be356c6..82e55cd9e73 100644 --- a/src/core/reference/include/ngraph/runtime/reference/convolution.hpp +++ b/src/core/reference/include/ngraph/runtime/reference/convolution.hpp @@ -50,7 +50,7 @@ struct ConvolutionParams { }; template -constexpr inline bool in_range(Int val, std::pair range) noexcept { +constexpr inline bool in_range(Int val, const std::pair& range) noexcept { return val >= range.first && val < range.second; } diff --git a/src/core/reference/src/runtime/reference/jit_generator.cpp b/src/core/reference/src/runtime/reference/jit_generator.cpp index 431eb9877ca..1ca5affacdd 100644 --- a/src/core/reference/src/runtime/reference/jit_generator.cpp +++ b/src/core/reference/src/runtime/reference/jit_generator.cpp @@ -2,14 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "jit_generator.hpp" - -#include - -#include "ngraph/type/float16.hpp" +#include "openvino/core/visibility.hpp" #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) +# if defined _WIN32 && !defined NOMINMAX +# define NOMINMAX +# endif +# include + +# include "jit_generator.hpp" +# include "ngraph/type/float16.hpp" + namespace ngraph { namespace runtime { namespace jit { diff --git a/src/core/src/except.cpp b/src/core/src/except.cpp index 6faef9d93c2..fe82239a727 100644 --- a/src/core/src/except.cpp +++ b/src/core/src/except.cpp @@ -4,6 +4,10 @@ #include "openvino/core/except.hpp" +ov::Exception::Exception(const std::string& what_arg) : std::runtime_error(what_arg) {} + +ov::Exception::Exception(const std::stringstream& what_arg) : std::runtime_error(what_arg.str()) {} + void ov::Exception::create(const CheckLocInfo& check_loc_info, const std::string& context_info, const std::string& explanation) { diff --git a/src/core/src/pass/manager.cpp b/src/core/src/pass/manager.cpp index bac12e6c544..fa01e69b9f2 100644 --- a/src/core/src/pass/manager.cpp +++ b/src/core/src/pass/manager.cpp @@ -79,7 +79,7 @@ bool ov::pass::Manager::run_passes(shared_ptr func) { continue; } - OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ov_pass, pass::perf_counters()[pass->get_type_info()]); + OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ov_pass, ov::pass::perf_counters()[pass->get_type_info()]); pass_timer.start(); diff --git a/src/core/src/pass/pass.cpp b/src/core/src/pass/pass.cpp index 6b246959ac3..5d8a8ed8134 100644 --- a/src/core/src/pass/pass.cpp +++ b/src/core/src/pass/pass.cpp @@ -2,8 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#ifdef _WIN32 -#else +#ifndef _WIN32 # include #endif diff --git a/src/frontends/common/shutdown_protobuf/CMakeLists.txt b/src/frontends/common/shutdown_protobuf/CMakeLists.txt index a14a97f7f31..4b0c2309abb 100644 --- a/src/frontends/common/shutdown_protobuf/CMakeLists.txt +++ b/src/frontends/common/shutdown_protobuf/CMakeLists.txt @@ -6,5 +6,6 @@ set(TARGET_NAME ov_protobuf_shutdown) add_library(${TARGET_NAME} STATIC shutdown_protobuf.cpp) -target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $) +target_include_directories(${TARGET_NAME} SYSTEM PRIVATE + $>) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/src/frontends/common/src/plugin_loader.cpp b/src/frontends/common/src/plugin_loader.cpp index 755636f1fda..7abbf9b0b68 100644 --- a/src/frontends/common/src/plugin_loader.cpp +++ b/src/frontends/common/src/plugin_loader.cpp @@ -6,8 +6,8 @@ # ifndef NOMINMAX # define NOMINMAX # endif -# include # include +# include #else // _WIN32 # include # include diff --git a/src/frontends/common/src/utils.cpp b/src/frontends/common/src/utils.cpp index f032a628089..8ef74815518 100644 --- a/src/frontends/common/src/utils.cpp +++ b/src/frontends/common/src/utils.cpp @@ -23,7 +23,7 @@ # ifndef NOMINMAX # define NOMINMAX # endif -# include +# include #endif namespace { diff --git a/src/frontends/ir/src/frontend.cpp b/src/frontends/ir/src/frontend.cpp index 0215eee96b0..42eba740a3e 100644 --- a/src/frontends/ir/src/frontend.cpp +++ b/src/frontends/ir/src/frontend.cpp @@ -77,7 +77,7 @@ bool FrontEnd::supported_impl(const std::vector& variants) const { #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) } else if (model_variant.is()) { const auto& path = model_variant.as(); - local_model_stream.open(path, std::ios::in | std::ifstream::binary); + local_model_stream.open(path.c_str(), std::ios::in | std::ifstream::binary); #endif } else if (model_variant.is()) { provided_model_stream = model_variant.as(); @@ -153,11 +153,11 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector& variants) const #else model_path = tmp_path; #endif - local_model_stream.open(model_path, std::ios::in | std::ifstream::binary); + local_model_stream.open(model_path.c_str(), std::ios::in | std::ifstream::binary); #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) } else if (model_variant.is()) { model_path = model_variant.as(); - local_model_stream.open(model_path, std::ios::in | std::ifstream::binary); + local_model_stream.open(model_path.c_str(), std::ios::in | std::ifstream::binary); #endif } else if (model_variant.is()) { provided_model_stream = model_variant.as(); @@ -205,7 +205,7 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector& variants) const weights = ov::load_mmap_object(weights_path); else { std::ifstream bin_stream; - bin_stream.open(weights_path, std::ios::binary); + bin_stream.open(weights_path.c_str(), std::ios::binary); if (!bin_stream.is_open()) #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) IE_THROW() << "Weights file " + ov::util::wstring_to_string(weights_path) + " cannot be opened!"; diff --git a/src/frontends/ir/src/os/win/win_mmap_object.cpp b/src/frontends/ir/src/os/win/win_mmap_object.cpp index a3c85bd3101..5a99c1c63b3 100644 --- a/src/frontends/ir/src/os/win/win_mmap_object.cpp +++ b/src/frontends/ir/src/os/win/win_mmap_object.cpp @@ -7,6 +7,9 @@ #include "openvino/util/file_util.hpp" // clang-format-off +#ifndef NOMINMAX +# define NOMINMAX +#endif #include // clang-format-on diff --git a/src/frontends/onnx/frontend/src/frontend.cpp b/src/frontends/onnx/frontend/src/frontend.cpp index ff0eb279d4e..4108070c4f2 100644 --- a/src/frontends/onnx/frontend/src/frontend.cpp +++ b/src/frontends/onnx/frontend/src/frontend.cpp @@ -140,7 +140,7 @@ bool FrontEnd::supported_impl(const std::vector& variants) const { #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) else if (variants[0].is()) { const auto path = variants[0].as(); - model_stream.open(path, std::ios::in | std::ifstream::binary); + model_stream.open(path.c_str(), std::ios::in | std::ifstream::binary); } #endif if (model_stream.is_open()) { diff --git a/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp b/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp index ada7aeebc5a..a1222ed9a09 100644 --- a/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp +++ b/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp @@ -37,7 +37,7 @@ std::string TensorExternalData::load_external_data(const std::string& model_dir) auto full_path = file_util::path_join(model_dir, m_data_location); #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) file_util::convert_path_win_style(full_path); - std::ifstream external_data_stream(ov::util::string_to_wstring(full_path), + std::ifstream external_data_stream(ov::util::string_to_wstring(full_path).c_str(), std::ios::binary | std::ios::in | std::ios::ate); #else std::ifstream external_data_stream(full_path, std::ios::binary | std::ios::in | std::ios::ate); diff --git a/src/frontends/onnx/onnx_common/CMakeLists.txt b/src/frontends/onnx/onnx_common/CMakeLists.txt index 7ea6b0ed11f..ef3d4ce3c1a 100644 --- a/src/frontends/onnx/onnx_common/CMakeLists.txt +++ b/src/frontends/onnx/onnx_common/CMakeLists.txt @@ -29,9 +29,9 @@ target_include_directories(${TARGET_NAME} PUBLIC $ #include +#include #include #include #include diff --git a/src/frontends/onnx/onnx_common/src/parser.cpp b/src/frontends/onnx/onnx_common/src/parser.cpp index 5a837728211..9682c350882 100644 --- a/src/frontends/onnx/onnx_common/src/parser.cpp +++ b/src/frontends/onnx/onnx_common/src/parser.cpp @@ -15,7 +15,7 @@ namespace ngraph { namespace onnx_common { ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path) { - std::ifstream file_stream{file_path, std::ios::in | std::ios::binary}; + std::ifstream file_stream{file_path.c_str(), std::ios::in | std::ios::binary}; if (!file_stream.is_open()) { OPENVINO_THROW("Could not open the file: " + file_path); @@ -28,7 +28,7 @@ ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path) { #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) ONNX_NAMESPACE::ModelProto parse_from_file(const std::wstring& file_path) { - std::ifstream file_stream{file_path, std::ios::in | std::ios::binary}; + std::ifstream file_stream{file_path.c_str(), std::ios::in | std::ios::binary}; if (!file_stream.is_open()) { NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/src/frontends/onnx/tests/CMakeLists.txt b/src/frontends/onnx/tests/CMakeLists.txt index 597bdd33a76..6dcc113f6a0 100644 --- a/src/frontends/onnx/tests/CMakeLists.txt +++ b/src/frontends/onnx/tests/CMakeLists.txt @@ -145,7 +145,7 @@ target_include_directories(ov_onnx_frontend_tests SYSTEM PRIVATE $ $ - ${Protobuf_INCLUDE_DIRS}) + $) target_compile_definitions(ov_onnx_frontend_tests PRIVATE $) target_compile_definitions(ov_onnx_frontend_tests PRIVATE ENABLE_OV_ONNX_FRONTEND) diff --git a/src/frontends/paddle/src/frontend.cpp b/src/frontends/paddle/src/frontend.cpp index 6568c0976b9..340f3e9722a 100644 --- a/src/frontends/paddle/src/frontend.cpp +++ b/src/frontends/paddle/src/frontend.cpp @@ -136,7 +136,7 @@ std::istream* variant_to_stream_ptr(const ov::Any& variant, std::ifstream& ext_s #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) else if (variant.is()) { const auto& model_path = variant.as(); - ext_stream.open(model_path, std::ios::in | std::ifstream::binary); + ext_stream.open(model_path.c_str(), std::ios::in | std::ifstream::binary); } #endif FRONT_END_INITIALIZATION_CHECK(ext_stream && ext_stream.is_open(), "Cannot open model file."); @@ -375,7 +375,7 @@ bool FrontEnd::supported_impl(const std::vector& variants) const { if (!ov::util::ends_with(model_path, suffix)) { model_path += paddle::get_path_sep() + L"__model__"; } - std::ifstream model_str(model_path, std::ios::in | std::ifstream::binary); + std::ifstream model_str(model_path.c_str(), std::ios::in | std::ifstream::binary); // It is possible to validate here that protobuf can read model from the stream, // but it will complicate the check, while it should be as quick as possible return model_str && model_str.is_open(); diff --git a/src/frontends/paddle/src/input_model.cpp b/src/frontends/paddle/src/input_model.cpp index a9f4ae1d60c..d3a266b6696 100644 --- a/src/frontends/paddle/src/input_model.cpp +++ b/src/frontends/paddle/src/input_model.cpp @@ -200,7 +200,7 @@ std::basic_string get_model_path(const std::basic_string& path std::wstring params_ext = L".pdiparams"; std::wstring weights_file{path}; weights_file.replace(weights_file.size() - ext.size(), ext.size(), params_ext); - weights_stream->open(weights_file, std::ios::binary); + weights_stream->open(weights_file.c_str(), std::ios::binary); // Don't throw error if file isn't opened // It may mean that model don't have constants } else { @@ -306,7 +306,7 @@ void InputModel::InputModelImpl::loadConsts(const std::basic_string& folder_w if (weight_stream) { read_succeed = read_tensor(*weight_stream, reinterpret_cast(&tensor_data[0]), data_length); } else if (!folder_with_weights.empty()) { - std::ifstream is(get_const_path(folder_with_weights, name), std::ios::in | std::ifstream::binary); + std::ifstream is(get_const_path(folder_with_weights, name).c_str(), std::ios::in | std::ifstream::binary); FRONT_END_GENERAL_CHECK(is && is.is_open(), "Cannot open file for constant value."); read_succeed = read_tensor(is, reinterpret_cast(&tensor_data[0]), data_length); } else { @@ -332,7 +332,7 @@ InputModel::InputModelImpl::InputModelImpl(const std::basic_string& path, m_telemetry(telemetry) { std::string empty_str; std::ifstream weights_stream; - std::ifstream pb_stream(get_model_path(path, &weights_stream), std::ios::in | std::ifstream::binary); + std::ifstream pb_stream(get_model_path(path, &weights_stream).c_str(), std::ios::in | std::ifstream::binary); FRONT_END_GENERAL_CHECK(pb_stream && pb_stream.is_open(), "Model file doesn't exist"); FRONT_END_GENERAL_CHECK(m_fw_ptr->ParseFromIstream(&pb_stream), "Model can't be parsed"); diff --git a/src/frontends/tensorflow/src/CMakeLists.txt b/src/frontends/tensorflow/src/CMakeLists.txt index af1cb8b00cd..95a999092e1 100644 --- a/src/frontends/tensorflow/src/CMakeLists.txt +++ b/src/frontends/tensorflow/src/CMakeLists.txt @@ -8,6 +8,6 @@ ov_add_frontend(NAME tensorflow LINK_LIBRARIES openvino::core::dev openvino::frontend::tensorflow_common) if(ENABLE_SNAPPY_COMPRESSION) - target_link_libraries(openvino_tensorflow_frontend PRIVATE Snappy::snappy) + target_link_libraries(openvino_tensorflow_frontend PRIVATE openvino::snappy) target_compile_definitions(openvino_tensorflow_frontend PRIVATE ENABLE_SNAPPY_COMPRESSION) endif() diff --git a/src/frontends/tensorflow/src/graph_iterator_meta.hpp b/src/frontends/tensorflow/src/graph_iterator_meta.hpp index a7a42261a9e..0d1689ecf6b 100644 --- a/src/frontends/tensorflow/src/graph_iterator_meta.hpp +++ b/src/frontends/tensorflow/src/graph_iterator_meta.hpp @@ -42,7 +42,7 @@ public: template static bool is_supported(const std::basic_string& path) { try { - std::ifstream mg_stream(path, std::ios::in | std::ifstream::binary); + std::ifstream mg_stream(path.c_str(), std::ios::in | std::ifstream::binary); auto metagraph_def = std::make_shared<::tensorflow::MetaGraphDef>(); return mg_stream && mg_stream.is_open() && metagraph_def->ParsePartialFromIstream(&mg_stream) && metagraph_def->has_graph_def() && metagraph_def->graph_def().node_size() > 0; @@ -70,13 +70,13 @@ private: bool read_meta(const std::basic_string& path) { std::basic_string model_path = path.substr(0, path.find_last_of('.')); - std::ifstream mg_stream{path, std::ifstream::in | std::ifstream::binary}; + std::ifstream mg_stream{path.c_str(), std::ifstream::in | std::ifstream::binary}; FRONT_END_GENERAL_CHECK(mg_stream && mg_stream.is_open(), "Model file does not exist"); std::basic_string varIndexPath = get_variables_index_name(model_path); if (ov::util::file_exists(varIndexPath)) { m_variables_index = std::make_shared(); - std::ifstream vi_stream{varIndexPath, std::ifstream::in | std::ifstream::binary}; + std::ifstream vi_stream{varIndexPath.c_str(), std::ifstream::in | std::ifstream::binary}; FRONT_END_GENERAL_CHECK(vi_stream && vi_stream.is_open(), "MetaGraph's variable index file does not exist"); FRONT_END_GENERAL_CHECK(m_variables_index->read_variables(vi_stream, model_path, false), "MetaGraph's variable index file cannot be parsed"); diff --git a/src/frontends/tensorflow/src/graph_iterator_proto.hpp b/src/frontends/tensorflow/src/graph_iterator_proto.hpp index 46ddce55ad9..a5da5277269 100644 --- a/src/frontends/tensorflow/src/graph_iterator_proto.hpp +++ b/src/frontends/tensorflow/src/graph_iterator_proto.hpp @@ -95,7 +95,7 @@ public: GraphIteratorProto(const std::basic_string& path) : m_graph_def(std::make_shared<::tensorflow::GraphDef>()), m_func_def(nullptr) { - std::ifstream pb_stream(path, std::ios::in | std::ifstream::binary); + std::ifstream pb_stream(path.c_str(), std::ios::in | std::ifstream::binary); FRONT_END_GENERAL_CHECK(pb_stream && pb_stream.is_open(), "Model file does not exist"); FRONT_END_GENERAL_CHECK(m_graph_def->ParseFromIstream(&pb_stream), "Model cannot be parsed"); @@ -107,7 +107,7 @@ public: template static bool is_supported(const std::basic_string& path) { try { - std::ifstream pb_stream(path, std::ios::in | std::ifstream::binary); + std::ifstream pb_stream(path.c_str(), std::ios::in | std::ifstream::binary); auto graph_def = std::make_shared<::tensorflow::GraphDef>(); return pb_stream && pb_stream.is_open() && graph_def->ParsePartialFromIstream(&pb_stream) && graph_def->node_size() > 0; diff --git a/src/frontends/tensorflow/src/graph_iterator_proto_txt.hpp b/src/frontends/tensorflow/src/graph_iterator_proto_txt.hpp index 569fe757628..3b483a9688d 100644 --- a/src/frontends/tensorflow/src/graph_iterator_proto_txt.hpp +++ b/src/frontends/tensorflow/src/graph_iterator_proto_txt.hpp @@ -19,7 +19,7 @@ class GraphIteratorProtoTxt : public GraphIteratorProto { public: template GraphIteratorProtoTxt(const std::basic_string& path) : GraphIteratorProto() { - std::ifstream pbtxt_stream(path, std::ios::in); + std::ifstream pbtxt_stream(path.c_str(), std::ios::in); FRONT_END_GENERAL_CHECK(pbtxt_stream && pbtxt_stream.is_open(), "Model file does not exist"); auto input_stream = std::make_shared<::google::protobuf::io::IstreamInputStream>(&pbtxt_stream); FRONT_END_GENERAL_CHECK(input_stream, "Model cannot be read"); @@ -35,7 +35,7 @@ public: template static bool is_supported(const std::basic_string& path) { try { - std::ifstream pbtxt_stream(path, std::ios::in); + std::ifstream pbtxt_stream(path.c_str(), std::ios::in); bool model_exists = (pbtxt_stream && pbtxt_stream.is_open()); if (!model_exists) { return false; diff --git a/src/frontends/tensorflow/src/graph_iterator_saved_model.hpp b/src/frontends/tensorflow/src/graph_iterator_saved_model.hpp index a104611e371..d05378ff636 100644 --- a/src/frontends/tensorflow/src/graph_iterator_saved_model.hpp +++ b/src/frontends/tensorflow/src/graph_iterator_saved_model.hpp @@ -68,13 +68,14 @@ private: template bool read_saved_model(const std::basic_string& path, const std::string& tags) { - std::ifstream sm_stream{path + get_saved_model_name(), std::ifstream::in | std::ifstream::binary}; + std::basic_string save_model_path = path + get_saved_model_name(); + std::ifstream sm_stream{save_model_path.c_str(), std::ifstream::in | std::ifstream::binary}; FRONT_END_GENERAL_CHECK(sm_stream && sm_stream.is_open(), "Model file does not exist"); std::basic_string varIndexPath = path + get_variables_index_name(); if (ov::util::file_exists(varIndexPath)) { m_variables_index = std::make_shared(); - std::ifstream vi_stream{varIndexPath, std::ifstream::in | std::ifstream::binary}; + std::ifstream vi_stream{varIndexPath.c_str(), std::ifstream::in | std::ifstream::binary}; FRONT_END_GENERAL_CHECK(vi_stream && vi_stream.is_open(), "Saved Model's variable index file does not exist"); FRONT_END_GENERAL_CHECK(m_variables_index->read_variables(vi_stream, path), diff --git a/src/frontends/tensorflow/src/variables_index.cpp b/src/frontends/tensorflow/src/variables_index.cpp index 662cd47be0b..2743b7116a6 100644 --- a/src/frontends/tensorflow/src/variables_index.cpp +++ b/src/frontends/tensorflow/src/variables_index.cpp @@ -264,8 +264,8 @@ bool VariablesIndex::read_variables(std::ifstream& vi_stream, const std::string& } else { fullPath = path + "." + suffix.data(); } - m_data_files[shard] = - std::shared_ptr(new std::ifstream(fullPath, std::ifstream::in | std::ifstream::binary)); + m_data_files[shard] = std::shared_ptr( + new std::ifstream(fullPath.c_str(), std::ifstream::in | std::ifstream::binary)); FRONT_END_GENERAL_CHECK(m_data_files[shard]->is_open(), "Variable index data file does not exist"); } @@ -288,8 +288,8 @@ bool VariablesIndex::read_variables(std::ifstream& vi_stream, const std::wstring } else { fullPath = path + L"." + suffix.data(); } - m_data_files[shard] = - std::shared_ptr(new std::ifstream(fullPath, std::ifstream::in | std::ifstream::binary)); + m_data_files[shard] = std::shared_ptr( + new std::ifstream(fullPath.c_str(), std::ifstream::in | std::ifstream::binary)); FRONT_END_GENERAL_CHECK(m_data_files[shard]->is_open(), "Variable index data file does not exist"); } diff --git a/src/frontends/tensorflow/src/variables_index.hpp b/src/frontends/tensorflow/src/variables_index.hpp index d3a3cf518fd..0c2f5dfc899 100644 --- a/src/frontends/tensorflow/src/variables_index.hpp +++ b/src/frontends/tensorflow/src/variables_index.hpp @@ -78,7 +78,7 @@ public: } /// \brief Checks if variable has a mapped pair - /// \param name Name of variable for checking existance + /// \param name Name of variable for checking existence /// \returns True in case variable has mapped value and false otherwise bool has_mapped_variable(const std::string& name) const { auto mapItem = m_variables_map.find(name); diff --git a/src/frontends/tensorflow_common/src/CMakeLists.txt b/src/frontends/tensorflow_common/src/CMakeLists.txt index b11f4cb1d4d..bc543ca11ee 100644 --- a/src/frontends/tensorflow_common/src/CMakeLists.txt +++ b/src/frontends/tensorflow_common/src/CMakeLists.txt @@ -33,4 +33,4 @@ ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} "${root_dir}/src" ADDITIONAL_INCLUDE_DIRECTORIES $ - $) \ No newline at end of file + $) diff --git a/src/frontends/tensorflow_common/src/op/non_max_suppression.cpp b/src/frontends/tensorflow_common/src/op/non_max_suppression.cpp index ad8d1fc587d..69b8a9cd018 100644 --- a/src/frontends/tensorflow_common/src/op/non_max_suppression.cpp +++ b/src/frontends/tensorflow_common/src/op/non_max_suppression.cpp @@ -52,13 +52,13 @@ NamedOutputVector translate_non_max_suppression_op(const NodeContext& node) { auto scores = node.get_input(1); auto max_output_size = node.get_input(2); - // prepare boxes: in TensorFlow NonMaxSupression operation there is no batch dimension + // prepare boxes: in TensorFlow NonMaxSuppression operation there is no batch dimension // so we need to introduce it to be aligned with OpenVINO NonMaxSuppression // boxes of shape [num_batches, num_boxes, 4] auto boxes_axis = make_shared(element::i32, Shape{1}, 0); auto ov_boxes = make_shared(boxes, boxes_axis); - // prepare scores: in TensorFlow NonMaxSupression operation there is no batch and class dimensions + // prepare scores: in TensorFlow NonMaxSuppression operation there is no batch and class dimensions // so we need to introduce them to be aligned with OpenVINO NonMaxSuppression scores // of shape [num_batches, num_classes, num_boxes] auto scores_axes = make_shared(element::i32, Shape{2}, vector{0, 1}); diff --git a/src/inference/CMakeLists.txt b/src/inference/CMakeLists.txt index e9ce7bc8d02..28f4fb9c693 100644 --- a/src/inference/CMakeLists.txt +++ b/src/inference/CMakeLists.txt @@ -133,7 +133,7 @@ target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $ $ $ - $) + $<$:$>) target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" diff --git a/src/inference/include/ie/details/ie_so_loader.h b/src/inference/include/ie/details/ie_so_loader.h index aac9e173087..59c71f23ba4 100644 --- a/src/inference/include/ie/details/ie_so_loader.h +++ b/src/inference/include/ie/details/ie_so_loader.h @@ -35,13 +35,13 @@ public: */ SharedObjectLoader() = default; -#ifdef ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Loads a library with the wide char name specified. * @param pluginName Full or relative path to the plugin library */ explicit SharedObjectLoader(const wchar_t* pluginName); -#endif +#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Loads a library with the name specified. diff --git a/src/inference/include/ie/ie_api.h b/src/inference/include/ie/ie_api.h index b2c02fc3d1a..a3c7a6df72b 100644 --- a/src/inference/include/ie/ie_api.h +++ b/src/inference/include/ie/ie_api.h @@ -14,7 +14,7 @@ # define INFERENCE_ENGINE_API_CPP(...) __VA_ARGS__ # define INFERENCE_ENGINE_API_CLASS(...) __VA_ARGS__ #else -# if defined(_WIN32) +# if defined(_WIN32) || defined(__CYGWIN__) # ifdef IMPLEMENT_INFERENCE_ENGINE_API # define INFERENCE_ENGINE_API(...) extern "C" __declspec(dllexport) __VA_ARGS__ __cdecl # define INFERENCE_ENGINE_API_CPP(...) __declspec(dllexport) __VA_ARGS__ @@ -31,53 +31,53 @@ # endif #endif -#if defined(_WIN32) +#if defined(__GNUC__) +# define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated(msg))) +# if __GNUC__ >= 6 || defined(__clang__) +# define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) INFERENCE_ENGINE_DEPRECATED(msg) +# else +# define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) +# endif +#elif defined(_MSC_VER) # define INFERENCE_ENGINE_DEPRECATED(msg) __declspec(deprecated(msg)) # if __cplusplus >= 201402L # define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) [[deprecated(msg)]] # else # define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) # endif -#elif defined __INTEL_COMPILER +#elif defined(__INTEL_COMPILER) # define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated(msg))) # define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) INFERENCE_ENGINE_DEPRECATED(msg) -#elif defined(__GNUC__) -# define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated(msg))) -# if __GNUC__ < 6 && !defined(__clang__) -# define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) -# else -# define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) INFERENCE_ENGINE_DEPRECATED(msg) -# endif #else # define INFERENCE_ENGINE_DEPRECATED(msg) # define INFERENCE_ENGINE_ENUM_DEPRECATED(msg) #endif // Suppress warning "-Wdeprecated-declarations" / C4996 -#if defined(_MSC_VER) -# define IE_DO_PRAGMA(x) __pragma(x) -#elif defined(__GNUC__) +#if defined(__GNUC__) # define IE_DO_PRAGMA(x) _Pragma(# x) +#elif defined(_MSC_VER) +# define IE_DO_PRAGMA(x) __pragma(x) #else # define IE_DO_PRAGMA(x) #endif -#if defined(_MSC_VER) && !defined(__clang__) +#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) || defined(__clang__) +# define IE_SUPPRESS_DEPRECATED_START \ + IE_DO_PRAGMA(GCC diagnostic push) \ + IE_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +# define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(GCC diagnostic pop) +#elif defined(_MSC_VER) # define IE_SUPPRESS_DEPRECATED_START \ IE_DO_PRAGMA(warning(push)) \ IE_DO_PRAGMA(warning(disable : 4996)) # define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(warning(pop)) #elif defined(__INTEL_COMPILER) -# define IE_SUPPRESS_DEPRECATED_START \ - IE_DO_PRAGMA(warning(push)) \ - IE_DO_PRAGMA(warning(disable : 1478)) -IE_DO_PRAGMA(warning(disable : 1786)) +# define IE_SUPPRESS_DEPRECATED_START \ + IE_DO_PRAGMA(warning(push)) \ + IE_DO_PRAGMA(warning(disable : 1478)) \ + IE_DO_PRAGMA(warning(disable : 1786)) # define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(warning(pop)) -#elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) -# define IE_SUPPRESS_DEPRECATED_START \ - IE_DO_PRAGMA(GCC diagnostic push) \ - IE_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") -# define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(GCC diagnostic pop) #else # define IE_SUPPRESS_DEPRECATED_START # define IE_SUPPRESS_DEPRECATED_END @@ -92,18 +92,22 @@ IE_DO_PRAGMA(warning(disable : 1786)) # define _IE_SUPPRESS_DEPRECATED_END_GCC #endif -#ifndef ENABLE_UNICODE_PATH_SUPPORT +#ifndef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # ifdef _WIN32 -# if defined __INTEL_COMPILER || defined _MSC_VER -# define ENABLE_UNICODE_PATH_SUPPORT +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__GNUC__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif -# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__) -# define ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__clang__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT # endif #endif -#ifdef ENABLE_UNICODE_PATH_SUPPORT -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# ifndef ENABLE_UNICODE_PATH_SUPPORT +# define ENABLE_UNICODE_PATH_SUPPORT +# endif #endif /** @@ -112,7 +116,7 @@ IE_DO_PRAGMA(warning(disable : 1786)) * @param type A plugin type */ -#if defined(_WIN32) && defined(IMPLEMENT_INFERENCE_ENGINE_PLUGIN) +#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(IMPLEMENT_INFERENCE_ENGINE_PLUGIN) # define INFERENCE_PLUGIN_API(type) extern "C" __declspec(dllexport) type #else # define INFERENCE_PLUGIN_API(type) INFERENCE_ENGINE_API(type) diff --git a/src/inference/include/ie/ie_blob.h b/src/inference/include/ie/ie_blob.h index 0cd5f1e60cd..7dcb814ef71 100644 --- a/src/inference/include/ie/ie_blob.h +++ b/src/inference/include/ie/ie_blob.h @@ -609,7 +609,7 @@ public: * @return rvalue for the empty locked object of type T */ virtual LockedMemory data() noexcept { - return std::move(lockme()); + return lockme(); } /** @@ -618,7 +618,7 @@ public: * @return rvalue for the empty locked const object of type T. */ virtual LockedMemory readOnly() const noexcept { - return std::move(lockme()); + return lockme(); } void allocate() noexcept override { @@ -639,22 +639,22 @@ public: } LockedMemory buffer() noexcept override { - return std::move(lockme()); + return lockme(); } LockedMemory cbuffer() const noexcept override { - return std::move(lockme()); + return lockme(); } LockedMemory rwmap() noexcept override { - return std::move(lockme()); + return lockme(); } LockedMemory rmap() const noexcept override { - return std::move(lockme()); + return lockme(); } LockedMemory wmap() noexcept override { - return std::move(lockme()); + return lockme(); } Blob::Ptr createROI(const ROI& roi) const override { diff --git a/src/inference/include/ie/ie_common.h b/src/inference/include/ie/ie_common.h index c14556b232d..61c89b18598 100644 --- a/src/inference/include/ie/ie_common.h +++ b/src/inference/include/ie/ie_common.h @@ -504,7 +504,8 @@ struct NullStream { } // namespace details } // namespace InferenceEngine -#if defined(_WIN32) + +#if defined(_WIN32) && !defined(__GNUC__) # define __PRETTY_FUNCTION__ __FUNCSIG__ #else # define __PRETTY_FUNCTION__ __PRETTY_FUNCTION__ diff --git a/src/inference/include/ie/ie_core.hpp b/src/inference/include/ie/ie_core.hpp index 36cba5553f5..dbf59a66784 100644 --- a/src/inference/include/ie/ie_core.hpp +++ b/src/inference/include/ie/ie_core.hpp @@ -56,7 +56,7 @@ public: */ std::map GetVersions(const std::string& deviceName) const; -#ifdef ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Reads models from IR and ONNX formats * @param modelPath path to model @@ -69,7 +69,7 @@ public: * @return CNNNetwork */ CNNNetwork ReadNetwork(const std::wstring& modelPath, const std::wstring& binPath = {}) const; -#endif +#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Reads models from IR and ONNX formats diff --git a/src/inference/include/ie/ie_extension.h b/src/inference/include/ie/ie_extension.h index 2836e4b7b6e..8bf89e18f84 100644 --- a/src/inference/include/ie/ie_extension.h +++ b/src/inference/include/ie/ie_extension.h @@ -31,14 +31,14 @@ public: */ explicit Extension(const std::string& name); -#ifdef ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Loads extension from a shared library * * @param name Full or relative path to extension library */ explicit Extension(const std::wstring& name); -#endif // ENABLE_UNICODE_PATH_SUPPORT +#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Gets the extension version information @@ -110,7 +110,7 @@ inline std::shared_ptr make_so_pointer(const std::string& name) { return std::make_shared(name); } -#ifdef ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** * @brief Creates extension using deprecated API @@ -123,5 +123,6 @@ inline std::shared_ptr make_so_pointer(const std::wstring& name) { return std::make_shared(name); } -#endif +#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT + } // namespace InferenceEngine diff --git a/src/inference/include/ie/ie_iextension.h b/src/inference/include/ie/ie_iextension.h index 7af52585c11..73287595a21 100644 --- a/src/inference/include/ie/ie_iextension.h +++ b/src/inference/include/ie/ie_iextension.h @@ -25,13 +25,13 @@ * @def INFERENCE_EXTENSION_API(TYPE) * @brief Defines Inference Engine Extension API method */ -#if defined(_WIN32) +#if defined(_WIN32) || defined(__CYGWIN__) # if defined(IMPLEMENT_INFERENCE_EXTENSION_API) # define INFERENCE_EXTENSION_API(type) extern "C" __declspec(dllexport) type # else # define INFERENCE_EXTENSION_API(type) extern "C" type # endif -#elif defined(__GNUC__) && (__GNUC__ >= 4) +#elif defined(__GNUC__) && (__GNUC__ >= 4) || defined(__clang__) # ifdef IMPLEMENT_INFERENCE_EXTENSION_API # define INFERENCE_EXTENSION_API(type) extern "C" __attribute__((visibility("default"))) type # else @@ -220,7 +220,7 @@ INFERENCE_EXTENSION_API(void) CreateExtensionShared(IExtensionPtr& ext); * @param resp Responce * @return InferenceEngine::OK if extension is constructed and InferenceEngine::GENERAL_ERROR otherwise */ -#if defined(_WIN32) +#ifdef _MSC_VER INFERENCE_ENGINE_DEPRECATED("Use IE_DEFINE_EXTENSION_CREATE_FUNCTION macro") INFERENCE_EXTENSION_API(StatusCode) CreateExtension(IExtension*& ext, ResponseDesc* resp) noexcept; diff --git a/src/inference/include/openvino/runtime/intel_gpu/ocl/ocl_wrapper.hpp b/src/inference/include/openvino/runtime/intel_gpu/ocl/ocl_wrapper.hpp index d698984c372..8b7baf3c430 100644 --- a/src/inference/include/openvino/runtime/intel_gpu/ocl/ocl_wrapper.hpp +++ b/src/inference/include/openvino/runtime/intel_gpu/ocl/ocl_wrapper.hpp @@ -39,6 +39,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic push # pragma GCC system_header +#elif defined(_MSC_VER) +# pragma warning(push) +# pragma system_header #endif #ifdef OV_GPU_USE_OPENCL_HPP @@ -49,6 +52,8 @@ #ifdef __GNUC__ # pragma GCC diagnostic pop +#elif defined(_MSC_VER) +# pragma warning(pop) #endif /// @endcond diff --git a/src/inference/src/cpp/ie_extension.cpp b/src/inference/src/cpp/ie_extension.cpp index eab5682ac6e..f2bb75ce7ed 100644 --- a/src/inference/src/cpp/ie_extension.cpp +++ b/src/inference/src/cpp/ie_extension.cpp @@ -61,7 +61,7 @@ Extension::Extension(const std::string& name) { _actual = CreateExtensionFromLibrary(_so); } -#ifdef ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT Extension::Extension(const std::wstring& name) { try { _so = ov::util::load_shared_object(name.c_str()); @@ -70,7 +70,7 @@ Extension::Extension(const std::wstring& name) { } _actual = CreateExtensionFromLibrary(_so); } -#endif // ENABLE_UNICODE_PATH_SUPPORT +#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT std::map Extension::getOpSets() { return _actual->getOpSets(); diff --git a/src/inference/src/dev/threading/parallel_custom_arena.cpp b/src/inference/src/dev/threading/parallel_custom_arena.cpp index 78bd1989220..4e25a4f4d1b 100644 --- a/src/inference/src/dev/threading/parallel_custom_arena.cpp +++ b/src/inference/src/dev/threading/parallel_custom_arena.cpp @@ -31,6 +31,9 @@ # endif # if defined(_WIN32) || defined(_WIN64) +# ifndef NOMINMAX +# define NOMINMAX +# endif # include # endif @@ -161,7 +164,7 @@ public: private: int get_processors_group_num() const { -# if defined(_WIN32) || defined(_WIN64) +# if defined(_WIN32) SYSTEM_INFO si; GetNativeSystemInfo(&si); diff --git a/src/inference/src/dev/threading/thread_affinity.hpp b/src/inference/src/dev/threading/thread_affinity.hpp index 92f1bf9b180..1f971d64275 100644 --- a/src/inference/src/dev/threading/thread_affinity.hpp +++ b/src/inference/src/dev/threading/thread_affinity.hpp @@ -17,7 +17,7 @@ namespace threading { #if (defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(_WIN32)) using cpu_set_t = void; -#endif // (defined(__APPLE__) || defined(_WIN32)) +#endif // (defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(_WIN32)) /** * @brief Release the cores affinity mask for the current process diff --git a/src/inference/src/file_utils.cpp b/src/inference/src/file_utils.cpp index 77cdde0a53b..c8933ea5f82 100644 --- a/src/inference/src/file_utils.cpp +++ b/src/inference/src/file_utils.cpp @@ -32,7 +32,7 @@ # ifndef NOMINMAX # define NOMINMAX # endif -# include +# include #endif long long FileUtils::fileSize(const char* charfilepath) { diff --git a/src/inference/src/ie_network_reader.cpp b/src/inference/src/ie_network_reader.cpp index 09b39ccaf0d..17f02c12c41 100644 --- a/src/inference/src/ie_network_reader.cpp +++ b/src/inference/src/ie_network_reader.cpp @@ -182,7 +182,7 @@ CNNNetwork load_ir_v7_network(const std::string& modelPath, # endif // Try to open model file - std::ifstream modelStream(model_path, std::ios::binary); + std::ifstream modelStream(model_path.c_str(), std::ios::binary); if (!modelStream.is_open()) IE_THROW() << "Model file " << modelPath << " cannot be opened!"; @@ -214,7 +214,7 @@ CNNNetwork load_ir_v7_network(const std::string& modelPath, std::string weights_path = bPath; # endif std::ifstream binStream; - binStream.open(weights_path, std::ios::binary); + binStream.open(weights_path.c_str(), std::ios::binary); if (!binStream.is_open()) IE_THROW() << "Weights file " << bPath << " cannot be opened!"; diff --git a/src/inference/src/streams_executor.hpp b/src/inference/src/streams_executor.hpp index 6cae7ef41d1..0fd7bc424df 100644 --- a/src/inference/src/streams_executor.hpp +++ b/src/inference/src/streams_executor.hpp @@ -50,7 +50,7 @@ void parse_processor_info_linux(const int _processors, std::vector>& _cpu_mapping_table); #endif -#if (defined(_WIN32) || defined(_WIN64)) +#if defined(_WIN32) /** * @brief Parse processors infomation on Windows * @param[in] base_ptr buffer object pointer of Windows system infomation diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp index 19b42b9d3e2..d555db7f34b 100644 --- a/src/inference/src/system_conf.cpp +++ b/src/inference/src/system_conf.cpp @@ -19,15 +19,17 @@ #include "streams_executor.hpp" #include "threading/ie_cpu_streams_info.hpp" -#define XBYAK_NO_OP_NAMES -#define XBYAK_UNDEF_JNL -#include +#if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) +# define XBYAK_NO_OP_NAMES +# define XBYAK_UNDEF_JNL +# include +#endif using namespace InferenceEngine; namespace ov { -#if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) +#if defined(OPENVINO_ARCH_X86_64) // note: MSVC 2022 (17.4) is not able to compile the next line for ARM and ARM64 // so, we disable this code since for non-x86 platforms it returns 'false' anyway @@ -77,7 +79,7 @@ bool with_cpu_x86_avx512_core_amx() { return with_cpu_x86_avx512_core_amx_int8() || with_cpu_x86_avx512_core_amx_bf16(); } -#else // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64 +#else // OPENVINO_ARCH_X86_64 bool with_cpu_x86_sse42() { return false; @@ -110,7 +112,7 @@ bool with_cpu_x86_avx512_core_amx() { return false; } -#endif // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64 +#endif // OPENVINO_ARCH_X86_64 bool check_open_mp_env_vars(bool include_omp_num_threads) { for (auto&& var : {"GOMP_CPU_AFFINITY", diff --git a/src/inference/src/threading/ie_thread_affinity.hpp b/src/inference/src/threading/ie_thread_affinity.hpp index 53fb8219cf4..065a0cdfc25 100644 --- a/src/inference/src/threading/ie_thread_affinity.hpp +++ b/src/inference/src/threading/ie_thread_affinity.hpp @@ -17,7 +17,7 @@ namespace InferenceEngine { #if (defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(_WIN32)) using cpu_set_t = ov::threading::cpu_set_t; -#endif // (defined(__APPLE__) || defined(_WIN32)) +#endif // (defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(_WIN32)) /** * @brief Release the cores affinity mask for the current process diff --git a/src/inference/tests/unit/cpu_map_parser.cpp b/src/inference/tests/unit/cpu_map_parser.cpp index 805c66589f0..9150600f147 100644 --- a/src/inference/tests/unit/cpu_map_parser.cpp +++ b/src/inference/tests/unit/cpu_map_parser.cpp @@ -586,7 +586,7 @@ INSTANTIATE_TEST_SUITE_P(CPUMap, _1sockets_6cores_hyperthreading)); #endif -#if (defined(_WIN32) || defined(_WIN64)) +#if defined(_WIN32) int Hex2Int(char c) { return (c >= '0' && c <= '9') @@ -595,7 +595,7 @@ int Hex2Int(char c) { } void Hex2Bin(const char* hex, std::size_t sz, char* out) { - for (int i = 0; i < sz; i += 2) { + for (size_t i = 0; i < sz; i += 2) { out[i / 2] = (Hex2Int(hex[i]) << 4) | Hex2Int(hex[i + 1]); } } @@ -626,7 +626,7 @@ public: int test_processors = 0; int test_sockets = 0; int test_cores = 0; - unsigned long len = unsigned long(test_len / 2); + unsigned long len = (unsigned long)(test_len / 2); std::vector> test_proc_type_table; std::vector> test_cpu_mapping_table; diff --git a/src/inference/tests/unit/ie_blob_test.cpp b/src/inference/tests/unit/ie_blob_test.cpp index e48e18860ae..ddda510d146 100644 --- a/src/inference/tests/unit/ie_blob_test.cpp +++ b/src/inference/tests/unit/ie_blob_test.cpp @@ -8,12 +8,6 @@ #include "unit_test_utils/mocks/mock_allocator.hpp" -#ifdef _WIN32 -# define UNUSED -#else -# define UNUSED __attribute__((unused)) -#endif - class BlobTests : public ::testing::Test { protected: std::shared_ptr createMockAllocator() { @@ -78,7 +72,10 @@ TEST_F(BlobTests, doesNotUnlockIfLockFailed) { InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, std::dynamic_pointer_cast(allocator)); blob.allocate(); - { float UNUSED* ptr = blob.data(); } + { + float* ptr = blob.data(); + (void)ptr; + } } TEST_F(BlobTests, canAccessDataUsingAllocator) { diff --git a/src/plugins/auto/CMakeLists.txt b/src/plugins/auto/CMakeLists.txt index a0fc390b985..312ac4a7966 100644 --- a/src/plugins/auto/CMakeLists.txt +++ b/src/plugins/auto/CMakeLists.txt @@ -1,12 +1,11 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # + if(NOT ENABLE_AUTO AND NOT ENABLE_MULTI) return() endif() - - set (TARGET_NAME "openvino_auto_plugin") file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/*.cpp) diff --git a/src/plugins/auto/src/utils/time_utils.cpp b/src/plugins/auto/src/utils/time_utils.cpp index dec1aea32f0..e311d602922 100644 --- a/src/plugins/auto/src/utils/time_utils.cpp +++ b/src/plugins/auto/src/utils/time_utils.cpp @@ -14,7 +14,7 @@ namespace TimeUtils { bool localtimeSafe(const time_t* time, struct tm* result) { if (time && result) { -#if (defined(_WIN32) || defined(_WIN64)) +#if defined(_WIN32) localtime_s(result, time); #else localtime_r(time, result); @@ -32,7 +32,7 @@ std::string putTime(std::chrono::system_clock::time_point tp, const char* format std::stringstream ss; -#if (defined(__GNUC__) && (__GNUC__ < 5)) +#if (defined(__GNUC__) && (__GNUC__ < 5)) && !defined(__clang__) char time_str[24]; strftime(time_str, sizeof(time_str), format, &t); ss << time_str; diff --git a/src/plugins/auto/tests/unit/auto_async_infer_request_test.cpp b/src/plugins/auto/tests/unit/auto_async_infer_request_test.cpp index d33c0e0ce73..d9b150cc700 100644 --- a/src/plugins/auto/tests/unit/auto_async_infer_request_test.cpp +++ b/src/plugins/auto/tests/unit/auto_async_infer_request_test.cpp @@ -1,6 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // + +#include + #include "include/mock_auto_device_plugin.hpp" #include "include/auto_infer_request_test_base.hpp" diff --git a/src/plugins/auto/tests/unit/auto_dynamic_output_test.cpp b/src/plugins/auto/tests/unit/auto_dynamic_output_test.cpp index 9f1783c174d..55a8660d849 100644 --- a/src/plugins/auto/tests/unit/auto_dynamic_output_test.cpp +++ b/src/plugins/auto/tests/unit/auto_dynamic_output_test.cpp @@ -1,6 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // + +#include + #include "include/mock_auto_device_plugin.hpp" #include "include/auto_infer_request_test_base.hpp" diff --git a/src/plugins/auto/tests/unit/auto_infer_request_test_base.cpp b/src/plugins/auto/tests/unit/auto_infer_request_test_base.cpp index c9f715c5b0d..dc7ba31e4d7 100644 --- a/src/plugins/auto/tests/unit/auto_infer_request_test_base.cpp +++ b/src/plugins/auto/tests/unit/auto_infer_request_test_base.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "include/auto_infer_request_test_base.hpp" mockAsyncInferRequest::mockAsyncInferRequest(const InferenceEngine::IInferRequestInternal::Ptr &inferRequest, diff --git a/src/plugins/auto/tests/unit/auto_runtime_fallback_test.cpp b/src/plugins/auto/tests/unit/auto_runtime_fallback_test.cpp index fc90baf68ab..db2b323506e 100644 --- a/src/plugins/auto/tests/unit/auto_runtime_fallback_test.cpp +++ b/src/plugins/auto/tests/unit/auto_runtime_fallback_test.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include diff --git a/src/plugins/auto/tests/unit/log_utils_test.cpp b/src/plugins/auto/tests/unit/log_utils_test.cpp index 54fd53d5b88..70f1e683441 100644 --- a/src/plugins/auto/tests/unit/log_utils_test.cpp +++ b/src/plugins/auto/tests/unit/log_utils_test.cpp @@ -11,7 +11,7 @@ using ::testing::_; using namespace MockMultiDevice; // disable using windows.h #if 0 -#if (defined(_WIN32) || defined(_WIN64)) +#if defined(_WIN32) #include #elif defined(__linux__) #include diff --git a/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h b/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h index c5f7cb226b2..169d8543550 100644 --- a/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h +++ b/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h @@ -13,8 +13,8 @@ namespace ov { namespace intel_cpu { -DISABLE_WARNING_MSVC_BEGIN(4250) // Visual Studio warns us about inheritance via dominance but it's done intentionally - // so turn it off +OPENVINO_DISABLE_WARNING_MSVC_BEGIN(4250) // Visual Studio warns us about inheritance via dominance but it's done intentionally + // so turn it off class DnnlBlockedMemoryDesc : public BlockedMemoryDesc, public DnnlMemoryDesc { public: // Creates planar DnnlBlockedMemoryDesc @@ -100,7 +100,7 @@ private: friend std::shared_ptr DnnlExtensionUtils::makeUndefinedDesc(const dnnl::memory::desc &desc, const Shape& shape); friend class MemoryDescUtils; }; -DISABLE_WARNING_MSVC_END(4250) +OPENVINO_DISABLE_WARNING_MSVC_END(4250) using DnnlBlockedMemoryDescPtr = std::shared_ptr; using DnnlBlockedMemoryDescCPtr = std::shared_ptr; diff --git a/src/plugins/intel_cpu/src/nodes/common/defs.h b/src/plugins/intel_cpu/src/nodes/common/defs.h index 579fa2d2474..f5eab4b30c3 100644 --- a/src/plugins/intel_cpu/src/nodes/common/defs.h +++ b/src/plugins/intel_cpu/src/nodes/common/defs.h @@ -11,23 +11,3 @@ # include # endif #endif - -#ifdef _WIN32 -# if defined (__INTEL_COMPILER) -# define DLSDK_EXT_IVDEP() __pragma(ivdep) -# elif defined(_MSC_VER) -# define DLSDK_EXT_IVDEP() __pragma(loop(ivdep)) -# else -# define DLSDK_EXT_IVDEP() -# endif -#elif defined(__linux__) -# if defined(__INTEL_COMPILER) -# define DLSDK_EXT_IVDEP() _Pragma("ivdep") -# elif defined(__GNUC__) -# define DLSDK_EXT_IVDEP() _Pragma("GCC ivdep") -# else -# define DLSDK_EXT_IVDEP() -# endif -#else -# define DLSDK_EXT_IVDEP() -#endif diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp index 10a5a5bd06d..2f59f155cd0 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp @@ -39,7 +39,7 @@ namespace { 1 }; - static std::shared_ptr simple_function_non_max_supression_internal(ngraph::element::Type, size_t) { + static std::shared_ptr simple_function_non_max_suppression_internal(ngraph::element::Type, size_t) { auto boxes = std::make_shared(element::f32, Shape{1, 1000, 4}); auto scores = std::make_shared(element::f32, Shape{1, 1, 1000}); auto max_output_boxes_per_class = ov::op::v0::Constant::create(element::i32, Shape{1}, {10}); @@ -77,7 +77,7 @@ namespace { static std::vector internal_functions_cpu() { std::vector funcs = { - ovModelWithName { simple_function_non_max_supression_internal, "NonMaxSuppressionIEInternal"}, + ovModelWithName { simple_function_non_max_suppression_internal, "NonMaxSuppressionIEInternal"}, ovModelWithName { simple_function_matrix_nms_internal, "NmsStaticShapeIE_MatrixNms"}, ovModelWithName { simple_function_multiclass_nms_internal, "MulticlassNmsIEInternal"}, }; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/plugin/caching_tests.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/plugin/caching_tests.cpp index e2d517232d3..22ac9df2c0c 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/plugin/caching_tests.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/plugin/caching_tests.cpp @@ -39,7 +39,7 @@ namespace { 1 }; - static std::shared_ptr simple_function_non_max_supression_internal(ngraph::element::Type, size_t) { + static std::shared_ptr simple_function_non_max_suppression_internal(ngraph::element::Type, size_t) { auto boxes = std::make_shared(element::f32, Shape{1, 1000, 4}); auto scores = std::make_shared(element::f32, Shape{1, 1, 1000}); auto max_output_boxes_per_class = opset1::Constant::create(element::i32, Shape{1}, {10}); @@ -77,7 +77,7 @@ namespace { static std::vector internal_functions_cpu() { std::vector funcs = { - nGraphFunctionWithName { simple_function_non_max_supression_internal, "NonMaxSuppressionIEInternal"}, + nGraphFunctionWithName { simple_function_non_max_suppression_internal, "NonMaxSuppressionIEInternal"}, nGraphFunctionWithName { simple_function_matrix_nms_internal, "NmsStaticShapeIE_MatrixNms"}, nGraphFunctionWithName { simple_function_multiclass_nms_internal, "MulticlassNmsIEInternal"}, }; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 51b3a405de8..a42f7adeba7 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -216,7 +216,7 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(smoke_Snippets.*)"); #endif -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) retVector.emplace_back(R"(.*LoadNetworkCompiledKernelsCacheTest.*CanCreateCacheDirAndDumpBinariesUnicodePath.*)"); #endif diff --git a/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake b/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake new file mode 100644 index 00000000000..2df390711a8 --- /dev/null +++ b/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake @@ -0,0 +1,360 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR) + set(ARM_COMPUTE_INCLUDE_DIR "" CACHE PATH "Path to ARM Compute Library headers" FORCE) + + if(NOT ARM_COMPUTE_LIB_DIR) + message(FATAL_ERROR "Undefined ARM_COMPUTE_LIB_DIR input variable should be set manually") + elseif(NOT TARGET arm_compute::arm_compute) + if(WIN32 OR APPLE) + if(OV_GENERATOR_MULTI_CONFIG) + set(extra_args PATH_SUFFIXES ${CMAKE_CONFIGURATION_TYPES}) + else() + set(extra_args PATH_SUFFIXES ${CMAKE_BUILD_TYPE}) + endif() + endif() + + find_library(ARM_COMPUTE_LIB + NAMES arm_compute-static + PATHS ${ARM_COMPUTE_LIB_DIR} + ${extra_args}) + unset(extra_args) + + message(STATUS "Found arm_compute-static: ${ARM_COMPUTE_LIB}") + + add_library(arm_compute::arm_compute STATIC IMPORTED GLOBAL) + set_target_properties(arm_compute::arm_compute PROPERTIES + IMPORTED_LOCATION ${ARM_COMPUTE_LIB}) + + add_library(arm_compute::half INTERFACE IMPORTED GLOBAL) + + if(ARM_COMPUTE_INCLUDE_DIR) + set_target_properties(arm_compute::arm_compute arm_compute::half PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_INCLUDE_DIR}) + endif() + endif() + + # for oneDNN integration + + set(ACL_FOUND ON) + set(ACL_LIBRARIES arm_compute::arm_compute arm_compute::half) + + foreach(acl_library IN LISTS ACL_LIBRARIES) + list(APPEND ACL_INCLUDE_DIRS + $) + endforeach() +elseif(ENABLE_ARM_COMPUTE_CMAKE) + set(ARM_COMPUTE_SOURCE_DIR "${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary") + set(ARM_COMPUTE_BINARY_DIR "${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary") + + function(ov_build_compute_library) + # build ComputeLibrary as static libraries + set(BUILD_SHARED_LIBS OFF) + # ComputeLibrary settings + set(ARM_COMPUTE_GRAPH_ENABLED OFF CACHE BOOL "" FORCE) + # disable OpenMP + set(OPENMP OFF CACHE BOOL "" FORCE) + # and use std::threads instead + set(CPPTHREADS OFF CACHE BOOL "" FORCE) + # SVE is not supported on Darwin + if(CMAKE_HOST_APPLE) + set(ENABLE_SVE OFF CACHE BOOL "" FORCE) + set(ARM_COMPUTE_ENABLE_SVE OFF CACHE BOOL "" FORCE) + set(ARM_COMPUTE_ENABLE_SVEF32MM OFF CACHE BOOL "" FORCE) + endif() + + add_subdirectory(${ARM_COMPUTE_SOURCE_DIR} ${ARM_COMPUTE_BINARY_DIR} EXCLUDE_FROM_ALL) + + add_library(ArmCompute::Half INTERFACE IMPORTED GLOBAL) + set_target_properties(ArmCompute::Half PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ARM_COMPUTE_SOURCE_DIR}/include") + endfunction() + + ov_build_compute_library() + + # Helpers for oneDNN intergation + + set(ACL_FOUND ON) + set(ACL_LIBRARIES arm_compute_core ArmCompute::Half) + + foreach(acl_library IN LISTS ACL_LIBRARIES) + list(APPEND ACL_INCLUDE_DIRS + $) + endforeach() + + # required by oneDNN to attempt to parse ACL version + set(ENV{ACL_ROOT_DIR} "${ARM_COMPUTE_SOURCE_DIR}") +elseif(NOT TARGET arm_compute::arm_compute) + set(ARM_COMPUTE_SOURCE_DIR "${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary") + set(ARM_COMPUTE_BINARY_DIR "${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary") + + message(STATUS "Configure to build ${ARM_COMPUTE_SOURCE_DIR}") + + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) + list(APPEND find_scons_extra_options REQUIRED) + endif() + + find_host_program(SCONS scons ${find_scons_extra_options}) + + if(NOT SCONS) + message(FATAL_ERROR "Scons tool is not found!") + endif() + + file(GLOB_RECURSE SOURCES + ${ARM_COMPUTE_SOURCE_DIR}/*.cpp + ${ARM_COMPUTE_SOURCE_DIR}/*.hpp + ${ARM_COMPUTE_SOURCE_DIR}/*.h + ) + + set(extra_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-undef") + if(MSVC64) + # clang-cl does not recognize /MP option + string(REPLACE "/MP " "" extra_cxx_flags "${extra_cxx_flags}") + elseif(CMAKE_POSITION_INDEPENDENT_CODE) + # -fPIC is not applicable for clang-cl + set(extra_cxx_flags "${extra_cxx_flags} -fPIC") + endif() + + set(ARM_COMPUTE_OPTIONS + neon=1 + opencl=0 + openmp=0 + cppthreads=1 + examples=0 + Werror=0 + gemm_tuner=0 + reference_openmp=0 + validation_tests=0 + benchmark_tests=0 + # TODO: check this for Apple Silicon + # multi_isa=1 + # TODO: use CC for ARM compute library to minimize binary size + # build_config= + # TODO: use data_type_support to disable useless kernels + data_layout_support=all + arch=${ARM_COMPUTE_TARGET_ARCH} + ) + + if(NOT MSVC64) + list(APPEND ARM_COMPUTE_OPTIONS + build_dir=${ARM_COMPUTE_BINARY_DIR} + install_dir=${ARM_COMPUTE_BINARY_DIR}/install) + endif() + + if(ARM_COMPUTE_SCONS_JOBS) + list(APPEND ARM_COMPUTE_OPTIONS --jobs=${ARM_COMPUTE_SCONS_JOBS}) + endif() + + set(ARM_COMPUTE_DEBUG_OPTIONS + debug=1 + asserts=1 + logging=1) + + # cmake older 3.20 does not support generator expressions in add_custom_command + # https://cmake.org/cmake/help/latest/command/add_custom_command.html#examples-generating-files + if(OV_GENERATOR_MULTI_CONFIG AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + foreach(option IN LISTS ARM_COMPUTE_DEBUG_OPTIONS) + list(APPEND ARM_COMPUTE_OPTIONS $<$:${option}> + $<$:${option}>) + endforeach() + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER "${config}" config_upper) + set(flags ${CMAKE_CXX_FLAGS_${config_upper}}) + set(extra_cxx_flags "${extra_cxx_flags} $<$:${flags}>") + endforeach() + elseif(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + list(APPEND ARM_COMPUTE_OPTIONS ${ARM_COMPUTE_DEBUG_OPTIONS}) + endif() + + if(EMSCRIPTEN OR LINUX) + list(APPEND ARM_COMPUTE_OPTIONS os=linux) + elseif(ANDROID) + list(APPEND ARM_COMPUTE_OPTIONS os=android) + elseif(APPLE) + list(APPEND ARM_COMPUTE_OPTIONS os=macos) + elseif(WIN32) + list(APPEND ARM_COMPUTE_OPTIONS os=windows) + endif() + + if(CMAKE_CROSSCOMPILING) + list(APPEND ARM_COMPUTE_OPTIONS build=cross_compile) + else() + list(APPEND ARM_COMPUTE_OPTIONS build=native) + endif() + + if (CMAKE_CXX_COMPILER_LAUNCHER) + list(APPEND ARM_COMPUTE_OPTIONS compiler_cache=${CMAKE_CXX_COMPILER_LAUNCHER}) + endif() + + # used to build for yocto + if(ARM_COMPUTE_TOOLCHAIN_PREFIX) + list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix=${ARM_COMPUTE_TOOLCHAIN_PREFIX}) + endif() + + if(ANDROID) + if(ANDROID_PLATFORM_LEVEL LESS 18) + message(FATAL_ERROR "ARM compute library requires Android API 18 level and higher" + "Please, speficy -DANDROID_PLATFORM=android-18 at least") + endif() + + if(ANDROID_NDK_REVISION LESS "23.0") + list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${ANDROID_TOOLCHAIN_PREFIX}") + else() + string(REGEX REPLACE "/bin/[^/]+-" "/bin/llvm-" ANDROID_TOOLCHAIN_PREFIX_FIXED "${ANDROID_TOOLCHAIN_PREFIX}") + message(STATUS "SCONS: using ANDROID_TOOLCHAIN_PREFIX=${ANDROID_TOOLCHAIN_PREFIX_FIXED}") + list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${ANDROID_TOOLCHAIN_PREFIX_FIXED}") + endif() + + list(APPEND ARM_COMPUTE_OPTIONS + compiler_prefix="${ANDROID_TOOLCHAIN_ROOT}/bin/") + + set(extra_flags "${extra_flags} --target=${ANDROID_LLVM_TRIPLE}") + set(extra_flags "${extra_flags} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT}") + set(extra_flags "${extra_flags} --sysroot=${CMAKE_SYSROOT}") + + set(extra_link_flags "${extra_link_flags} ${extra_flags}") + set(extra_cxx_flags "${extra_cxx_flags} ${extra_flags}") + elseif(LINUX) + # we need to bypass this information in case of custom compiler is passed + # to cmake call. Such compiler and compiler prefix need to be passed to scons + get_filename_component(cxx_compiler "${CMAKE_CXX_COMPILER}" NAME) + get_filename_component(c_compiler "${CMAKE_C_COMPILER}" NAME) + get_filename_component(compiler_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY) + + set(cmake_build_env + CC=${c_compiler} + CXX=${cxx_compiler}) + list(APPEND ARM_COMPUTE_OPTIONS compiler_prefix="${compiler_prefix}/") + elseif(EMSCRIPTEN) + set(cmake_build_env + CC=emcc + CXX=em++ + RANLIB=emranlib + AR=emar) + # EMSDK: Passing any of -msse, -msse2, -msse3, -mssse3, -msse4.1, -msse4.2, + # -msse4, -mavx, -mfpu=neon flags also requires passing -msimd128 (or -mrelaxed-simd)! + set(extra_cxx_flags "${extra_cxx_flags} -msimd128") + # clang-16: error: argument unused during compilation: '-mthumb' [-Werror,-Wunused-command-line-argument] + # clang-16: error: argument unused during compilation: '-mfloat-abi=hard' [-Werror,-Wunused-command-line-argument] + set(extra_cxx_flags "${extra_cxx_flags} \ + -Wno-unused-command-line-argument \ + -Wno-unknown-warning-option \ + -Wno-unused-function \ + -Wno-unused-but-set-variable") + + get_filename_component(toolchain_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY) + list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${toolchain_prefix}/") + elseif(APPLE) + if(CMAKE_OSX_DEPLOYMENT_TARGET) + set(extra_cxx_flags "${extra_cxx_flags} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + set(minos_added ON) + endif() + + if(HOST_X86_64) + if(NOT minos_added) + message(FATAL_ERROR "Please, specify either env MACOSX_DEPLOYMENT_TARGET or cmake CMAKE_OSX_DEPLOYMENT_TARGET variables") + endif() + set(extra_cxx_flags "${extra_cxx_flags} --sysroot ${CMAKE_OSX_SYSROOT}") + endif() + + set(extra_cxx_flags "${extra_cxx_flags} -Wno-error=return-stack-address") + get_filename_component(compiler_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY) + list(APPEND ARM_COMPUTE_OPTIONS compiler_prefix="${compiler_prefix}/") + + if(CMAKE_OSX_ARCHITECTURES) + foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES) + set(extra_cxx_flags "${extra_cxx_flags} -arch ${arch}") + endforeach() + endif() + elseif(MSVC64) + # required for clang-cl compiler + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + set(extra_cxx_flags "${extra_cxx_flags} $,/MD,/MDd>") + else() + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(extra_cxx_flags "${extra_cxx_flags} /MDd") + else() + set(extra_cxx_flags "${extra_cxx_flags} /MD") + endif() + endif() + endif() + + if(ENABLE_LTO) + if((CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) AND NOT CMAKE_CROSSCOMPILING) + set(extra_cxx_flags "${extra_cxx_flags} -flto=thin") + set(extra_link_flags "${extra_link_flags} -flto=thin") + endif() + endif() + + if(SUGGEST_OVERRIDE_SUPPORTED) + set(extra_cxx_flags "${extra_cxx_flags} -Wno-suggest-override") + endif() + + if(extra_link_flags) + list(APPEND ARM_COMPUTE_OPTIONS extra_link_flags=${extra_link_flags}) + endif() + if(extra_cxx_flags) + list(APPEND ARM_COMPUTE_OPTIONS extra_cxx_flags=${extra_cxx_flags}) + endif() + + if(NOT CMAKE_VERBOSE_MAKEFILE) + list(APPEND ARM_COMPUTE_OPTIONS --silent) + endif() + + if(MSVC64) + set(arm_compute build/arm_compute-static.lib) + set(arm_compute_full_path "${ARM_COMPUTE_SOURCE_DIR}/${arm_compute}") + else() + set(arm_compute ${ARM_COMPUTE_BINARY_DIR}/libarm_compute-static.a) + set(arm_compute_full_path "${arm_compute}") + endif() + + add_custom_command( + OUTPUT + ${arm_compute_full_path} + COMMAND ${CMAKE_COMMAND} -E env ${cmake_build_env} + ${SCONS} ${ARM_COMPUTE_OPTIONS} + ${arm_compute} + WORKING_DIRECTORY ${ARM_COMPUTE_SOURCE_DIR} + COMMENT "Build Arm Compute Library" + DEPENDS ${SOURCES} + ${CMAKE_CURRENT_LIST_FILE} + ${ARM_COMPUTE_SOURCE_DIR}/SConscript + ${ARM_COMPUTE_SOURCE_DIR}/SConstruct) + + # Compute Library uses cppthreads=1 + # if one day will rely on TBB only, we can omit this dependency + find_package(Threads REQUIRED) + + # Import targets + + add_custom_target(arm_compute_static_libs DEPENDS ${arm_compute_full_path}) + + add_library(arm_compute::arm_compute STATIC IMPORTED GLOBAL) + set_target_properties(arm_compute::arm_compute PROPERTIES + IMPORTED_LOCATION ${arm_compute_full_path} + INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR} + INTERFACE_LINK_LIBRARIES Threads::Threads + OSX_ARCHITECTURES arm64) + add_dependencies(arm_compute::arm_compute arm_compute_static_libs) + + add_library(arm_compute::half INTERFACE IMPORTED GLOBAL) + set_target_properties(arm_compute::half PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}/include + OSX_ARCHITECTURES arm64) + + # Helpers for oneDNN intergation + + set(ACL_FOUND ON) + set(ACL_LIBRARIES arm_compute::arm_compute arm_compute::half) + + foreach(acl_library IN LISTS ACL_LIBRARIES) + list(APPEND ACL_INCLUDE_DIRS + $) + endforeach() + + # required by oneDNN to attempt to parse ACL version + set(ENV{ACL_ROOT_DIR} "${ARM_COMPUTE_SOURCE_DIR}") +endif() diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt index 458bbdffa4c..8c645814fa3 100644 --- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt @@ -15,7 +15,7 @@ if(ENABLE_LTO) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) endif() -function(ie_add_onednn) +function(ov_add_onednn) set(DNNL_ENABLE_JIT_PROFILING ${BUILD_SHARED_LIBS} CACHE BOOL "" FORCE) if(BUILD_SHARED_LIBS AND ENABLE_PROFILING_ITT) set(DNNL_ENABLE_ITT_TASKS ON CACHE BOOL "" FORCE) @@ -137,16 +137,26 @@ function(ie_add_onednn) endif() # to find our FindACL.cmake - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + list(APPEND CMAKE_MODULE_PATH "${intel_cpu_thirdparty_SOURCE_DIR}") add_subdirectory(onednn EXCLUDE_FROM_ALL) + # install static libraries ov_install_static_lib(dnnl cpu) - if(ARM OR AARCH64) - ov_install_static_lib(arm_compute_core cpu) + + if(DNNL_USE_ACL AND NOT BUILD_SHARED_LIBS) + # use ACLConfig.cmake in OpenVINOConfig.cmake in case of static build + # we cannot use 'ov_install_static_lib' for imported targets, + # but for this we need to install library files + install(FILES $ + DESTINATION ${OV_CPACK_ARCHIVEDIR} + COMPONENT cpu) + install(FILES "${intel_cpu_thirdparty_SOURCE_DIR}/ACLConfig.cmake" + DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} + COMPONENT core_dev) endif() endfunction() if(ENABLE_INTEL_CPU) - ie_add_onednn() + ov_add_onednn() endif() diff --git a/src/plugins/intel_cpu/thirdparty/FindACL.cmake b/src/plugins/intel_cpu/thirdparty/FindACL.cmake index 61772f39a96..057dcee3f5d 100644 --- a/src/plugins/intel_cpu/thirdparty/FindACL.cmake +++ b/src/plugins/intel_cpu/thirdparty/FindACL.cmake @@ -2,334 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 # -if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR) - if (NOT ARM_COMPUTE_INCLUDE_DIR) - message(FATAL_ERROR "Undefined ARM_COMPUTE_INCLUDE_DIR input variable should be set manually") - else() - message(STATUS "Using ${ARM_COMPUTE_INCLUDE_DIR} to include arm compute library headers") - endif() - - if (NOT ARM_COMPUTE_LIB_DIR) - message(FATAL_ERROR "Undefined ARM_COMPUTE_LIB_DIR input variable should be set manually") - else() - find_library( - ARM_COMPUTE_LIB - arm_compute-static - PATHS ${ARM_COMPUTE_LIB_DIR} - ) - message(STATUS "Found arm_compute-static: ${ARM_COMPUTE_LIB}") - add_library(arm_compute STATIC IMPORTED GLOBAL) - set_target_properties(arm_compute PROPERTIES - IMPORTED_LOCATION ${ARM_COMPUTE_LIB} - INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_INCLUDE_DIR}) - endif() - - add_library(half INTERFACE IMPORTED GLOBAL) - set_target_properties(half PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_INCLUDE_DIR}) -elseif(ENABLE_ARM_COMPUTE_CMAKE) - set(ARM_COMPUTE_SOURCE_DIR "${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary") - set(ARM_COMPUTE_BINARY_DIR "${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary") - - function(ov_build_compute_library) - # build ComputeLibrary as static libraries - set(BUILD_SHARED_LIBS OFF) - # ComputeLibrary settings - set(ARM_COMPUTE_GRAPH_ENABLED OFF CACHE BOOL "" FORCE) - # disable OpenMP - set(OPENMP OFF CACHE BOOL "" FORCE) - # and use std::threads instead - set(CPPTHREADS OFF CACHE BOOL "" FORCE) - # SVE is not supported on Darwin - if(CMAKE_HOST_APPLE) - set(ENABLE_SVE OFF CACHE BOOL "" FORCE) - set(ARM_COMPUTE_ENABLE_SVE OFF CACHE BOOL "" FORCE) - set(ARM_COMPUTE_ENABLE_SVEF32MM OFF CACHE BOOL "" FORCE) - endif() - - add_subdirectory(${ARM_COMPUTE_SOURCE_DIR} ${ARM_COMPUTE_BINARY_DIR} EXCLUDE_FROM_ALL) - - add_library(ArmCompute::Half INTERFACE IMPORTED GLOBAL) - set_target_properties(ArmCompute::Half PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ARM_COMPUTE_SOURCE_DIR}/include") - endfunction() - - ov_build_compute_library() - - # Helpers for oneDNN intergation - - set(ACL_FOUND ON) - set(ACL_LIBRARIES arm_compute_core ArmCompute::Half) - - foreach(acl_library IN LISTS ACL_LIBRARIES) - list(APPEND ACL_INCLUDE_DIRS - $) - endforeach() - - # required by oneDNN to attempt to parse ACL version - set(ENV{ACL_ROOT_DIR} "${ARM_COMPUTE_SOURCE_DIR}") -else() - set(ARM_COMPUTE_SOURCE_DIR "${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary") - set(ARM_COMPUTE_BINARY_DIR "${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary") - - message(STATUS "Configure to build ${ARM_COMPUTE_SOURCE_DIR}") - - find_host_program(SCONS scons) - - if(NOT SCONS) - message(FATAL_ERROR "Scons tool is not found!") - endif() - - file(GLOB_RECURSE SOURCES - ${ARM_COMPUTE_SOURCE_DIR}/*.cpp - ${ARM_COMPUTE_SOURCE_DIR}/*.hpp - ${ARM_COMPUTE_SOURCE_DIR}/*.h - ) - - set(extra_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-undef") - if(MSVC64) - # clang-cl does not recognize /MP option - string(REPLACE "/MP " "" extra_cxx_flags "${extra_cxx_flags}") - elseif(CMAKE_POSITION_INDEPENDENT_CODE) - # -fPIC is not applicable for clang-cl - set(extra_cxx_flags "${extra_cxx_flags} -fPIC") - endif() - - set(ARM_COMPUTE_OPTIONS - neon=1 - opencl=0 - openmp=0 - cppthreads=1 - examples=0 - Werror=0 - gemm_tuner=0 - reference_openmp=0 - validation_tests=0 - benchmark_tests=0 - # TODO: check this for Apple Silicon - # multi_isa=1 - # TODO: use CC for ARM compute library to minimize binary size - # build_config= - # TODO: use data_type_support to disable useless kernels - data_layout_support=all - arch=${ARM_COMPUTE_TARGET_ARCH} - ) - - if(NOT MSVC64) - list(APPEND ARM_COMPUTE_OPTIONS - build_dir=${ARM_COMPUTE_BINARY_DIR} - install_dir=${ARM_COMPUTE_BINARY_DIR}/install) - endif() - - if(ARM_COMPUTE_SCONS_JOBS) - list(APPEND ARM_COMPUTE_OPTIONS --jobs=${ARM_COMPUTE_SCONS_JOBS}) - endif() - - set(ARM_COMPUTE_DEBUG_OPTIONS - debug=1 - asserts=1 - logging=1) - - # cmake older 3.20 does not support generator expressions in add_custom_command - # https://cmake.org/cmake/help/latest/command/add_custom_command.html#examples-generating-files - if(OV_GENERATOR_MULTI_CONFIG AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) - foreach(option IN LISTS ARM_COMPUTE_DEBUG_OPTIONS) - list(APPEND ARM_COMPUTE_OPTIONS $<$:${option}> - $<$:${option}>) - endforeach() - foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) - string(TOUPPER "${config}" config_upper) - set(flags ${CMAKE_CXX_FLAGS_${config_upper}}) - set(extra_cxx_flags "${extra_cxx_flags} $<$:${flags}>") - endforeach() - elseif(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") - list(APPEND ARM_COMPUTE_OPTIONS ${ARM_COMPUTE_DEBUG_OPTIONS}) - endif() - - if(EMSCRIPTEN OR LINUX) - list(APPEND ARM_COMPUTE_OPTIONS os=linux) - elseif(ANDROID) - list(APPEND ARM_COMPUTE_OPTIONS os=android) - elseif(APPLE) - list(APPEND ARM_COMPUTE_OPTIONS os=macos) - elseif(WIN32) - list(APPEND ARM_COMPUTE_OPTIONS os=windows) - endif() - - if(CMAKE_CROSSCOMPILING) - list(APPEND ARM_COMPUTE_OPTIONS build=cross_compile) - else() - list(APPEND ARM_COMPUTE_OPTIONS build=native) - endif() - - if (CMAKE_CXX_COMPILER_LAUNCHER) - list(APPEND ARM_COMPUTE_OPTIONS compiler_cache=${CMAKE_CXX_COMPILER_LAUNCHER}) - endif() - - # used to build for yocto - if(ARM_COMPUTE_TOOLCHAIN_PREFIX) - list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix=${ARM_COMPUTE_TOOLCHAIN_PREFIX}) - endif() - - if(ANDROID) - if(ANDROID_PLATFORM_LEVEL LESS 18) - message(FATAL_ERROR "ARM compute library requires Android API 18 level and higher" - "Please, speficy -DANDROID_PLATFORM=android-18 at least") - endif() - - if(ANDROID_NDK_REVISION LESS "23.0") - list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${ANDROID_TOOLCHAIN_PREFIX}") - else() - string(REGEX REPLACE "/bin/[^/]+-" "/bin/llvm-" ANDROID_TOOLCHAIN_PREFIX_FIXED "${ANDROID_TOOLCHAIN_PREFIX}") - message(STATUS "SCONS: using ANDROID_TOOLCHAIN_PREFIX=${ANDROID_TOOLCHAIN_PREFIX_FIXED}") - list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${ANDROID_TOOLCHAIN_PREFIX_FIXED}") - endif() - - list(APPEND ARM_COMPUTE_OPTIONS - compiler_prefix="${ANDROID_TOOLCHAIN_ROOT}/bin/") - - set(extra_flags "${extra_flags} --target=${ANDROID_LLVM_TRIPLE}") - set(extra_flags "${extra_flags} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT}") - set(extra_flags "${extra_flags} --sysroot=${CMAKE_SYSROOT}") - - set(extra_link_flags "${extra_link_flags} ${extra_flags}") - set(extra_cxx_flags "${extra_cxx_flags} ${extra_flags}") - elseif(CMAKE_CROSSCOMPILING AND LINUX) - get_filename_component(cxx_compiler "${CMAKE_CXX_COMPILER}" NAME) - get_filename_component(c_compiler "${CMAKE_C_COMPILER}" NAME) - get_filename_component(compiler_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY) - - set(cmake_build_env - CC=${c_compiler} - CXX=${cxx_compiler}) - list(APPEND ARM_COMPUTE_OPTIONS compiler_prefix="${compiler_prefix}/") - elseif(EMSCRIPTEN) - set(cmake_build_env - CC=emcc - CXX=em++ - RANLIB=emranlib - AR=emar) - # EMSDK: Passing any of -msse, -msse2, -msse3, -mssse3, -msse4.1, -msse4.2, - # -msse4, -mavx, -mfpu=neon flags also requires passing -msimd128 (or -mrelaxed-simd)! - set(extra_cxx_flags "${extra_cxx_flags} -msimd128") - # clang-16: error: argument unused during compilation: '-mthumb' [-Werror,-Wunused-command-line-argument] - # clang-16: error: argument unused during compilation: '-mfloat-abi=hard' [-Werror,-Wunused-command-line-argument] - set(extra_cxx_flags "${extra_cxx_flags} \ - -Wno-unused-command-line-argument \ - -Wno-unknown-warning-option \ - -Wno-unused-function \ - -Wno-unused-but-set-variable") - - get_filename_component(toolchain_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY) - list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${toolchain_prefix}/") - elseif(APPLE) - if(CMAKE_OSX_DEPLOYMENT_TARGET) - set(extra_cxx_flags "${extra_cxx_flags} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") - set(minos_added ON) - endif() - - if(HOST_X86_64) - if(NOT minos_added) - message(FATAL_ERROR "Please, specify either env MACOSX_DEPLOYMENT_TARGET or cmake CMAKE_OSX_DEPLOYMENT_TARGET variables") - endif() - set(extra_cxx_flags "${extra_cxx_flags} --sysroot ${CMAKE_OSX_SYSROOT}") - endif() - - set(extra_cxx_flags "${extra_cxx_flags} -Wno-error=return-stack-address") - get_filename_component(compiler_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY) - list(APPEND ARM_COMPUTE_OPTIONS compiler_prefix="${compiler_prefix}/") - - if(CMAKE_OSX_ARCHITECTURES) - foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES) - set(extra_cxx_flags "${extra_cxx_flags} -arch ${arch}") - endforeach() - endif() - elseif(MSVC64) - # required for clang-cl compiler - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) - set(extra_cxx_flags "${extra_cxx_flags} $,/MD,/MDd>") - else() - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(extra_cxx_flags "${extra_cxx_flags} /MDd") - else() - set(extra_cxx_flags "${extra_cxx_flags} /MD") - endif() - endif() - endif() - - if(ENABLE_LTO) - if((CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) AND (NOT CMAKE_CROSSCOMPILING)) - set(extra_cxx_flags "${extra_cxx_flags} -flto=thin") - set(extra_link_flags "${extra_link_flags} -flto=thin") - endif() - endif() - - if(SUGGEST_OVERRIDE_SUPPORTED) - set(extra_cxx_flags "${extra_cxx_flags} -Wno-suggest-override") - endif() - - if(extra_link_flags) - list(APPEND ARM_COMPUTE_OPTIONS extra_link_flags=${extra_link_flags}) - endif() - if(extra_cxx_flags) - list(APPEND ARM_COMPUTE_OPTIONS extra_cxx_flags=${extra_cxx_flags}) - endif() - - if(NOT CMAKE_VERBOSE_MAKEFILE) - list(APPEND ARM_COMPUTE_OPTIONS --silent) - endif() - - if(MSVC64) - set(arm_compute build/arm_compute-static.lib) - set(arm_compute_full_path "${ARM_COMPUTE_SOURCE_DIR}/${arm_compute}") - else() - set(arm_compute ${ARM_COMPUTE_BINARY_DIR}/libarm_compute-static.a) - set(arm_compute_full_path "${arm_compute}") - endif() - - add_custom_command( - OUTPUT - ${arm_compute_full_path} - COMMAND ${CMAKE_COMMAND} -E env ${cmake_build_env} - ${SCONS} ${ARM_COMPUTE_OPTIONS} - ${arm_compute} - WORKING_DIRECTORY ${ARM_COMPUTE_SOURCE_DIR} - COMMENT "Build Arm Compute Library" - DEPENDS ${SOURCES} - ${CMAKE_CURRENT_LIST_FILE} - ${ARM_COMPUTE_SOURCE_DIR}/SConscript - ${ARM_COMPUTE_SOURCE_DIR}/SConstruct) - - # Import targets - - add_custom_target(arm_compute_static_libs DEPENDS ${arm_compute_full_path}) - - add_library(arm_compute::arm_compute STATIC IMPORTED GLOBAL) - set_target_properties(arm_compute::arm_compute PROPERTIES - IMPORTED_LOCATION ${arm_compute_full_path} - INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}) - add_dependencies(arm_compute::arm_compute arm_compute_static_libs) - - add_library(arm_compute::half INTERFACE IMPORTED GLOBAL) - set_target_properties(arm_compute::half PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}/include) - - # Compute Library uses cppthreads=1 - # if one day will rely on TBB only, we can omit this dependency - find_package(Threads REQUIRED) - set_target_properties(arm_compute::arm_compute PROPERTIES - INTERFACE_LINK_LIBRARIES Threads::Threads) - - # Helpers for oneDNN intergation - - set(ACL_FOUND ON) - set(ACL_LIBRARIES arm_compute::arm_compute arm_compute::half) - - foreach(acl_library IN LISTS ACL_LIBRARIES) - list(APPEND ACL_INCLUDE_DIRS - $) - endforeach() - - # required by oneDNN to attempt to parse ACL version - set(ENV{ACL_ROOT_DIR} "${ARM_COMPUTE_SOURCE_DIR}") -endif() +include(${CMAKE_CURRENT_LIST_DIR}/ACLConfig.cmake) diff --git a/src/plugins/intel_gna/CMakeLists.txt b/src/plugins/intel_gna/CMakeLists.txt index 374bb23c650..08b075e66ca 100644 --- a/src/plugins/intel_gna/CMakeLists.txt +++ b/src/plugins/intel_gna/CMakeLists.txt @@ -44,6 +44,7 @@ file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp) find_package(libGNA REQUIRED + NO_MODULE PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake" NO_DEFAULT_PATH) diff --git a/src/plugins/intel_gna/cmake/libGNAConfig.cmake b/src/plugins/intel_gna/cmake/libGNAConfig.cmake index 0b53d5be514..299f4d2d7c4 100644 --- a/src/plugins/intel_gna/cmake/libGNAConfig.cmake +++ b/src/plugins/intel_gna/cmake/libGNAConfig.cmake @@ -19,25 +19,25 @@ # # The example usage: # -# find_package(libGNA COMPONENTS API KERNEL) +# find_package(libGNA NO_MODULE COMPONENTS API KERNEL) # -set(libGNA_FOUND TRUE) +set(libGNA_FOUND ON) set(GNA_KERNEL_LIB_NAME gna CACHE STRING "" FORCE) -if (NOT libGNA_FIND_COMPONENTS) +if(NOT libGNA_FIND_COMPONENTS) set(libGNA_FIND_COMPONENTS "API;KERNEL") endif() foreach (_gna_component ${libGNA_FIND_COMPONENTS}) - set(libGNA_${_gna_component}_FOUND FALSE) - set(libGNA_FIND_REQUIRED_${_gna_component} TRUE) + set(libGNA_${_gna_component}_FOUND OFF) + set(libGNA_FIND_REQUIRED_${_gna_component} ON) endforeach() set(libGNA_LIBRARIES_BASE_PATH ${GNA_PATH} CACHE STRING "" FORCE) -if(libGNA_FIND_REQUIRED_KERNEL) +if(libGNA_FIND_REQUIRED_KERNEL AND NOT TARGET libGNA::KERNEL) find_library(GNA_KERNEL_LIBRARY ${GNA_KERNEL_LIB_NAME} HINTS ${libGNA_LIBRARIES_BASE_PATH} NO_CMAKE_FIND_ROOT_PATH) @@ -55,26 +55,34 @@ if(libGNA_FIND_REQUIRED_KERNEL) IMPORTED_LOCATION_RELEASE "${GNA_KERNEL_LIBRARY}" INTERFACE_LINK_OPTIONS "-Wl,-rpath-link,${libGNA_LIBRARIES_BASE_PATH}") endif() - set(libGNA_KERNEL_FOUND TRUE) else() message(SEND_ERROR "GNA KERNEL library (${GNA_KERNEL_LIB_NAME}) was not found in ${libGNA_LIBRARIES_BASE_PATH}") endif() endif() -if(libGNA_FIND_REQUIRED_API) +if(libGNA_FIND_REQUIRED_API AND NOT TARGET libGNA::API) find_path(libGNA_INCLUDE_DIRS gna2-api.h PATHS "${GNA_EXT_DIR}/include" NO_CMAKE_FIND_ROOT_PATH) if(libGNA_INCLUDE_DIRS) add_library(libGNA::API INTERFACE IMPORTED) set_target_properties(libGNA::API PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${libGNA_INCLUDE_DIRS}") - set(libGNA_API_FOUND TRUE) else() message(SEND_ERROR "GNA API headers (gna2-api.h) was not found in ${GNA_EXT_DIR}/include") endif() endif() -add_library(libGNA INTERFACE IMPORTED) -foreach(_lib_name IN LISTS libGNA_FIND_COMPONENTS) - set_property(TARGET libGNA APPEND PROPERTY INTERFACE_LINK_LIBRARIES libGNA::${_lib_name}) -endforeach(_lib_name) +if(TARGET libGNA::KERNEL) + set(libGNA_KERNEL_FOUND ON) +endif() + +if(TARGET libGNA::API) + set(libGNA_API_FOUND ON) +endif() + +if(NOT TARGET libGNA) + add_library(libGNA INTERFACE IMPORTED) + foreach(_lib_name IN LISTS libGNA_FIND_COMPONENTS) + set_property(TARGET libGNA APPEND PROPERTY INTERFACE_LINK_LIBRARIES libGNA::${_lib_name}) + endforeach() +endif() diff --git a/src/plugins/intel_gna/legacy/include/legacy/ie_layers.h b/src/plugins/intel_gna/legacy/include/legacy/ie_layers.h index fcf4270e81f..e8d6a40f357 100644 --- a/src/plugins/intel_gna/legacy/include/legacy/ie_layers.h +++ b/src/plugins/intel_gna/legacy/include/legacy/ie_layers.h @@ -24,7 +24,7 @@ #include "ie_common.h" #include "ie_data.h" -#ifdef _WIN32 +#ifdef _MSC_VER # define _IE_SUPPRESS_DEPRECATED_START_MSVC IE_SUPPRESS_DEPRECATED_START # define _IE_SUPPRESS_DEPRECATED_END_MSVC IE_SUPPRESS_DEPRECATED_END #else diff --git a/src/plugins/intel_gna/src/gna_plugin.cpp b/src/plugins/intel_gna/src/gna_plugin.cpp index 8a3793a43ba..b77b4a9cc59 100644 --- a/src/plugins/intel_gna/src/gna_plugin.cpp +++ b/src/plugins/intel_gna/src/gna_plugin.cpp @@ -84,13 +84,6 @@ using namespace ov::intel_gna::memory; using namespace ov::intel_gna::frontend; using namespace ov::intel_gna::pre_post_processing; -namespace InferenceEngine { -template <> -InferenceEngine::TBlob>::~TBlob() { - free(); -} -} // namespace InferenceEngine - template void GNAPlugin::copyInputData(T* dst, const U* src, diff --git a/src/plugins/intel_gna/src/log/debug.hpp b/src/plugins/intel_gna/src/log/debug.hpp index 3c531d74474..04733a406a1 100644 --- a/src/plugins/intel_gna/src/log/debug.hpp +++ b/src/plugins/intel_gna/src/log/debug.hpp @@ -26,7 +26,7 @@ #ifdef __PRETTY_FUNCTION__ # undef __PRETTY_FUNCTION__ #endif -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) # define __PRETTY_FUNCTION__ __FUNCSIG__ #else # define __PRETTY_FUNCTION__ __FUNCTION__ diff --git a/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.cpp b/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.cpp index 423adf9f1be..97a7f47faf8 100644 --- a/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.cpp +++ b/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.cpp @@ -19,9 +19,9 @@ # ifndef _WINSOCK2API_ # define _WINSOCK2API_ # endif -# include -# include -# include "Psapi.h" +# include +# include +# include "psapi.h" #endif static size_t parseLine(char* line) { diff --git a/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.hpp b/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.hpp index f12b39a856f..1ed74fb7c1f 100644 --- a/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.hpp +++ b/src/plugins/intel_gna/tests/deprecated/helpers/tests_common.hpp @@ -5,7 +5,9 @@ #pragma once // avoiding clash of the "max" macro with std::max +#ifndef NOMINMAX #define NOMINMAX +#endif #include #include diff --git a/src/plugins/intel_gna/tests/deprecated/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp b/src/plugins/intel_gna/tests/deprecated/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp index 6fbb7611734..fdee73907d1 100644 --- a/src/plugins/intel_gna/tests/deprecated/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp +++ b/src/plugins/intel_gna/tests/deprecated/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp @@ -79,7 +79,7 @@ void readAllFile(const std::string& string_file_name, void* buffer, size_t maxSi std::string file_name = string_file_name; #endif - inputFile.open(file_name, std::ios::binary | std::ios::in); + inputFile.open(file_name.c_str(), std::ios::binary | std::ios::in); if (!inputFile.is_open()) IE_THROW() << "cannot open file " << string_file_name; if (!inputFile.read(reinterpret_cast(buffer), maxSize)) { diff --git a/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt b/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt index 3a4b3fc173c..3b86fccbd70 100644 --- a/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt +++ b/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt @@ -42,7 +42,7 @@ if (ENABLE_INTEL_GNA AND BUILD_SHARED_LIBS) list(REMOVE_ITEM TEST_SRC "${gna_stub}") add_library(libGNAStubs SHARED "${gna_stub}") - find_package(libGNA) + find_package(libGNA NO_MODULE REQUIRED) target_include_directories(libGNAStubs PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/engines/gna/") target_link_libraries(libGNAStubs PUBLIC libGNA::API gmock gtest) diff --git a/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/gna_mock_api.hpp b/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/gna_mock_api.hpp index d38777a2740..95566ea79ca 100644 --- a/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/gna_mock_api.hpp +++ b/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/gna_mock_api.hpp @@ -8,7 +8,7 @@ #include #include -#if defined(_WIN32) +#if defined(_WIN32) || defined(__CYGWIN__) #ifdef libGNAStubs_EXPORTS #define GNA_STUBS_EXPORT __declspec(dllexport) #else diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/helpers.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/helpers.hpp index 391629baba2..68292028756 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/helpers.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/helpers.hpp @@ -3,6 +3,8 @@ // #pragma once + +#include #include #include diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp index 3841cc79692..62409bdc448 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp @@ -10,7 +10,7 @@ namespace cldnn { -/// @brief Performs non max supression of input boxes and returns indices of selected boxes. +/// @brief Performs non max suppression of input boxes and returns indices of selected boxes. /// @detail Filters out boxes that have high intersection-over-union (IOU) with previously /// selected boxes with higher score. Boxes with score higher than score_threshold are /// filtered out. This filtering happens per class. @@ -24,7 +24,7 @@ struct non_max_suppression : public primitive_base { DECLARE_OBJECT_TYPE_SERIALIZATION - /// @brief Creates non max supression primitive. + /// @brief Creates non max suppression primitive. /// @param id This primitive id. /// @param boxes_positions Id of primitive with bounding boxes. /// @param boxes_score Id of primitive with boxes scores per class. diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp index 387a319cbe1..e2a7b1fc0fa 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp index 209c8ef5934..4d4a1d3121d 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #if defined(_WIN32) #ifndef NOMINMAX @@ -18,9 +19,7 @@ #endif #include -#include "Psapi.h" -#elif !defined(__APPLE__) && !defined(__MACOSX) -#include +#include "psapi.h" #endif #include "layout.hpp" @@ -235,7 +234,7 @@ private: GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); footprint.rss = (int64_t)(pmc.WorkingSetSize/1024); footprint.peak_rss = (int64_t)(pmc.PeakWorkingSetSize/1024); -#elif !defined(__APPLE__) && !defined(__MACOSX) +#elif !defined(__APPLE__) std::ifstream status("/proc/self/status"); if (!status.is_open()) return footprint; diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp index bc6483fd9e1..4a0400ed8f5 100644 --- a/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp @@ -153,7 +153,7 @@ vector2D load_boxes(stream& stream, memory::ptr mem, bool center_p case cldnn::data_types::f32: return load_boxes_impl::type>(stream, mem, center_point); default: - throw std::runtime_error("Non max supression - unsupported boxes data type"); + throw std::runtime_error("Non max suppression - unsupported boxes data type"); } } @@ -190,7 +190,7 @@ vector3D load_scores(stream& stream, memory::ptr mem) { case cldnn::data_types::f32: return load_scores_impl::type>(stream, mem); default: - throw std::runtime_error("Non max supression - unsupported scores data type"); + throw std::runtime_error("Non max suppression - unsupported scores data type"); } } @@ -213,7 +213,7 @@ T load_scalar(stream& stream, memory::ptr mem) { case cldnn::data_types::f32: return load_scalar_impl::type>(stream, mem); default: - throw std::runtime_error("Non max supression - unsupported data type"); + throw std::runtime_error("Non max suppression - unsupported data type"); } } @@ -253,7 +253,7 @@ void store_result(stream& stream, memory::ptr mem, const std::vector::type>(stream, mem, result); break; default: - throw std::runtime_error("Non max supression - unsupported output data type"); + throw std::runtime_error("Non max suppression - unsupported output data type"); } } @@ -267,7 +267,7 @@ void store_first_output(stream& stream, memory::ptr mem, const std::vector::type>(stream, mem, result); break; default: - throw std::runtime_error("Non max supression - unsupported output data type"); + throw std::runtime_error("Non max suppression - unsupported output data type"); } } @@ -304,7 +304,7 @@ void store_second_output(stream& stream, memory::ptr mem, const std::vector::type>(stream, mem, result); break; default: - throw std::runtime_error("Non max supression - unsupported second output data type"); + throw std::runtime_error("Non max suppression - unsupported second output data type"); } } @@ -325,7 +325,7 @@ void store_third_output(stream& stream, memory::ptr mem, const std::vector::type>(stream, mem, result); break; default: - throw std::runtime_error("Non max supression - unsupported third output data type"); + throw std::runtime_error("Non max suppression - unsupported third output data type"); } } diff --git a/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp index d12b06d4b36..e403d95c967 100644 --- a/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp +++ b/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp @@ -76,7 +76,7 @@ std::string non_max_suppression_inst::to_string(non_max_suppression_node const& json_composite info; info.add("center point box", desc->center_point_box); - node_info->add("non max supression info", info); + node_info->add("non max suppression info", info); std::stringstream description; node_info->dump(description); diff --git a/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp b/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp index b904fa4f116..cfac486cdfc 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp @@ -16,10 +16,14 @@ #include #ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX #define NOMINMAX +#endif #include -#include +#include #include #include #else @@ -195,12 +199,14 @@ TuningCache* TuningCache::get() { GetModuleFileName(hm, module_path, sizeof(module_path)); std::string bin_path(module_path); path = bin_path.substr(0, bin_path.find_last_of("\\")) + "\\cache.json"; -#else +#elif __linux__ const char* device_info_failed_msg = "Device lookup failed"; Dl_info dl_info; dladdr((void*)(device_info_failed_msg), &dl_info); // NOLINT std::string bin_path(dl_info.dli_fname); path = bin_path.substr(0, bin_path.find_last_of("/")) + "/cache.json"; +#else +#error "Intel GPU plugin: unknown target system" #endif if (!cache_instance) { diff --git a/src/plugins/intel_gpu/src/plugin/custom_layer.cpp b/src/plugins/intel_gpu/src/plugin/custom_layer.cpp index 4531908ae9b..ca07172dbb1 100644 --- a/src/plugins/intel_gpu/src/plugin/custom_layer.cpp +++ b/src/plugins/intel_gpu/src/plugin/custom_layer.cpp @@ -14,6 +14,9 @@ #include #ifdef _WIN32 +# ifndef NOMINMAX +# define NOMINMAX +# endif # include #endif @@ -245,6 +248,8 @@ void CustomLayer::LoadFromFile(const std::string configFile, CustomLayerMap& cus #elif __linux__ char path[PATH_MAX]; char* abs_path_ptr = realpath(configFile.c_str(), path); +#else +#error "Intel GPU plugin: unknown target system" #endif if (abs_path_ptr == nullptr) { IE_THROW() << "Error loading custom layer configuration file: " << configFile << ", " diff --git a/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp b/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp index 4691a69bfb7..34b468b9c9c 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp @@ -64,9 +64,9 @@ static void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_pt }; if (p.use_new_shape_infer()) { - auto nonMaxSupressionLayerName = layer_type_name_ID(op); + auto nonMaxSuppressionLayerName = layer_type_name_ID(op); auto prim = cldnn::non_max_suppression( - nonMaxSupressionLayerName, + nonMaxSuppressionLayerName, reordered_inputs[0], reordered_inputs[1], 0, @@ -105,11 +105,11 @@ static void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_pt GPU_DEBUG_LOG << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; shared_memory.emplace_back(p.get_engine().allocate_memory(mutableLayoutSecond)); - cldnn::primitive_id non_max_supression_mutable_id_w_second = layer_type_name_ID(op) + "_md_write_second"; - auto nms_mutable_prim_second = cldnn::mutable_data(non_max_supression_mutable_id_w_second, + cldnn::primitive_id non_max_suppression_mutable_id_w_second = layer_type_name_ID(op) + "_md_write_second"; + auto nms_mutable_prim_second = cldnn::mutable_data(non_max_suppression_mutable_id_w_second, shared_memory.back()); p.add_primitive(*op, nms_mutable_prim_second); - inputs.push_back(cldnn::input_info(non_max_supression_mutable_id_w_second)); + inputs.push_back(cldnn::input_info(non_max_suppression_mutable_id_w_second)); } case 2: { auto mutable_precision_first = op->get_output_element_type(1); @@ -121,20 +121,20 @@ static void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_pt GPU_DEBUG_LOG << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; shared_memory.emplace_back(p.get_engine().allocate_memory(mutableLayoutFirst)); - cldnn::primitive_id non_max_supression_mutable_id_w_first = layer_type_name_ID(op) + "_md_write_first"; - auto nms_mutable_prim_first = cldnn::mutable_data(non_max_supression_mutable_id_w_first, + cldnn::primitive_id non_max_suppression_mutable_id_w_first = layer_type_name_ID(op) + "_md_write_first"; + auto nms_mutable_prim_first = cldnn::mutable_data(non_max_suppression_mutable_id_w_first, shared_memory.back()); p.add_primitive(*op, nms_mutable_prim_first); - inputs.push_back(cldnn::input_info(non_max_supression_mutable_id_w_first)); + inputs.push_back(cldnn::input_info(non_max_suppression_mutable_id_w_first)); } case 1: break; default: IE_THROW() << "Incorrect number of output for layer: " << op->get_friendly_name(); } - auto nonMaxSupressionLayerName = num_outputs > 1 ? layer_type_name_ID(op) + ".out0" : layer_type_name_ID(op); + auto nonMaxSuppressionLayerName = num_outputs > 1 ? layer_type_name_ID(op) + ".out0" : layer_type_name_ID(op); auto prim = cldnn::non_max_suppression( - nonMaxSupressionLayerName, + nonMaxSuppressionLayerName, reordered_inputs[0], reordered_inputs[1], static_cast(outputIndices), @@ -163,16 +163,16 @@ static void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_pt switch (num_outputs) { case 3: { - cldnn::primitive_id non_max_supression_id_r_second = layer_type_name_ID(op) + ".out2"; - auto nms_mutable_prim_r_second = cldnn::mutable_data(non_max_supression_id_r_second, - { cldnn::input_info(nonMaxSupressionLayerName) }, + cldnn::primitive_id non_max_suppression_id_r_second = layer_type_name_ID(op) + ".out2"; + auto nms_mutable_prim_r_second = cldnn::mutable_data(non_max_suppression_id_r_second, + { cldnn::input_info(nonMaxSuppressionLayerName) }, shared_memory.front()); p.add_primitive(*op, nms_mutable_prim_r_second); } case 2: { - cldnn::primitive_id non_max_supression_id_r_first = layer_type_name_ID(op) + ".out1"; - auto nms_mutable_prim_r_first = cldnn::mutable_data(non_max_supression_id_r_first, - { cldnn::input_info(nonMaxSupressionLayerName) }, + cldnn::primitive_id non_max_suppression_id_r_first = layer_type_name_ID(op) + ".out1"; + auto nms_mutable_prim_r_first = cldnn::mutable_data(non_max_suppression_id_r_first, + { cldnn::input_info(nonMaxSuppressionLayerName) }, shared_memory.back()); p.add_primitive(*op, nms_mutable_prim_r_first); } diff --git a/src/plugins/intel_gpu/src/plugin/program.cpp b/src/plugins/intel_gpu/src/plugin/program.cpp index 1d880f18065..ff667d8075f 100644 --- a/src/plugins/intel_gpu/src/plugin/program.cpp +++ b/src/plugins/intel_gpu/src/plugin/program.cpp @@ -148,6 +148,8 @@ Program::Program(InferenceEngine::CNNNetwork& network, cldnn::engine& engine, co Dl_info dl_info; dladdr(reinterpret_cast(CustomLayer::LoadFromFile), &dl_info); const char* mpath = dl_info.dli_fname; +#else +#error "Intel GPU plugin: unknown target system" #endif std::string configFile(mpath); std::size_t dir_split_pos = configFile.find_last_of("/\\"); diff --git a/src/plugins/intel_gpu/src/runtime/engine.cpp b/src/plugins/intel_gpu/src/runtime/engine.cpp index b294afa7d58..746f05e857a 100644 --- a/src/plugins/intel_gpu/src/runtime/engine.cpp +++ b/src/plugins/intel_gpu/src/runtime/engine.cpp @@ -18,8 +18,11 @@ #include #include -#if defined(_WIN32) && !defined(__GNUC__) -#include +#if defined(_WIN32) +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include static size_t get_cpu_ram_size() { MEMORYSTATUSEX s {}; @@ -28,15 +31,15 @@ static size_t get_cpu_ram_size() { return s.ullTotalPhys; } #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__QNXNTO__) -#include -#include +# include +# include static size_t get_cpu_ram_size() { -#ifdef __APPLE__ +# ifdef __APPLE__ int query_ram[] = {CTL_HW, HW_MEMSIZE}; -#else +# else int query_ram[] = {CTL_HW, HW_PHYSMEM}; -#endif +# endif int query_ram_len = sizeof(query_ram) / sizeof(*query_ram); size_t totalram = 0; size_t length = sizeof(totalram); @@ -45,7 +48,7 @@ static size_t get_cpu_ram_size() { return totalram; } #else -#include +# include static size_t get_cpu_ram_size() { struct sysinfo s {}; diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp index 964ae596fef..c96fcb8169e 100644 --- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp +++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp @@ -21,9 +21,14 @@ #include #ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif #include -#include +#include #include #include #else diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp index b08e55e0a17..72bc36b4a17 100644 --- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp +++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp @@ -19,7 +19,9 @@ #include #ifdef _WIN32 -# define NOMINMAX +# ifndef NOMINMAX +# define NOMINMAX +# endif # include typedef cl_d3d11_device_source_khr cl_device_source_intel; typedef cl_d3d11_device_set_khr cl_device_set_intel; diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_user_event.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_user_event.hpp index f2bc888d2cc..f2dcbd6ba17 100644 --- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_user_event.hpp +++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_user_event.hpp @@ -10,8 +10,8 @@ #include #include -DISABLE_WARNING_MSVC_BEGIN(4250) // Visual Studio warns us about inheritance via dominance but it's done intentionally - // so turn it off +OPENVINO_DISABLE_WARNING_MSVC_BEGIN(4250) // Visual Studio warns us about inheritance via dominance but it's done intentionally + // so turn it off namespace cldnn { namespace ocl { @@ -41,7 +41,7 @@ private: bool is_set_impl() override; }; -DISABLE_WARNING_MSVC_END(4250) +OPENVINO_DISABLE_WARNING_MSVC_END(4250) } // namespace ocl } // namespace cldnn diff --git a/src/plugins/intel_gpu/tests/test_cases/lstm_dynamic_gpu_test.cpp b/src/plugins/intel_gpu/tests/test_cases/lstm_dynamic_gpu_test.cpp index 5b7495ee5f1..8ee56d0aabb 100644 --- a/src/plugins/intel_gpu/tests/test_cases/lstm_dynamic_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/test_cases/lstm_dynamic_gpu_test.cpp @@ -17,7 +17,7 @@ #include #include -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning( disable : 4503 ) #endif diff --git a/src/plugins/intel_gpu/tests/test_cases/lstm_gpu_test.cpp b/src/plugins/intel_gpu/tests/test_cases/lstm_gpu_test.cpp index e96922a8213..1de09b2fb80 100644 --- a/src/plugins/intel_gpu/tests/test_cases/lstm_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/test_cases/lstm_gpu_test.cpp @@ -15,7 +15,7 @@ #include #include -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(disable: 4503) #endif diff --git a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt index f25d0f44cba..cec5ca58fcd 100644 --- a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt @@ -104,6 +104,9 @@ if(ENABLE_ONEDNN_FOR_GPU) "-DONEDNN_BUILD_GRAPH=OFF" "-DOpenCL_LIBRARY=${OpenCL_LIBRARY}" "-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIR}" + # specifically for Conan, because it overrides CMAKE_PREFIX_PATH and oneDNN's FindOpenCL.cmake is ignored + # Conan's FindOpenCL.cmake module does not set OpenCL_INCLUDE_DIRS, so we need to set it manually + "-DOpenCL_INCLUDE_DIRS=${OpenCL_INCLUDE_DIR}" ) add_library(onednn_gpu_tgt INTERFACE) set_target_properties(onednn_gpu_tgt PROPERTIES diff --git a/src/plugins/template/tests/functional/op_reference/softmax.cpp b/src/plugins/template/tests/functional/op_reference/softmax.cpp index 293df1a3cd5..3e002d50e45 100644 --- a/src/plugins/template/tests/functional/op_reference/softmax.cpp +++ b/src/plugins/template/tests/functional/op_reference/softmax.cpp @@ -10,7 +10,7 @@ using namespace reference_tests; using namespace ov; -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(disable : 4756) #endif diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 4eea97f94ef..d5731050a61 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -110,7 +110,7 @@ std::vector disabledTestPatterns() { // TODO: range input with one element should NOT be regarded as dynamic batch model in Program::IsDynBatchModel(). R"(.*smoke_select_CompareWithRefsNumpy_dynamic_range.*)", R"(.*CachingSupportCase.*LoadNetworkCacheTestBase.*CompareWithRefImpl.*)", -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) R"(.*KernelCachingSupportCase.*CanCreateCacheDirAndDumpBinariesUnicodePath.*)", #endif R"(.*CachingSupportCase.*GPU.*CompileModelCacheTestBase.*CompareWithRefImpl.*)", diff --git a/src/tests/functional/plugin/shared/include/behavior/plugin/caching_tests.hpp b/src/tests/functional/plugin/shared/include/behavior/plugin/caching_tests.hpp index 975b253178a..8ecf5ba9e32 100644 --- a/src/tests/functional/plugin/shared/include/behavior/plugin/caching_tests.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/plugin/caching_tests.hpp @@ -62,8 +62,8 @@ using compileKernelsCacheParams = std::tuple< std::pair, std::string> // device and cache configuration >; -DISABLE_WARNING_MSVC_BEGIN(4250) // Visual Studio warns us about inheritance via dominance but it's done intentionally - // so turn it off +OPENVINO_DISABLE_WARNING_MSVC_BEGIN(4250) // Visual Studio warns us about inheritance via dominance but it's done intentionally + // so turn it off class LoadNetworkCompiledKernelsCacheTest : virtual public LayerTestsUtils::LayerTestsCommon, virtual public BehaviorTestsUtils::IEPluginTestBase, public testing::WithParamInterface { @@ -101,6 +101,6 @@ protected: } }; -DISABLE_WARNING_MSVC_END(4250) +OPENVINO_DISABLE_WARNING_MSVC_END(4250) } // namespace LayerTestsDefinitions diff --git a/src/tests/ie_test_utils/common_test_utils/file_utils.cpp b/src/tests/ie_test_utils/common_test_utils/file_utils.cpp index fb4b2525d67..25a59feb59a 100644 --- a/src/tests/ie_test_utils/common_test_utils/file_utils.cpp +++ b/src/tests/ie_test_utils/common_test_utils/file_utils.cpp @@ -16,7 +16,7 @@ # ifndef NOMINMAX # define NOMINMAX # endif -# include +# include # include # include #else diff --git a/src/tests/ie_test_utils/common_test_utils/test_common.cpp b/src/tests/ie_test_utils/common_test_utils/test_common.cpp index 6aaebac03d6..6afc55520b9 100644 --- a/src/tests/ie_test_utils/common_test_utils/test_common.cpp +++ b/src/tests/ie_test_utils/common_test_utils/test_common.cpp @@ -20,7 +20,7 @@ #define _WINSOCKAPI_ #include -#include "Psapi.h" +#include "psapi.h" #endif namespace CommonTestUtils { diff --git a/src/tests/ie_test_utils/common_test_utils/test_constants.hpp b/src/tests/ie_test_utils/common_test_utils/test_constants.hpp index 35b76225e30..65f5cc0fe11 100644 --- a/src/tests/ie_test_utils/common_test_utils/test_constants.hpp +++ b/src/tests/ie_test_utils/common_test_utils/test_constants.hpp @@ -25,7 +25,7 @@ const char DEVICE_SUFFIX_SEPARATOR = '.'; const unsigned int maxFileNameLength = 140; #ifdef _WIN32 - #ifdef __MINGW32__ + #if defined(__MINGW32__) || defined(__MINGW64__) const char pre[] = "lib"; #else const char pre[] = ""; diff --git a/src/tests/ie_test_utils/common_test_utils/unicode_utils.hpp b/src/tests/ie_test_utils/common_test_utils/unicode_utils.hpp index 5094314de94..3ba071ca060 100644 --- a/src/tests/ie_test_utils/common_test_utils/unicode_utils.hpp +++ b/src/tests/ie_test_utils/common_test_utils/unicode_utils.hpp @@ -36,8 +36,8 @@ inline bool copyFile(std::wstring source_path, std::wstring dest_path) { #else fixSlashes(source_path); fixSlashes(dest_path); - std::ifstream source(source_path, std::ios::binary); - std::ofstream dest(dest_path, std::ios::binary); + std::ifstream source(source_path.c_str(), std::ios::binary); + std::ofstream dest(dest_path.c_str(), std::ios::binary); #endif bool result = source && dest; std::istreambuf_iterator begin_source(source); diff --git a/src/tests/ie_test_utils/common_test_utils/w_dirent.h b/src/tests/ie_test_utils/common_test_utils/w_dirent.h index 232f0a3d24f..c8d34bc7632 100644 --- a/src/tests/ie_test_utils/common_test_utils/w_dirent.h +++ b/src/tests/ie_test_utils/common_test_utils/w_dirent.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/tests/ie_test_utils/functional_test_utils/src/crash_handler.cpp b/src/tests/ie_test_utils/functional_test_utils/src/crash_handler.cpp index 748ff90adaa..18a5f2a0881 100644 --- a/src/tests/ie_test_utils/functional_test_utils/src/crash_handler.cpp +++ b/src/tests/ie_test_utils/functional_test_utils/src/crash_handler.cpp @@ -14,7 +14,11 @@ namespace CommonTestUtils { #if defined(__APPLE__) typedef sig_t sighandler; #elif defined(_WIN32) +#ifdef __GNUC__ + typedef __p_sig_fn_t sighandler; +#else typedef _crt_signal_t sighandler; +#endif #else typedef sighandler_t sighandler; #endif diff --git a/src/tests/util/test_common.cpp b/src/tests/util/test_common.cpp index 17ff8a78063..a63940704a7 100644 --- a/src/tests/util/test_common.cpp +++ b/src/tests/util/test_common.cpp @@ -16,7 +16,7 @@ # include -# include "Psapi.h" +# include "psapi.h" #endif namespace ov { diff --git a/tests/layer_tests/tensorflow_tests/test_tf_NonMaxSupression.py b/tests/layer_tests/tensorflow_tests/test_tf_NonMaxSupression.py index 9b9c196c153..35c8eacda3e 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_NonMaxSupression.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_NonMaxSupression.py @@ -8,7 +8,7 @@ import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest -class TestNonMaxSupression(CommonTFLayerTest): +class TestNonMaxSuppression(CommonTFLayerTest): # overload inputs generation to suit NMS use case def _prepare_input(self, inputs_dict): @@ -83,7 +83,7 @@ class TestNonMaxSupression(CommonTFLayerTest): @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.precommit_tf_fe - def test_NonMaxSupression(self, test_params, ie_device, precision, ir_version, temp_dir, + def test_NonMaxSuppression(self, test_params, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): if ie_device == 'GPU': pytest.skip("Skip TF NonMaxSuppresion test on GPU") @@ -96,7 +96,7 @@ class TestNonMaxSupression(CommonTFLayerTest): @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.precommit_tf_fe - def test_NonMaxSupressionWithScores(self, test_params, ie_device, precision, ir_version, temp_dir, + def test_NonMaxSuppressionWithScores(self, test_params, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): if ie_device == 'GPU': pytest.skip("Skip TF NonMaxSuppresionWithScores test on GPU") diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index edbcb824f4b..95d80a6fbd4 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -18,7 +18,20 @@ if(ENABLE_LTO) endif() if(ENABLE_PROFILING_ITT) - add_subdirectory(ittapi) + find_package(ittapi QUIET) + if(ittapi_FOUND) + # conan defines 'ittapi::ittapi' target + # create more common alias 'ittapi::ittnotify' + set_target_properties(ittapi::ittapi PROPERTIES + IMPORTED_GLOBAL ON + INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT) + add_library(ittapi::ittnotify ALIAS ittapi::ittapi) + + # set ittapi_FOUND to parent scope to properly generate OpenVINOConfig.cmake for static build + set(ittapi_FOUND ${ittapi_FOUND} PARENT_SCOPE) + else() + add_subdirectory(ittapi) + endif() add_subdirectory(itt_collector EXCLUDE_FROM_ALL) endif() @@ -26,9 +39,18 @@ if(ENABLE_SAMPLES OR ENABLE_TESTS) add_subdirectory(cnpy EXCLUDE_FROM_ALL) endif() -add_subdirectory(xbyak EXCLUDE_FROM_ALL) -openvino_developer_export_targets(COMPONENT openvino_common TARGETS xbyak) -ov_install_static_lib(xbyak ${OV_CPACK_COMP_CORE}) +if(X86_64 OR UNIVERSAL2) + find_package(xbyak QUIET) + if(xbyak_FOUND) + # conan creates alias xbyak::xbyak, we only need to make it GLOBAL + set_target_properties(xbyak::xbyak PROPERTIES IMPORTED_GLOBAL ON) + else() + add_subdirectory(xbyak EXCLUDE_FROM_ALL) + # export and install xbyak + openvino_developer_export_targets(COMPONENT openvino_common TARGETS xbyak::xbyak) + ov_install_static_lib(xbyak ${OV_CPACK_COMP_CORE}) + endif() +endif() # # OpenCL @@ -36,30 +58,41 @@ ov_install_static_lib(xbyak ${OV_CPACK_COMP_CORE}) if(ENABLE_INTEL_GPU) if(ENABLE_SYSTEM_OPENCL) - # try to find system OpenCL (installed via 'brew install opencl-icd-loader') + # try to find system OpenCL: + # - 'brew install opencl-icd-loader' + # - 'conan install opencl-icd-loader' find_package(OpenCLICDLoader QUIET) if(OpenCLICDLoader_FOUND) - # 'brew install opencl-headers' + # examples: + # - 'brew install opencl-headers' + # - 'conan install opencl-headers' find_package(OpenCLHeaders QUIET) if(NOT OpenCLHeaders_FOUND) message(WARNING "OpenCLHeaders not found, but OpenCLICDLoader is installed. Please, install OpenCL headers") else() set_target_properties(OpenCL::Headers PROPERTIES IMPORTED_GLOBAL ON) + set_property(TARGET OpenCL::OpenCL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenCL::Headers) endif() - # 'brew install opencl-clhpp-gheaders' + # examples: + # - 'brew install opencl-clhpp-headers' + # - 'conan install opencl-clhpp-headers' find_package(OpenCLHeadersCpp QUIET) if(NOT OpenCLHeadersCpp_FOUND) message(WARNING "OpenCLHeadersCpp not found, but OpenCLICDLoader is installed. Please, install OpenCL C++ headers") else() set_target_properties(OpenCL::HeadersCpp PROPERTIES IMPORTED_GLOBAL ON) get_target_property(opencl_cpp_include_dirs OpenCL::HeadersCpp INTERFACE_INCLUDE_DIRECTORIES) + set_property(TARGET OpenCL::OpenCL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenCL::HeadersCpp) endif() + + # set OpenCLICDLoader_FOUND to parent scope to generate proper OpenVINOConfig.cmake for static libraries case + set(OpenCLICDLoader_FOUND ON PARENT_SCOPE) else() # try to find system OpenCL: - # - 'sudo -E apt-get install opencl-headers ocl-icd-opencl-dev' - # - 'sudo -E yum install ocl-icd-devel opencl-headers' + # - 'apt-get install opencl-headers ocl-icd-opencl-dev' + # - 'yum install ocl-icd-devel opencl-headers' # - 'conda install khronos-opencl-icd-loader -c conda-forge' find_package(OpenCL QUIET) endif() @@ -105,6 +138,9 @@ if(ENABLE_INTEL_GPU) set(OpenCL_INCLUDE_DIR "${OpenCL_INCLUDE_DIR}" PARENT_SCOPE) set(OpenCL_LIBRARY "${OpenCL_LIBRARY}" PARENT_SCOPE) set(opencl_root_hints "${opencl_root_hints}" PARENT_SCOPE) + + # system OpenCL is not found: set it explictly for consistent OpenVINOConfig.cmake generation + set(ENABLE_SYSTEM_OPENCL OFF PARENT_SCOPE) endif() # cmake cannot set properties for imported targets @@ -136,17 +172,24 @@ endif() # if(ENABLE_SAMPLES OR ENABLE_TESTS) - if(PkgConfig_FOUND) + find_package(ZLIB QUIET NO_MODULE) + if(ZLIB_FOUND) + # need to make it global to use outside of the current sub-directory + set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_GLOBAL ON) + endif() + + # cmake has failed to find zlib, let's try pkg-config + if(NOT ZLIB_FOUND AND PkgConfig_FOUND) pkg_search_module(zlib QUIET IMPORTED_TARGET GLOBAL zlib) if(zlib_FOUND) - add_library(zlib::zlib ALIAS PkgConfig::zlib) + add_library(ZLIB::ZLIB ALIAS PkgConfig::zlib) message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}") endif() endif() - if(NOT zlib_FOUND) + if(NOT (zlib_FOUND OR ZLIB_FOUND)) add_subdirectory(zlib EXCLUDE_FROM_ALL) endif() endif() @@ -159,20 +202,22 @@ if(ENABLE_SYSTEM_PUGIXML) # try system pugixml first find_package(PugiXML QUIET) if(PugiXML_FOUND) + # TODO: use static pugixml library in case of BUILD_SHARED_LIBS=OFF if(TARGET pugixml::shared) # example: cross-compilation on debian set(pugixml_target pugixml::shared) elseif(TARGET pugixml::pugixml) # or create an alias for pugixml::pugixml shared library - # example: pugixml brew package + # - 'brew install pugixml' + # - 'conan install pugixml' set(pugixml_target pugixml::pugixml) elseif(TARGET pugixml) # or create an alias for pugixml shared library - # example: libpugixml-dev debian package + # - 'apt-get install libpugixml-dev' set(pugixml_target pugixml) elseif(TARGET pugixml::static) # sometimes pugixml::static target already exists, just need to make it global - # example: building using conda environment + # - 'conda install pugixml -c conda-forge' set(pugixml_target pugixml::static) else() message(FATAL_ERROR "Failed to detect pugixml library target name") @@ -182,7 +227,8 @@ if(ENABLE_SYSTEM_PUGIXML) elseif(PkgConfig_FOUND) # U18 case when cmake interface is not available pkg_search_module(pugixml QUIET - IMPORTED_TARGET GLOBAL + IMPORTED_TARGET + GLOBAL pugixml) if(pugixml_FOUND) set(pugixml_target PkgConfig::pugixml) @@ -237,26 +283,27 @@ if(ENABLE_SYSTEM_PUGIXML) # create an alias for real target which can be shared or static add_library(openvino::pugixml ALIAS ${pugixml_target}) else() - # reset to prevent improper code generation in OpenVINODeveloperPackage - set(ENABLE_SYSTEM_PUGIXML OFF CACHE BOOL "" FORCE) + # reset to prevent improper code generation in OpenVINODeveloperPackage.cmake, + # and OpenVINOConfig.cmake for static case + set(ENABLE_SYSTEM_PUGIXML OFF PARENT_SCOPE) endif() endif() if(NOT TARGET openvino::pugixml) # use OpenVINO pugixml copy if system one is not found - function(ie_build_pugixml) - function(ie_build_pugixml_static) + function(ov_build_pugixml) + function(ov_build_pugixml_static) set(BUILD_SHARED_LIBS OFF) add_subdirectory(pugixml EXCLUDE_FROM_ALL) endfunction() - ie_build_pugixml_static() + ov_build_pugixml_static() set_property(TARGET pugixml-static PROPERTY EXPORT_NAME pugixml) add_library(openvino::pugixml ALIAS pugixml-static) openvino_developer_export_targets(COMPONENT openvino_common TARGETS openvino::pugixml) ov_install_static_lib(pugixml-static ${OV_CPACK_COMP_CORE}) endfunction() - ie_build_pugixml() + ov_build_pugixml() endif() # @@ -267,7 +314,23 @@ if(ENABLE_GAPI_PREPROCESSING) add_library(ocv_hal INTERFACE) target_include_directories(ocv_hal INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/ocv") - add_subdirectory(ade EXCLUDE_FROM_ALL) + # ade + find_package(ade 0.1.2 QUIET) + if(ade_FOUND) + # conan creates 'ade' target + + # set ade_FOUND to parent scope to properly generate OpenVINOConfig.cmake for static build + set(ade_FOUND ${ade_FOUND} PARENT_SCOPE) + else() + add_subdirectory(ade EXCLUDE_FROM_ALL) + + set_target_properties(ade PROPERTIES FOLDER thirdparty) + openvino_developer_export_targets(COMPONENT openvino_common TARGETS ade) + + ov_install_static_lib(ade ${OV_CPACK_COMP_CORE}) + endif() + + # fluid add_subdirectory(fluid/modules/gapi EXCLUDE_FROM_ALL) if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11) @@ -277,10 +340,9 @@ if(ENABLE_GAPI_PREPROCESSING) target_compile_options(fluid PRIVATE "-Wno-unused-but-set-variable") endif() - set_target_properties(ade fluid PROPERTIES FOLDER thirdparty) - openvino_developer_export_targets(COMPONENT openvino_common TARGETS ade fluid) + set_target_properties(fluid PROPERTIES FOLDER thirdparty) + openvino_developer_export_targets(COMPONENT openvino_common TARGETS fluid) - ov_install_static_lib(ade ${OV_CPACK_COMP_CORE}) ov_install_static_lib(fluid ${OV_CPACK_COMP_CORE}) endif() @@ -297,6 +359,9 @@ if(ENABLE_SAMPLES OR ENABLE_COMPILE_TOOL OR ENABLE_TESTS) set(gflag_component nothreads_static) endif() find_package(gflags QUIET OPTIONAL_COMPONENTS ${gflag_component}) + else() + # conan case + find_package(gflags QUIET) endif() if(gflags_FOUND) @@ -352,17 +417,22 @@ endif() if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND) if(ENABLE_SYSTEM_PROTOBUF) + # Note: Debian / Ubuntu / RHEL libprotobuf.a can only be used with -DBUILD_SHARED_LIBS=OFF + # because they are compiled without -fPIC set(Protobuf_USE_STATIC_LIBS ON) if(CMAKE_VERBOSE_MAKEFILE) set(Protobuf_DEBUG ON) endif() find_package(Protobuf 3.20.3 REQUIRED) - set(Protobuf_LITE_LIBRARIES protobuf::libprotobuf-lite) - set(Protobuf_LIBRARIES protobuf::libprotobuf) set(PROTOC_EXECUTABLE protobuf::protoc) - foreach(target IN LISTS PROTOC_EXECUTABLE Protobuf_LIBRARIES Protobuf_LITE_LIBRARIES) - set_property(TARGET ${target} PROPERTY IMPORTED_GLOBAL ON) + # in case of system protobuf, we have to add version to OpenVINOConfig.cmake for static build + # to ensure no mismatch between versions of protoc and libprotobuf, we need to use exactly + # the same versions + set(Protobuf_VERSION ${Protobuf_VERSION} PARENT_SCOPE) + + foreach(target ${PROTOC_EXECUTABLE} protobuf::libprotobuf protobuf::libprotobuf-lite) + set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL ON) endforeach() else() add_subdirectory(protobuf EXCLUDE_FROM_ALL) @@ -371,34 +441,40 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND # forward variables used in the other places set(PROTOC_DEPENDENCY ${PROTOC_DEPENDENCY} PARENT_SCOPE) set(PROTOC_EXECUTABLE ${PROTOC_EXECUTABLE} PARENT_SCOPE) - set(Protobuf_LIBRARIES ${Protobuf_LIBRARIES} PARENT_SCOPE) - set(Protobuf_LITE_LIBRARIES ${Protobuf_LITE_LIBRARIES} PARENT_SCOPE) - set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE) set(Protobuf_IN_FRONTEND ON PARENT_SCOPE) # set public / interface compile options - foreach(target IN LISTS Protobuf_LITE_LIBRARIES Protobuf_LIBRARIES) + foreach(target_name protobuf::libprotobuf protobuf::libprotobuf-lite) set(link_type PUBLIC) if(ENABLE_SYSTEM_PROTOBUF) set(link_type INTERFACE) endif() if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) - target_compile_options(${target} ${link_type} -Wno-undef) + get_target_property(original_name ${target_name} ALIASED_TARGET) + if(TARGET ${original_name}) + # during build protobuf's cmake creates aliased targets + set(target_name ${original_name}) + endif() + target_compile_options(${target_name} ${link_type} -Wno-undef) endif() endforeach() endif() # -# Flat Buffers +# FlatBuffers # if(ENABLE_OV_TF_LITE_FRONTEND) if(ENABLE_SYSTEM_FLATBUFFERS) - if(CMAKE_HOST_LINUX AND EMSCRIPTEN AND HOST_X86_64) + if(CMAKE_HOST_LINUX AND EMSCRIPTEN) set(_old_flat_CMAKE_LIBRARY_ARCHITECTURE ${CMAKE_LIBRARY_ARCHITECTURE}) # without this WA cmake does not search in subfolder # see https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure - set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") + if(HOST_X86_64) + set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") + elseif(HOST_AARCH64) + set(CMAKE_LIBRARY_ARCHITECTURE "aarch64-linux-gnu") + endif() endif() find_host_package(Flatbuffers QUIET NO_CMAKE_FIND_ROOT_PATH) @@ -433,10 +509,24 @@ endif() if(ENABLE_SNAPPY_COMPRESSION) if(ENABLE_SYSTEM_SNAPPY) find_package(Snappy REQUIRED) - set_target_properties(Snappy::snappy PROPERTIES IMPORTED_GLOBAL ON) + + set(ov_snappy_lib Snappy::snappy) + if(NOT BUILD_SHARED_LIBS AND TARGET Snappy::snappy-static) + # we can use static library only in static build, because in case od dynamic build + # the libsnappy.a should be compiled with -fPIC, while Debian / Ubuntu / RHEL don't do it + set(ov_snappy_lib Snappy::snappy-static) + endif() + + set_target_properties(${ov_snappy_lib} PROPERTIES IMPORTED_GLOBAL ON) + add_library(openvino::snappy ALIAS ${ov_snappy_lib}) + + # set Snappy_VERSION to parent scope for consistent OpenVINOConfig.cmake generation + # in case of static build with system dependencies + set(Snappy_VERSION ${Snappy_VERSION} PARENT_SCOPE) + set(ov_snappy_lib ${ov_snappy_lib} PARENT_SCOPE) endif() - if(NOT TARGET Snappy::snappy) + if(NOT TARGET openvino::snappy) function(ov_build_snappy) set(BUILD_SHARED_LIBS OFF) set(SNAPPY_BUILD_BENCHMARKS OFF) @@ -462,10 +552,10 @@ if(ENABLE_SNAPPY_COMPRESSION) endif() add_subdirectory(snappy EXCLUDE_FROM_ALL) - # need to create alias Snappy::snappy - add_library(Snappy::snappy ALIAS snappy) + # need to create alias openvino::snappy + add_library(openvino::snappy ALIAS snappy) - # WA for emscriptem build which currently requires -fexceptions + # WA for emscripten build which currently requires -fexceptions if(EMSCRIPTEN) target_compile_options(snappy PRIVATE "-fexceptions") endif() @@ -481,7 +571,19 @@ endif() # if(ENABLE_OV_ONNX_FRONTEND) - add_subdirectory(onnx) + find_package(ONNX 1.13.1 EXACT QUIET COMPONENTS onnx onnx_proto NO_MODULE) + + if(ONNX_FOUND) + # conan creates imported targets 'onnx' and 'onnx_proto' + set_target_properties(onnx onnx_proto PROPERTIES IMPORTED_GLOBAL ON) + + # set ONNX_VERSION to parent scope for correct OpenVINOConfig.cmake generation + # in case of static libraries + set(ONNX_VERSION ${ONNX_VERSION} PARENT_SCOPE) + set(ENABLE_SYSTEM_ONNX ON PARENT_SCOPE) + else() + add_subdirectory(onnx) + endif() endif() # @@ -489,18 +591,26 @@ endif() # if(ENABLE_SAMPLES) - add_subdirectory(json) + # Note: VPUX requires 3.9.0 version, because it contains 'nlohmann::ordered_json' + find_package(nlohmann_json 3.9.0 QUIET) + if(nlohmann_json_FOUND) + # conan creates imported target nlohmann_json::nlohmann_json + # no needs to make the target global, because samples call find_package(nlohmann_json) as well + # but we need to set nlohmann_json_FOUND to parent scope to properly generate InferenceEngineDeveloperPackageConfig.cmake + set(nlohmann_json_FOUND ${nlohmann_json_FOUND} PARENT_SCOPE) + else() + add_subdirectory(json) - # this is required only because of VPUX plugin reused this - openvino_developer_export_targets(COMPONENT openvino_common - TARGETS nlohmann_json) + # 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) + # for nlohmann library versions older than v3.0.0 + 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() endif() @@ -508,14 +618,14 @@ endif() # Install # -if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW)$") +if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW|CONAN)$") # These libraries are dependencies for openvino-samples package if(ENABLE_SAMPLES OR ENABLE_COMPILE_TOOL OR ENABLE_TESTS) if(NOT gflags_FOUND) message(FATAL_ERROR "gflags must be used as a ${CPACK_GENERATOR} package. Install libgflags-dev / gflags-devel") endif() - if(NOT zlib_FOUND) + if(NOT (zlib_FOUND OR ZLIB_FOUND)) message(FATAL_ERROR "zlib must be used as a ${CPACK_GENERATOR} package. Install zlib1g-dev / zlib-devel") endif() endif() diff --git a/thirdparty/cnpy/CMakeLists.txt b/thirdparty/cnpy/CMakeLists.txt index 6c1293f3441..c10d23301d9 100644 --- a/thirdparty/cnpy/CMakeLists.txt +++ b/thirdparty/cnpy/CMakeLists.txt @@ -13,7 +13,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") PRIVATE -Wno-all) endif() -target_link_libraries(${TARGET_NAME} PUBLIC zlib::zlib) +target_link_libraries(${TARGET_NAME} PUBLIC ZLIB::ZLIB) target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER thirdparty) diff --git a/thirdparty/cnpy/cnpy.h b/thirdparty/cnpy/cnpy.h index 360f33d7e4d..7db302d1439 100644 --- a/thirdparty/cnpy/cnpy.h +++ b/thirdparty/cnpy/cnpy.h @@ -20,7 +20,9 @@ #include #if defined(_WIN32) +#ifndef NOMINMAX #define NOMINMAX +#endif #include #else #include diff --git a/thirdparty/fluid/modules/gapi/include/opencv2/gapi/infer/parsers.hpp b/thirdparty/fluid/modules/gapi/include/opencv2/gapi/infer/parsers.hpp index c7308dd39f4..e39d6fd4c6a 100644 --- a/thirdparty/fluid/modules/gapi/include/opencv2/gapi/infer/parsers.hpp +++ b/thirdparty/fluid/modules/gapi/include/opencv2/gapi/infer/parsers.hpp @@ -95,7 +95,7 @@ GAPI_EXPORTS_W GArray parseSSD(const GMat& in, /** @brief Parses output of Yolo network. Extracts detection information (box, confidence, label) from Yolo output, -filters it by given confidence and performs non-maximum supression for overlapping boxes. +filters it by given confidence and performs non-maximum suppression for overlapping boxes. @note Function textual ID is "org.opencv.nn.parsers.parseYolo" @@ -105,7 +105,7 @@ where num_classes - a number of classes Yolo network was trained with. @param inSz Size to project detected boxes to (size of the input image). @param confidenceThreshold If confidence of the detection is smaller than confidence threshold, detection is rejected. -@param nmsThreshold Non-maximum supression threshold which controls minimum +@param nmsThreshold Non-maximum suppression threshold which controls minimum relative box intersection area required for rejecting the box with a smaller confidence. If 1.f, nms is not performed and no boxes are rejected. @param anchors Anchors Yolo network was trained with. diff --git a/thirdparty/itt_collector/sea_itt_lib/CMakeLists.txt b/thirdparty/itt_collector/sea_itt_lib/CMakeLists.txt index 694f9341bd2..82919fb64b5 100644 --- a/thirdparty/itt_collector/sea_itt_lib/CMakeLists.txt +++ b/thirdparty/itt_collector/sea_itt_lib/CMakeLists.txt @@ -27,15 +27,18 @@ add_library(${TARGET_NAME} SHARED ${SOURCES}) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME IntelSEAPI) -target_link_libraries(${TARGET_NAME} PRIVATE ittnotify) +target_link_libraries(${TARGET_NAME} PRIVATE ittapi::ittnotify) if(UNIX) - target_link_libraries(${TARGET_NAME} PRIVATE dl) - target_compile_options(${TARGET_NAME} PRIVATE -Wno-undef -Wno-deprecated-declarations -Wno-multichar) + target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS}) elseif(WIN32) target_link_libraries(${TARGET_NAME} PRIVATE Dbghelp) endif() +if(CMAKE_COMPILER_IS_GNUCC OR OV_COMPILER_IS_CLANG) + target_compile_options(${TARGET_NAME} PRIVATE -Wno-undef -Wno-deprecated-declarations -Wno-multichar) +endif() + add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) install(TARGETS ${TARGET_NAME} diff --git a/thirdparty/ittapi/CMakeLists.txt b/thirdparty/ittapi/CMakeLists.txt index feb06a31c01..d30d6f0136c 100644 --- a/thirdparty/ittapi/CMakeLists.txt +++ b/thirdparty/ittapi/CMakeLists.txt @@ -10,7 +10,7 @@ if(DEFINED INTEL_VTUNE_DIR OR DEFINED ENV{INTEL_VTUNE_DIR}) message(WARNING "Profiling option enabled, but no ITT library was found under INTEL_VTUNE_DIR") endif() else() - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ittapi ${CMAKE_BINARY_DIR}/_deps/ittapi EXCLUDE_FROM_ALL) + add_subdirectory(ittapi EXCLUDE_FROM_ALL) target_compile_definitions(ittnotify INTERFACE ENABLE_PROFILING_ITT) if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) @@ -22,6 +22,9 @@ else() $ $) - openvino_developer_export_targets(COMPONENT openvino_common TARGETS ittnotify) - ov_install_static_lib(ittnotify ${OV_CPACK_COMP_CORE}) + # create alias ittapi::ittnotify + add_library(ittapi::ittnotify ALIAS ittnotify) + + openvino_developer_export_targets(COMPONENT openvino_common TARGETS ittapi::ittnotify) + ov_install_static_lib(ittapi::ittnotify ${OV_CPACK_COMP_CORE}) endif() diff --git a/thirdparty/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt index 6ba56c3bbba..1884c4b6464 100644 --- a/thirdparty/onnx/CMakeLists.txt +++ b/thirdparty/onnx/CMakeLists.txt @@ -21,9 +21,6 @@ endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # 4244 conversion from 'XXX' to 'YYY', possible loss of data ie_add_compiler_flags(/wd4244) - - # from onnx==1.13 it requires C++17 when compiling on Windows - set(CMAKE_CXX_STANDARD 17) endif() set(ONNX_USE_PROTOBUF_SHARED_LIBS OFF CACHE BOOL "Use dynamic protobuf by ONNX library" FORCE) @@ -44,8 +41,20 @@ endfunction() ov_onnx_build_static() -target_include_directories(onnx SYSTEM PRIVATE "${Protobuf_INCLUDE_DIRS}") -target_include_directories(onnx_proto SYSTEM PRIVATE "${Protobuf_INCLUDE_DIRS}") +foreach(_onnx_target onnx onnx_proto) + target_include_directories(${_onnx_target} SYSTEM PRIVATE + $) +endforeach() + +if(WIN32) + # from onnx==1.13.1 it requires C++17 when compiling on Windows + target_compile_features(onnx PRIVATE cxx_std_17) + set_target_properties(onnx PROPERTIES CXX_STANDARD 17) + # OPTIONAL is a reserved word for mingw at least + if(MINGW) + target_compile_definitions(onnx PRIVATE OPTIONAL=OPTIONAL_PLACEHOLDER) + endif() +endif() ov_disable_all_warnings(onnx onnx_proto) @@ -55,12 +64,14 @@ ov_install_static_lib(onnx ${OV_CPACK_COMP_CORE}) ov_install_static_lib(onnx_proto ${OV_CPACK_COMP_CORE}) # WA for ONNX: protobuf must be in the same export set of ONNX targets -if(NOT BUILD_SHARED_LIBS) +# in case of protobuf::libprotobuf-lite / protobuf::libprotobuf are imported targets +if(NOT ENABLE_SYSTEM_PROTOBUF) if(ONNX_USE_LITE_PROTO) - install(TARGETS ${Protobuf_LITE_LIBRARIES} EXPORT ONNXTargets - ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE}) + set(protobuf_target_name libprotobuf-lite) else() - install(TARGETS ${Protobuf_LIBRARIES} EXPORT ONNXTargets - ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE}) + set(protobuf_target_name libprotobuf) endif() + + install(TARGETS ${protobuf_target_name} EXPORT ONNXTargets + ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE}) endif() diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt index 79e69a47b09..2f1fd6e4876 100644 --- a/thirdparty/protobuf/CMakeLists.txt +++ b/thirdparty/protobuf/CMakeLists.txt @@ -96,10 +96,3 @@ else() set(PROTOC_EXECUTABLE $ PARENT_SCOPE) set(PROTOC_DEPENDENCY protoc PARENT_SCOPE) endif() - -# set to parent scope - -set(protobuf_VERSION ${protobuf_VERSION} PARENT_SCOPE) -set(Protobuf_LITE_LIBRARIES libprotobuf-lite PARENT_SCOPE) -set(Protobuf_LIBRARIES libprotobuf PARENT_SCOPE) -set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE) diff --git a/thirdparty/zlib/CMakeLists.txt b/thirdparty/zlib/CMakeLists.txt index b16cb47dad6..89fa92abef3 100644 --- a/thirdparty/zlib/CMakeLists.txt +++ b/thirdparty/zlib/CMakeLists.txt @@ -13,7 +13,7 @@ else() #266: function "XXX" declared implicitly set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -diag-disable=266") endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-non-prototype") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") @@ -55,8 +55,8 @@ set(zlib_ext_hdrs zlib/zconf.h) add_library(${TARGET_NAME} STATIC ${zlib_srcs} ${zlib_hdrs} ${lib_ext_hdrs}) -add_library(${TARGET_NAME}::${TARGET_NAME} ALIAS ${TARGET_NAME}) +add_library(ZLIB::ZLIB ALIAS ${TARGET_NAME}) target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/zlib") -set_target_properties(zlib PROPERTIES FOLDER thirdparty) +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER thirdparty) diff --git a/tools/compile_tool/CMakeLists.txt b/tools/compile_tool/CMakeLists.txt index bb66f387449..1cb39b77030 100644 --- a/tools/compile_tool/CMakeLists.txt +++ b/tools/compile_tool/CMakeLists.txt @@ -38,7 +38,7 @@ ov_cpack_add_component(${OV_CPACK_COMP_CORE_TOOLS} HIDDEN DEPENDS ${OV_CPACK_COMP_CORE}) -if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW)$") +if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW|CONAN)$") install(TARGETS compile_tool RUNTIME DESTINATION ${OV_CPACK_TOOLSDIR} COMPONENT ${OV_CPACK_COMP_CORE_TOOLS}) diff --git a/tools/legacy/benchmark_app/w_dirent.h b/tools/legacy/benchmark_app/w_dirent.h index 5352a8f8b13..88ef0bcd06a 100644 --- a/tools/legacy/benchmark_app/w_dirent.h +++ b/tools/legacy/benchmark_app/w_dirent.h @@ -36,7 +36,7 @@ #include #include #include - #include + #include #include // clang-format on diff --git a/tools/mo/openvino/tools/mo/utils/cli_parser.py b/tools/mo/openvino/tools/mo/utils/cli_parser.py index cca28014c3a..2efb7e0db2c 100644 --- a/tools/mo/openvino/tools/mo/utils/cli_parser.py +++ b/tools/mo/openvino/tools/mo/utils/cli_parser.py @@ -580,7 +580,7 @@ class IgnoredAction(argparse.Action): def canonicalize_and_check_paths(values: Union[str, List[str]], param_name, - try_mo_root=False, check_existance=True) -> List[str]: + try_mo_root=False, check_existence=True) -> List[str]: if values is not None: list_of_values = list() if isinstance(values, str): @@ -591,7 +591,7 @@ def canonicalize_and_check_paths(values: Union[str, List[str]], param_name, else: raise Error('Unsupported type of command line parameter "{}" value'.format(param_name)) - if not check_existance: + if not check_existence: return [get_absolute_path(path) for path in list_of_values] for idx, val in enumerate(list_of_values): @@ -619,7 +619,7 @@ class CanonicalizePathAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): list_of_paths = canonicalize_and_check_paths(values, param_name=option_string, - try_mo_root=False, check_existance=False) + try_mo_root=False, check_existence=False) setattr(namespace, self.dest, ','.join(list_of_paths)) @@ -631,7 +631,7 @@ class CanonicalizeTransformationPathCheckExistenceAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): list_of_paths = canonicalize_and_check_paths(values, param_name=option_string, - try_mo_root=True, check_existance=True) + try_mo_root=True, check_existence=True) setattr(namespace, self.dest, ','.join(list_of_paths)) @@ -643,7 +643,7 @@ class CanonicalizePathCheckExistenceAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): list_of_paths = canonicalize_and_check_paths(values, param_name=option_string, - try_mo_root=False, check_existance=True) + try_mo_root=False, check_existence=True) setattr(namespace, self.dest, ','.join(list_of_paths)) @@ -655,7 +655,7 @@ class CanonicalizeExtensionsPathCheckExistenceAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): list_of_paths = canonicalize_and_check_paths(values, param_name=option_string, - try_mo_root=False, check_existance=True) + try_mo_root=False, check_existence=True) # Extensions paths are needed to be stored as list setattr(namespace, self.dest, list_of_paths)