Skip to content

Commit

Permalink
Migration to C++17 as default standart (openvinotoolkit#28273)
Browse files Browse the repository at this point in the history
### Details:
- This PR bumps minimum required cxx standart version to C++17, which
provides an ability to use advanced features from a more modern
standart.
- OpenVINO minimum supported compiler version is gcc 8.5 (for RHEL 8.4).
Based on
https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
gcc 8 has full c++17 support (with insignificant exceptions), so nothing
prevents the upgrade.
- MSVC supports c++17 starting with VS 2017 with some fixes in VS 2019
https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170.

### Dependencies:

- Disable LTO build on Ubuntu 20:
intel-innersource/frameworks.ai.openvino.ci.product-configs#3979

### Tickets:
 - [CVS-157537](https://jira.devtools.intel.com/browse/CVS-157537)

---------

Co-authored-by: Alina Kladieva <[email protected]>
  • Loading branch information
dmitry-gorokhov and akladiev authored Jan 7, 2025
1 parent e56624a commit 7318165
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 21 deletions.
8 changes: 1 addition & 7 deletions cmake/developer_package/compile_flags/os_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,7 @@ endif()

# to allows to override CMAKE_CXX_STANDARD from command line
if(NOT DEFINED CMAKE_CXX_STANDARD)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_STANDARD 14)
elseif(OV_COMPILER_IS_INTEL_LLVM)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD 17)
endif()

if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ endif()
set(TARGET_NAME "ov_integration_snippet")
# [cmake:integration_example_cpp]
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

find_package(OpenVINO REQUIRED)

Expand All @@ -120,7 +120,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime)
set(TARGET_NAME_PY "ov_integration_snippet_py")
# [cmake:integration_example_cpp_py]
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

if(NOT CMAKE_CROSSCOMPILING)
find_package(Python3 QUIET COMPONENTS Interpreter)
Expand All @@ -143,7 +143,7 @@ target_link_libraries(${TARGET_NAME_PY} PRIVATE openvino::runtime)
set(TARGET_NAME_C "ov_integration_snippet_c")
# [cmake:integration_example_c]
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

find_package(OpenVINO REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ endif()
####################################
## to use C++11; can overwritten via cmake command line
if(NOT DEFINED CMAKE_CXX_STANDARD)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/openvino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add_library(${TARGET_NAME}
add_library(openvino::runtime ALIAS ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME runtime)

target_compile_features(${TARGET_NAME} PUBLIC cxx_std_11)
target_compile_features(${TARGET_NAME} PUBLIC cxx_std_17)

ov_add_vs_version_file(NAME ${TARGET_NAME} FILEDESCRIPTION "OpenVINO runtime library")

Expand Down
2 changes: 1 addition & 1 deletion src/core/template_extension/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# [cmake:extension]
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(TARGET_NAME "openvino_template_extension")

Expand Down
4 changes: 0 additions & 4 deletions src/plugins/intel_cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ if(DNNL_USE_ACL)
set(OV_CPU_WITH_ACL ON)
endif()

if(OV_CPU_WITH_ACL)
set(CMAKE_CXX_STANDARD 14)
endif()

if (ENABLE_SHL_FOR_CPU)
add_definitions(-DOV_CPU_WITH_SHL)
set(OV_CPU_WITH_SHL ON)
Expand Down
2 changes: 1 addition & 1 deletion tests/memory_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required(VERSION 3.13)

set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
2 changes: 1 addition & 1 deletion tests/stress_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required(VERSION 3.13)

set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
2 changes: 1 addition & 1 deletion tests/time_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required(VERSION 3.13)

set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
1 change: 0 additions & 1 deletion thirdparty/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ if(ENABLE_SNAPPY_COMPRESSION)
set(SNAPPY_BUILD_BENCHMARKS OFF)
set(SNAPPY_BUILD_TESTS OFF)
set(INSTALL_GTEST OFF)
set(CMAKE_CXX_STANDARD 14)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# '<': signed/unsigned mismatch
ov_add_compiler_flags(/wd4018)
Expand Down

0 comments on commit 7318165

Please sign in to comment.