From 0e6c0660ccb32799ba428c477335e640b453c551 Mon Sep 17 00:00:00 2001 From: Egor Churaev Date: Mon, 30 Jan 2023 14:31:16 +0300 Subject: [PATCH] Enable C++17 for cmake modules 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. --- CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 032e0bc2af00..a82c64097481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -478,6 +478,17 @@ endif(USE_KALLOC_ALIGNMENT) # need to be re-compiled every time. Using ccache 4.0+ can resolve this issue. include(cmake/utils/CCache.cmake) +include(CheckCXXCompilerFlag) +if(NOT MSVC) + check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17) + set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CUDA_STANDARD 17) +else() + check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17) + set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CUDA_STANDARD 17) +endif() + # Module rules include(cmake/modules/VTA.cmake) include(cmake/modules/StandaloneCrt.cmake) @@ -525,17 +536,6 @@ include(cmake/modules/Git.cmake) include(cmake/modules/LibInfo.cmake) include(cmake/modules/RustExt.cmake) -include(CheckCXXCompilerFlag) -if(NOT MSVC) - check_cxx_compiler_flag("-std=c++17" SUPPORT_CXX17) - set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}") - set(CMAKE_CUDA_STANDARD 17) -else() - check_cxx_compiler_flag("/std:c++17" SUPPORT_CXX17) - set(CMAKE_CXX_FLAGS "/std:c++17 ${CMAKE_CXX_FLAGS}") - set(CMAKE_CUDA_STANDARD 17) -endif() - set(LIBINFO_FILE ${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc) add_lib_info(${LIBINFO_FILE}) list(REMOVE_ITEM COMPILER_SRCS ${LIBINFO_FILE})