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/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 27ef108c3b9..7292e79a1f7 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() @@ -279,7 +259,7 @@ function(ov_abi_free_target target) # To guarantee OpenVINO can be used with gcc versions 7 through 12.2 # - https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html # - https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW64) target_compile_options(${target} PRIVATE $<$:-Wabi=11>) endif() endfunction() @@ -332,11 +312,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 # @@ -349,16 +329,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 @@ -375,42 +353,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/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 de211bc19e1..7168fe96708 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) @@ -229,7 +228,7 @@ macro(ov_add_frontend) link_system_libraries(${TARGET_NAME} PRIVATE ${Protobuf_LIBRARIES}) endif() - # prptobuf generated code emits -Wsuggest-override error + # protobuf generated code emits -Wsuggest-override error if(SUGGEST_OVERRIDE_SUPPORTED) target_compile_options(${TARGET_NAME} PRIVATE -Wno-suggest-override) endif() 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/target_flags.cmake b/cmake/developer_package/target_flags.cmake index 0a37c910ae8..f45fdaed238 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.*") + 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) + 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 42f48b6f1bb..a90e2f7bf97 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 @@ -85,7 +85,7 @@ ie_option (ENABLE_INTEL_GNA_DEBUG "GNA debug build" 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) 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/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/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index d2a65618071..fcf9c864e6d 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() 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/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/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/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/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/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/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/src/onnx_model_validator.cpp b/src/frontends/onnx/onnx_common/src/onnx_model_validator.cpp index 7653518c9d2..616f586e852 100644 --- a/src/frontends/onnx/onnx_common/src/onnx_model_validator.cpp +++ b/src/frontends/onnx/onnx_common/src/onnx_model_validator.cpp @@ -6,6 +6,7 @@ #include #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/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/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 d35bc216b69..426c138c42b 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_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/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..c3d823c2ff7 100644 --- a/src/inference/src/dev/threading/parallel_custom_arena.cpp +++ b/src/inference/src/dev/threading/parallel_custom_arena.cpp @@ -161,7 +161,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/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/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/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index cb77dabe5f6..64abf83c77f 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 @@ -215,7 +215,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/FindACL.cmake b/src/plugins/intel_cpu/thirdparty/FindACL.cmake index 61772f39a96..219871e8940 100644 --- a/src/plugins/intel_cpu/thirdparty/FindACL.cmake +++ b/src/plugins/intel_cpu/thirdparty/FindACL.cmake @@ -74,7 +74,11 @@ else() message(STATUS "Configure to build ${ARM_COMPUTE_SOURCE_DIR}") - find_host_program(SCONS scons) + 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!") @@ -194,7 +198,9 @@ else() set(extra_link_flags "${extra_link_flags} ${extra_flags}") set(extra_cxx_flags "${extra_cxx_flags} ${extra_flags}") - elseif(CMAKE_CROSSCOMPILING AND LINUX) + 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) @@ -258,7 +264,7 @@ else() endif() if(ENABLE_LTO) - if((CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) AND (NOT CMAKE_CROSSCOMPILING)) + 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() @@ -300,6 +306,10 @@ else() ${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}) @@ -307,18 +317,15 @@ else() 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_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) - - # 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) + INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}/include + OSX_ARCHITECTURES arm64) # Helpers for oneDNN intergation 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 0f8de0bf819..552f66fd1d5 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/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/runtime/debug_configuration.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp index 0715b24d093..293704813ae 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp @@ -42,7 +42,7 @@ enum class LogLevel : int8_t { } // namespace ov #ifdef GPU_DEBUG_CONFIG -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) #define SEPARATE '\\' #else #define SEPARATE '/' 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/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..7c0899d6c59 100644 --- a/src/plugins/intel_gpu/src/plugin/custom_layer.cpp +++ b/src/plugins/intel_gpu/src/plugin/custom_layer.cpp @@ -245,6 +245,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/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..1922dc6ff95 100644 --- a/src/plugins/intel_gpu/src/runtime/engine.cpp +++ b/src/plugins/intel_gpu/src/runtime/engine.cpp @@ -18,7 +18,7 @@ #include #include -#if defined(_WIN32) && !defined(__GNUC__) +#if defined(_WIN32) #include static size_t get_cpu_ram_size() { 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..de475803447 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,11 @@ #include #ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#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/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 7430e1bb14e..e71a64444aa 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_gpu/tests/functional/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/plugins/intel_gpu/tests/unit/test_cases/lstm_dynamic_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/lstm_dynamic_gpu_test.cpp index 5b7495ee5f1..8ee56d0aabb 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/lstm_dynamic_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/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/unit/test_cases/lstm_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/lstm_gpu_test.cpp index e96922a8213..1de09b2fb80 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/lstm_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/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/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/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/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/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt index 6ba56c3bbba..c276a78a74d 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) @@ -47,6 +44,16 @@ ov_onnx_build_static() target_include_directories(onnx SYSTEM PRIVATE "${Protobuf_INCLUDE_DIRS}") target_include_directories(onnx_proto SYSTEM PRIVATE "${Protobuf_INCLUDE_DIRS}") +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) # install diff --git a/thirdparty/zlib/CMakeLists.txt b/thirdparty/zlib/CMakeLists.txt index b16cb47dad6..fb4b1dadc73 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") 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