Skip to content

Commit 76c5186

Browse files
authored
Enable C++17 for cmake modules (#13869)
Moved the lines which add c++17 to CXX_FLAGS before the include of modules. After this c++17 features should be also supported in source code of the modules.
1 parent e6262bf commit 76c5186

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

CMakeLists.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,17 @@ endif(USE_KALLOC_ALIGNMENT)
478478
# need to be re-compiled every time. Using ccache 4.0+ can resolve this issue.
479479
include(cmake/utils/CCache.cmake)
480480

481+
include(CheckCXXCompilerFlag)
482+
if(NOT MSVC)
483+
check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17)
484+
set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
485+
set(CMAKE_CUDA_STANDARD 17)
486+
else()
487+
check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17)
488+
set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}")
489+
set(CMAKE_CUDA_STANDARD 17)
490+
endif()
491+
481492
# Module rules
482493
include(cmake/modules/VTA.cmake)
483494
include(cmake/modules/StandaloneCrt.cmake)
@@ -525,17 +536,6 @@ include(cmake/modules/Git.cmake)
525536
include(cmake/modules/LibInfo.cmake)
526537
include(cmake/modules/RustExt.cmake)
527538

528-
include(CheckCXXCompilerFlag)
529-
if(NOT MSVC)
530-
check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17)
531-
set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
532-
set(CMAKE_CUDA_STANDARD 17)
533-
else()
534-
check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17)
535-
set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}")
536-
set(CMAKE_CUDA_STANDARD 17)
537-
endif()
538-
539539
set(LIBINFO_FILE ${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc)
540540
add_lib_info(${LIBINFO_FILE})
541541
list(REMOVE_ITEM COMPILER_SRCS ${LIBINFO_FILE})

0 commit comments

Comments
 (0)