[go: nahoru, domu]

Skip to content

Commit

Permalink
detect language version correctly for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
romeric committed May 31, 2020
1 parent c08f992 commit 7592ea7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 15 deletions.
14 changes: 14 additions & 0 deletions Fastor/commons/commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ SOFTWARE.

// Determine CXX version
//------------------------------------------------------------------------------------------------//
#if defined(FASTOR_MSVC)
#if defined(_MSVC_LANG)
#if _MSVC_LANG == 199711L
#define FASTOR_CXX_VERSION 1998
#elif _MSVC_LANG == 201103L
#define FASTOR_CXX_VERSION 2011
#elif _MSVC_LANG == 201402L
#define FASTOR_CXX_VERSION 2014
#elif _MSVC_LANG == 201703L
#define FASTOR_CXX_VERSION 2017
#endif
#endif
#else
#if defined(__cplusplus)
#if __cplusplus == 199711L
#define FASTOR_CXX_VERSION 1998
Expand All @@ -105,6 +118,7 @@ SOFTWARE.
#define FASTOR_CXX_VERSION 2017
#endif
#endif
#endif
//------------------------------------------------------------------------------------------------//


Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ project(test_fastor)
set(FASTOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../)

set(CMAKE_CXX_STANDARD 14)
# set(CMAKE_VERBOSE_MAKEFILE ON)

enable_testing()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_einsum/test_einsum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void run() {
FASTOR_EXIT_ASSERT(abs(norm(II_ijkl) - norm(II_iljk)) < Tol);


Tensor<T,3,3> A, B; A.iota(65); B.iota(13.2);
Tensor<T,3> D = {124.36, -37.29, 5.61};
Tensor<T,3,3> A, B; A.iota(65); B.iota(T(13.2));
Tensor<T,3> D = {T(124.36), T(-37.29), T(5.61)};
auto bb_ijkl = einsum<Index<i,j>,Index<k,l>>(A,B);
FASTOR_EXIT_ASSERT(abs(norm(bb_ijkl) - 10808.437) < HugeTol);
auto bb_ikjl = permutation<Index<i,k,j,l>>(bb_ijkl);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fixed_views_1d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_executable(test_fixed_views_1d test_fixed_views_1d.cpp)
add_test(test_fixed_views_1d test_fixed_views_1d)

if(MSVC)
target_compile_options(test_fixed_views_1d PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_fixed_views_1d PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_fixed_views_1d PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand All @@ -21,7 +21,7 @@ add_executable(test_fixed_views_1d_vec test_fixed_views_1d.cpp)
add_test(test_fixed_views_1d_vec test_fixed_views_1d_vec)

if(MSVC)
target_compile_options(test_fixed_views_1d_vec PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_fixed_views_1d_vec PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_fixed_views_1d_vec PRIVATE "-DFASTOR_USE_VECTORISED_EXPR_ASSIGN" "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fixed_views_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_executable(test_fixed_views_2d test_fixed_views_2d.cpp)
add_test(test_fixed_views_2d test_fixed_views_2d)

if(MSVC)
target_compile_options(test_fixed_views_2d PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_fixed_views_2d PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_fixed_views_2d PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand All @@ -21,7 +21,7 @@ add_executable(test_fixed_views_2d_vec test_fixed_views_2d.cpp)
add_test(test_fixed_views_2d_vec test_fixed_views_2d_vec)

if(MSVC)
target_compile_options(test_fixed_views_2d_vec PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_fixed_views_2d_vec PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_fixed_views_2d_vec PRIVATE "-DFASTOR_USE_VECTORISED_EXPR_ASSIGN" "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fixed_views_nd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_executable(test_fixed_views_nd test_fixed_views_nd.cpp)
add_test(test_fixed_views_nd test_fixed_views_nd)

if(MSVC)
target_compile_options(test_fixed_views_nd PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_fixed_views_nd PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_fixed_views_nd PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand All @@ -20,7 +20,7 @@ add_executable(test_fixed_views_nd_2 test_fixed_views_nd_2.cpp)
add_test(test_fixed_views_nd_2 test_fixed_views_nd_2)

if(MSVC)
target_compile_options(test_fixed_views_nd_2 PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_fixed_views_nd_2 PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_fixed_views_nd_2 PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_views_1d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_executable(test_views_1d test_views_1d.cpp)
add_test(test_views_1d test_views_1d)

if(MSVC)
target_compile_options(test_views_1d PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_views_1d PRIVATE "/W1" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_views_1d PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand All @@ -21,7 +21,7 @@ add_executable(test_views_1d_vec test_views_1d.cpp)
add_test(test_views_1d_vec test_views_1d_vec)

if(MSVC)
target_compile_options(test_views_1d_vec PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_views_1d_vec PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_views_1d_vec PRIVATE "-DFASTOR_USE_VECTORISED_EXPR_ASSIGN" "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_views_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_executable(test_views_2d test_views_2d.cpp)
add_test(test_views_2d test_views_2d)

if(MSVC)
target_compile_options(test_views_2d PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_views_2d PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_views_2d PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand All @@ -21,7 +21,7 @@ add_executable(test_views_2d_vec test_views_2d.cpp)
add_test(test_views_2d_vec test_views_2d_vec)

if(MSVC)
target_compile_options(test_views_2d_vec PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_views_2d_vec PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_views_2d_vec PRIVATE "-DFASTOR_USE_VECTORISED_EXPR_ASSIGN" "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_views_nd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_executable(test_views_nd test_views_nd.cpp)
add_test(test_views_nd test_views_nd)

if(MSVC)
target_compile_options(test_views_nd PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_views_nd PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_views_nd PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand All @@ -20,7 +20,7 @@ add_executable(test_views_nd_2 test_views_nd_2.cpp)
add_test(test_views_nd_2 test_views_nd_2)

if(MSVC)
target_compile_options(test_views_nd_2 PRIVATE "/W4" "$<$<CONFIG:RELEASE>:/O2>")
target_compile_options(test_views_nd_2 PRIVATE "/W2" "$<$<CONFIG:RELEASE>:/O2>")
else()
target_compile_options(test_views_nd_2 PRIVATE "$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-march=native>")
endif()
Expand Down

0 comments on commit 7592ea7

Please sign in to comment.