diff --git a/CMakeLists.txt b/CMakeLists.txt index c7ec920c9..f2a9fdf12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,7 +194,7 @@ target_include_directories(xtensor INTERFACE $ $) -target_compile_features(xtensor INTERFACE cxx_std_17) +target_compile_features(xtensor INTERFACE cxx_std_20) target_link_libraries(xtensor INTERFACE xtl) @@ -205,7 +205,7 @@ OPTION(BUILD_TESTS "xtensor test suite" OFF) OPTION(BUILD_BENCHMARK "xtensor benchmark" OFF) OPTION(DOWNLOAD_GBENCHMARK "download google benchmark and build from source" ON) OPTION(DEFAULT_COLUMN_MAJOR "set default layout to column major" OFF) -OPTION(CPP20 "enables C++20 (experimental)" OFF) +OPTION(CPP23 "enables C++23 (experimental)" OFF) OPTION(XTENSOR_DISABLE_EXCEPTIONS "Disable C++ exceptions" OFF) OPTION(DISABLE_MSVC_ITERATOR_CHECK "Disable the MVSC iterator check" ON) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cc2f9281a..884de312b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -34,27 +34,27 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) include(set_compiler_flag.cmake) -if(CPP20) - # User requested C++17, but compiler might not oblige. +if(CPP23) + # User requested C++23, but compiler might not oblige. set_compiler_flag( _cxx_std_flag CXX - "-std=c++2a" # this should work with GNU, Intel, PGI - "/std:c++20" # this should work with MSVC + "-std=c++23" # this should work with GNU, Intel, PGI + "/std:c++23" # this should work with MSVC ) if(_cxx_std_flag) - message(STATUS "Building with C++20") + message(STATUS "Building with C++23") endif() else() set_compiler_flag( _cxx_std_flag CXX REQUIRED - "-std=c++17" # this should work with GNU, Intel, PGI - "/std:c++17" # this should work with MSVC + "-std=c++20" # this should work with GNU, Intel, PGI + "/std:c++20" # this should work with MSVC ) - message(STATUS "Building with C++17") + message(STATUS "Building with C++20") endif() if(NOT _cxx_std_flag) - message(FATAL_ERROR "xtensor needs a C++17-compliant compiler.") + message(FATAL_ERROR "xtensor needs a C++20-compliant compiler.") endif() OPTION(XTENSOR_ENABLE_WERROR "Turn on -Werror" OFF) @@ -74,7 +74,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Intel" set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -DSKIP_ON_WERROR") endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /MP /bigobj") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /Zc:__cplusplus /MP /bigobj") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) diff --git a/test/test_xbuilder.cpp b/test/test_xbuilder.cpp index fd69922d0..73d952b6f 100644 --- a/test/test_xbuilder.cpp +++ b/test/test_xbuilder.cpp @@ -676,7 +676,13 @@ namespace xt xt::dynamic_shape sd = {3, 2, 1}; auto ed1 = empty(sd); - auto ed2 = empty(dynamic_shape({3, 3, 3})); +// TODO : The ed2 expression do not work on MSVC due to bad deduction since cpp20. We need to fix it for MSVC. +#if defined(_MSVC_LANG) + using ShapeType = xt::dynamic_shape; + auto ed2 = empty(ShapeType({3, 3, 3})); +#else + auto ed2 = empty(xt::dynamic_shape({3, 3, 3})); +#endif auto ed3 = empty(std::vector({3, 3, 3})); b = std::is_same>::value; EXPECT_TRUE(b);