From: maier Date: Wed, 12 Sep 2012 11:24:59 +0000 (+0000) Subject: Add DEAL_II_HAVE_SANE_MT_DEFINITIONS X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5b6c562f4a3bc4e6dffee5723926230ad0c10f4;p=dealii-svn.git Add DEAL_II_HAVE_SANE_MT_DEFINITIONS git-svn-id: https://svn.dealii.org/branches/branch_cmake@26305 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/compiler-mumbo-jumbo.m4 b/deal.II/compiler-mumbo-jumbo.m4 index 837262b2a9..672322683c 100644 --- a/deal.II/compiler-mumbo-jumbo.m4 +++ b/deal.II/compiler-mumbo-jumbo.m4 @@ -2605,43 +2605,3 @@ template AC_MSG_RESULT(no) ]) ]) - - - - -dnl ------------------------------------------------------------- -dnl Check whether CXXFLAGSG and CXXFLAGSO are a valid combination -dnl of flags or if there are contradicting flags in them. -dnl -dnl Usage: DEAL_II_CHECK_CXXFLAGS_CONSISTENCY -dnl -dnl ------------------------------------------------------------- -AC_DEFUN(DEAL_II_CHECK_CXXFLAGS_CONSISTENCY, dnl -[ - AC_MSG_CHECKING(for consistency of CXXFLAGSG flags) - AC_LANG(C++) - CXXFLAGS="$CXXFLAGSG" - AC_TRY_COMPILE( - [], - [;], - [ - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_ERROR(invalid combination of flags!) - exit 1; - ]) - - AC_MSG_CHECKING(for consistency of CXXFLAGSO flags) - CXXFLAGS="$CXXFLAGSO" - AC_TRY_COMPILE( - [], - [;], - [ - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_ERROR(invalid combination of flags!) - exit 1; - ]) -]) diff --git a/deal.II/contrib/cmake/configure/configure_threads.cmake b/deal.II/contrib/cmake/configure/configure_threads.cmake index b87ce31cfa..c52e43e863 100644 --- a/deal.II/contrib/cmake/configure/configure_threads.cmake +++ b/deal.II/contrib/cmake/configure/configure_threads.cmake @@ -34,15 +34,16 @@ LIST(APPEND deal_ii_external_debug_libraries ${TBB_DEBUG_LIBRARY} ) - SET(DEAL_II_USE_MT TRUE) +# Set up some posix threads specific configuration toggles: IF(CMAKE_USE_PTHREADS_INIT) SET(DEAL_II_USE_MT_POSIX TRUE) # Check whether posix thread barriers are available: - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + CHECK_CXX_SOURCE_COMPILES( " #include @@ -57,11 +58,34 @@ IF(CMAKE_USE_PTHREADS_INIT) " DEAL_II_HAVE_MT_POSIX_BARRIERS) - SET(CMAKE_REQUIRED_FLAGS "") + LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS) SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE) ENDIF() - ENDIF() + + +# +# +# In some cases, -threads (or whatever else command line option) +# switches on some preprocessor flags. If this is not the case, +# then define them explicitely. +# + +LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") +CHECK_CXX_SOURCE_COMPILES( + " + #if !defined (_REENTRANT) && !defined (_THREAD_SAFE) + # error Neither _REENTRANT nor _THREAD_SAFE were defined. + nonsense + #endif + int main(){ return 0; } + " + DEAL_II_HAVE_SANE_MT_DEFINITIONS) +LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + +IF(NOT DEAL_II_HAVE_SANE_MT_DEFINITIONS) + ADD_DEFINITIONS("-D_REENTRANT" "-D_THREAD_SAFE") +ENDIF()