From 4f4c697897b63f7e7717c2dfe6e39a459915208f Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Tue, 30 Jul 2013 22:35:31 +0200 Subject: [PATCH] separate some tests in c++11 dir for old compilers. new policy : for non standard conforming compilers, we can skip the tests using new features using recent c++ features. I.e. compilers below gcc 4.8.1, clang 3.3. --- CMakeLists.txt | 1 + cmake/TRIQSConfig.cmake.in | 1 + test/triqs/CMakeLists.txt | 15 +++++++++++++++ test/triqs/gf/{ => c++11}/gf_re_im_freq_time.cpp | 0 triqs/gfs/curry.hpp | 8 ++++++-- 5 files changed, 23 insertions(+), 2 deletions(-) rename test/triqs/gf/{ => c++11}/gf_re_im_freq_time.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6f80e4a..f4c4e7eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,6 +414,7 @@ endif (PythonSupport) ## Remove the test from the build ? option(Build_Triqs_General_Tools_Test "Build the test of the general tool ? ( array class , ... ) " ON) if (Build_Triqs_General_Tools_Test) + message( STATUS "-------- Preparing tests -------------") add_subdirectory(${TRIQS_SOURCE_DIR}/test ) endif() diff --git a/cmake/TRIQSConfig.cmake.in b/cmake/TRIQSConfig.cmake.in index e2fc01dc..1b122cb9 100644 --- a/cmake/TRIQSConfig.cmake.in +++ b/cmake/TRIQSConfig.cmake.in @@ -32,6 +32,7 @@ set(TRIQS_LIBRARY_GSL @GSL_LIBRARIES@) set(TRIQS_WITH_PYTHON_SUPPORT @TRIQS_WITH_PYTHON_SUPPORT@) set(TRIQS_HDF5_DIFF_EXECUTABLE @TRIQS_HDF5_DIFF_EXECUTABLE@) set(TRIQS_PYTHON_LIB_DEST @TRIQS_PYTHON_LIB_DEST@) +set(TRIQS_COMPILER_IS_C11_COMPLIANT @TRIQS_COMPILER_IS_C11_COMPLIANT@) # for people who want to quickly add everything TRIQS has detected... set(TRIQS_LIBRARY_ALL ${TRIQS_LIBRARY} ${TRIQS_LIBRARY_BOOST} ${TRIQS_LIBRARY_PYTHON} ${TRIQS_LIBRARY_MPI} ${TRIQS_LIBRARY_HDF5} ${TRIQS_LIBRARY_LAPACK} ${TRIQS_LIBRARY_FFTW} ${TRIQS_LIBRARY_GMP} ${TRIQS_LIBRARY_GSL} ) diff --git a/test/triqs/CMakeLists.txt b/test/triqs/CMakeLists.txt index 642a7af5..78cf0f99 100644 --- a/test/triqs/CMakeLists.txt +++ b/test/triqs/CMakeLists.txt @@ -15,6 +15,21 @@ macro(all_tests ) endif() ENDFOREACH( TestName1 ${TestList} ) + FILE(GLOB TestList RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c++11/*.cpp) + FOREACH( TestName1 ${TestList} ) + STRING(REPLACE ".cpp" "" TestName2 ${TestName1}) + STRING(REPLACE "c++11/" "" TestName ${TestName2}) + if(TRIQS_COMPILER_IS_C11_COMPLIANT) + add_executable( ${TestName} ${CMAKE_CURRENT_SOURCE_DIR}/c++11/${TestName}.cpp ) + add_test_C_simple( ${TestName}) + if (TESTS_C_WITH_VALGRIND) + add_test ( ${TestName}_valgrind valgrind --error-exitcode=1 ${CMAKE_CURRENT_BINARY_DIR}/c++11/${TestName}) + endif() + else() + MESSAGE(STATUS "WARNING: Deactivating the test ${TestName} : this obsolete compiler does not implement the C++ standard") + endif() + ENDFOREACH( TestName1 ${TestList} ) + endmacro() add_all_subdirectories_with_cmakelist() diff --git a/test/triqs/gf/gf_re_im_freq_time.cpp b/test/triqs/gf/c++11/gf_re_im_freq_time.cpp similarity index 100% rename from test/triqs/gf/gf_re_im_freq_time.cpp rename to test/triqs/gf/c++11/gf_re_im_freq_time.cpp diff --git a/triqs/gfs/curry.hpp b/triqs/gfs/curry.hpp index 05dcf36c..15864121 100644 --- a/triqs/gfs/curry.hpp +++ b/triqs/gfs/curry.hpp @@ -22,6 +22,10 @@ #define TRIQS_GF_CURRY_H #include "./product.hpp" +#ifndef TRIQS_COMPILER_IS_C11_COMPLIANT +#error "This header requires a fully C++11 compliant compiler" +#endif + namespace triqs { namespace gfs { template struct lambda_valued {}; @@ -54,7 +58,7 @@ namespace triqs { namespace gfs { // - m : returns from a CP object the corresponding tuple of meshes of the remaining meshes // after partial eval (of the type computed by "type"). // - auxiliary data : - // pos : position in the CP tuple ( CP::size-1 ->0) + // pos : position in the CP tuple (CP::size-1 ->0) // ip : position in the tuple of indices (for sl) // MP : accumulation of the final type metacomputed. // @@ -77,7 +81,7 @@ namespace triqs { namespace gfs { }; template struct pv_impl { - typedef typename cartesian_product_add_front::type, MP>::type MP2; + typedef typename cartesian_product_add_front::type, MP>::type MP2; typedef pv_impl B; typedef typename B::type type; template static auto sl (T t, IT const & it) DECL_AND_RETURN( B::sl(triqs::tuple::push_front(t,std::get(it)),it));