From: maier Date: Thu, 13 Sep 2012 15:28:51 +0000 (+0000) Subject: Add DEAL_II_MIN_VECTOR_CAPACITY tests X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c539aaf2425e172553319f1ca8b9b85f3351e201;p=dealii-svn.git Add DEAL_II_MIN_VECTOR_CAPACITY tests git-svn-id: https://svn.dealii.org/branches/branch_cmake@26356 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 88b672de6a..71393156fb 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -85,7 +85,7 @@ OPTION(DEAL_II_WITH_NETCDF OPTION(DEAL_II_WITH_THREADS "Build deal.II with support for threads. This pulls in libtbb as a dependency." - ON) + OFF) OPTION(DEAL_II_WITH_UMFPACK "Build deal.II with support for UMFPACK, BLAS and LAPACK." diff --git a/deal.II/contrib/cmake/check/check_for_compiler_features.cmake b/deal.II/contrib/cmake/check/check_for_compiler_features.cmake index 17d94906e1..b9ebc44641 100644 --- a/deal.II/contrib/cmake/check/check_for_compiler_features.cmake +++ b/deal.II/contrib/cmake/check/check_for_compiler_features.cmake @@ -386,3 +386,57 @@ CHECK_CXX_COMPILER_FLAG( IF(DEAL_II_COMPILER_HAS_AS_NEEDED) SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-as-needed") ENDIF() + + + +# +# Check for minimal vector capacity +# +GET_CXX_SOURCE_RETURN_VALUE( + " + #include + int main () { + std::vector v(1); + v.reserve (1); + v.resize (1); + return v.capacity(); + } + " + DEAL_II_MIN_VECTOR_CAPACITY + DEAL_II_MIN_VECTOR_CAPACITY_RETURN_VALUE) + +IF(NOT DEAL_II_MIN_VECTOR_CAPACITY) + # We have a problem... + MESSAGE(WARNING + "Could not determine DEAL_II_MIN_VECTOR_CAPACITY, source might not compile..." + ) +ELSE() + SET(DEAL_II_MIN_VECTOR_CAPACITY ${DEAL_II_MIN_VECTOR_CAPACITY_RETURN_VALUE}) +ENDIF() + + + +# +# Do same thing with std::vector +# +GET_CXX_SOURCE_RETURN_VALUE( + " + #include + int main () { + std::vector v(1); + v.reserve (1); + v.resize (1); + return v.capacity(); + } + " + DEAL_II_MIN_BOOL_VECTOR_CAPACITY + DEAL_II_MIN_BOOL_VECTOR_CAPACITY_RETURN_VALUE) + +IF(NOT DEAL_II_MIN_BOOL_VECTOR_CAPACITY) + # We have a problem... + MESSAGE(WARNING + "Could not determine DEAL_II_MIN_VECTOR_CAPACITY, source might not compile..." + ) +ELSE() + SET(DEAL_II_MIN_BOOL_VECTOR_CAPACITY ${DEAL_II_MIN_BOOL_VECTOR_CAPACITY_RETURN_VALUE}) +ENDIF() diff --git a/deal.II/contrib/cmake/macros/macro_get_cxx_source_return_value.cmake b/deal.II/contrib/cmake/macros/macro_get_cxx_source_return_value.cmake new file mode 100644 index 0000000000..1ebc0301ed --- /dev/null +++ b/deal.II/contrib/cmake/macros/macro_get_cxx_source_return_value.cmake @@ -0,0 +1,41 @@ +MACRO(GET_CXX_SOURCE_RETURN_VALUE SOURCE VAR EXIT_CODE) + + # + # TODO: This file is still very basic :-] + # + + FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" + "${SOURCE}\n") + + MESSAGE(STATUS "Performing Test ${VAR}") + + TRY_RUN( + ${VAR}_EXIT_CODE + ${VAR}_COMPILE_OK + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx) + + IF(${VAR}_COMPILE_OK) + SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}") + SET(${EXIT_CODE} ${VAR_EXIT_CODE} CACHE INTERNAL "Test ${EXIT_CODE}") + MESSAGE(STATUS "Performing Test ${VAR} - Success") + + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" + "${OUTPUT}\n" + "Return value: ${${VAR}}\n" + "Source file was:\n${SOURCE}\n") + + ELSE() + + SET(${VAR} 0 CACHE INTERNAL "Test ${VAR}") + MESSAGE(STATUS "Performing Test ${VAR} - Failed") + + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" + "${OUTPUT}\n" + "Return value: ${${VAR}_EXITCODE}\n" + "Source file was:\n${SOURCE}\n") + ENDIF() + +ENDMACRO() diff --git a/deal.II/include/deal.II/base/config.h.in b/deal.II/include/deal.II/base/config.h.in index e42f6a84b3..1a21466605 100644 --- a/deal.II/include/deal.II/base/config.h.in +++ b/deal.II/include/deal.II/base/config.h.in @@ -66,9 +66,6 @@ /* Defined if you have the `functionparser' library */ #cmakedefine HAVE_FUNCTIONPARSER - - - /* * Configured in configure_mpi.cmake: */ @@ -78,8 +75,6 @@ #cmakedefine DEAL_II_COMPILER_SUPPORTS_MPI - - /* * Configured in configure_netcdf.cmake: */ @@ -89,8 +84,6 @@ #cmakedefine HAVE_LIBNETCDF - - /* * Configured in configure_threads.cmake: */ @@ -123,8 +116,6 @@ #endif - - /* * Configured in configure_umfpack.cmake: */ @@ -140,8 +131,6 @@ #cmakedefine HAVE_LIBLAPACK - - /* * Configured in configure_umfpack.cmake: */ @@ -188,6 +177,14 @@ about the present function is available for this compiler. */ #cmakedefine __PRETTY_FUNCTION__ @__PRETTY_FUNCTION__@ +/* Set to the minimal number of elements a std::vector can always hold, + i.e. its minimal capacity. */ +#define DEAL_II_MIN_VECTOR_CAPACITY @DEAL_II_MIN_VECTOR_CAPACITY@ + +/* Set to the minimal number of elements a std::vector can always hold, + i.e. its minimal capacity. */ +#define DEAL_II_MIN_BOOL_VECTOR_CAPACITY @DEAL_II_MIN_BOOL_VECTOR_CAPACITY@ + diff --git a/deal.II/include/deal.II/base/config.h.in.old b/deal.II/include/deal.II/base/config.h.in.old index a0b43ac677..68c0515a05 100644 --- a/deal.II/include/deal.II/base/config.h.in.old +++ b/deal.II/include/deal.II/base/config.h.in.old @@ -101,14 +101,6 @@ the top-level directory. */ #cmakedefine DEAL_II_MEMBER_VAR_SPECIALIZATION_BUG -/* Set to the minimal number of elements a std::vector can always hold, - i.e. its minimal capacity. */ -#cmakedefine DEAL_II_MIN_BOOL_VECTOR_CAPACITY - -/* Set to the minimal number of elements a std::vector can always hold, - i.e. its minimal capacity. */ -#cmakedefine DEAL_II_MIN_VECTOR_CAPACITY - /* enable multigrid compatibility mode */ #cmakedefine DEAL_II_MULTIGRID_COMPATIBILITY