@@ -21,11 +21,6 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "IntelLLVM")
2121 endif ()
2222endif ()
2323
24- # Needed for Java
25- if (NOT CMAKE_CXX_STANDARD)
26- set (CMAKE_C_STANDARD 99)
27- endif ()
28-
2924include (CheckCXXCompilerFlag)
3025include (CheckLanguage)
3126include (CMakeDependentOption)
@@ -34,10 +29,6 @@ include(CheckFunctionExists)
3429include (CheckSymbolExists)
3530include (GNUInstallDirs) # onnxruntime_providers_* require CMAKE_INSTALL_* variables
3631
37- if (NOT CMAKE_CXX_STANDARD)
38- set (CMAKE_CXX_STANDARD 20)
39- endif ()
40-
4132if (MSVC )
4233 # Make sure Visual Studio sets __cplusplus macro correctly: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
4334 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus" )
@@ -249,6 +240,24 @@ option(onnxruntime_USE_OPENVINO_INTERFACE "Build ONNXRuntime shared lib which is
249240option (onnxruntime_USE_VITISAI_INTERFACE "Build ONNXRuntime shared lib which is compatible with Vitis-AI EP interface" OFF )
250241option (onnxruntime_USE_QNN_INTERFACE "Build ONNXRuntime shared lib which is compatible with QNN EP interface" OFF )
251242
243+ # Set C/C++ standard versions
244+ if (NOT CMAKE_C_STANDARD)
245+ # Needed for Java
246+ set (CMAKE_C_STANDARD 99)
247+ endif ()
248+
249+ if (NOT CMAKE_CXX_STANDARD)
250+ # TODO move all builds to C++20
251+ if (MSVC AND onnxruntime_USE_CUDA)
252+ # There's a compilation error from CUTLASS header "cute/tensor.hpp" when attempting to use C++20:
253+ # cutlass-src\include\cute\stride.hpp(299,46): error C3545: 'Ints': parameter pack expects a non-type template
254+ # argument
255+ set (CMAKE_CXX_STANDARD 17)
256+ else ()
257+ set (CMAKE_CXX_STANDARD 20)
258+ endif ()
259+ endif ()
260+
252261if ("${CMAKE_C_COMPILER_ID} " STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 11.1)
253262 message (FATAL_ERROR "GCC version must be greater than or equal to 11.1" )
254263endif ()
0 commit comments