Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ target_include_directories(xtensor INTERFACE
$<BUILD_INTERFACE:${XTENSOR_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)

target_compile_features(xtensor INTERFACE cxx_std_17)
target_compile_features(xtensor INTERFACE cxx_std_20)

target_link_libraries(xtensor INTERFACE xtl)

Expand All @@ -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)

Expand Down
20 changes: 10 additions & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion test/test_xbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,13 @@ namespace xt

xt::dynamic_shape<std::size_t> sd = {3, 2, 1};
auto ed1 = empty<double>(sd);
auto ed2 = empty<double, layout_type::column_major>(dynamic_shape<std::size_t>({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<std::size_t>;
auto ed2 = empty<double, xt::layout_type::column_major, ShapeType>(ShapeType({3, 3, 3}));
#else
auto ed2 = empty<double, xt::layout_type::column_major>(xt::dynamic_shape<std::size_t>({3, 3, 3}));
#endif
auto ed3 = empty<double>(std::vector<std::size_t>({3, 3, 3}));
b = std::is_same<decltype(ed1), xarray<double>>::value;
EXPECT_TRUE(b);
Expand Down