]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Remove obsolete threading setup
authorMatthias Maier <tamiko@43-1.org>
Sat, 23 May 2020 05:25:47 +0000 (00:25 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 27 May 2020 03:34:01 +0000 (22:34 -0500)
bundled/tbb-2018_U2/src/CMakeLists.txt
cmake/configure/configure_0_threads.cmake [new file with mode: 0644]
cmake/configure/configure_1_lapack.cmake
cmake/configure/configure_1_tbb.cmake [new file with mode: 0644]
cmake/configure/configure_1_threads.cmake [deleted file]
cmake/macros/macro_deal_ii_package_handle.cmake
cmake/macros/macro_find_system_library.cmake
cmake/modules/FindBOOST.cmake
cmake/modules/FindUMFPACK.cmake

index f9c069292258e0f3607b9b1e90e338463fb2ad08..412930681624fe8e3a875e559136366a0cd5dca0 100644 (file)
@@ -45,7 +45,7 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wtautological-overlap-compare=0")
 
 SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
 INCLUDE_DIRECTORIES(
-  ${THREADS_BUNDLED_INCLUDE_DIRS}
+  ${TBB_BUNDLED_INCLUDE_DIRS}
   ${CMAKE_CURRENT_SOURCE_DIR}/rml/include
   )
 
diff --git a/cmake/configure/configure_0_threads.cmake b/cmake/configure/configure_0_threads.cmake
new file mode 100644 (file)
index 0000000..33ae714
--- /dev/null
@@ -0,0 +1,37 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2012 - 2020 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+
+#
+# Set up threading:
+#
+
+# Clear the test flags because FindThreads.cmake will use a C compiler:
+CLEAR_CMAKE_REQUIRED()
+
+SWITCH_LIBRARY_PREFERENCE()
+FIND_PACKAGE(Threads)
+SWITCH_LIBRARY_PREFERENCE()
+
+RESET_CMAKE_REQUIRED()
+
+ADD_FLAGS(DEAL_II_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+
+IF(NOT Threads_FOUND)
+  MESSAGE(FATAL_ERROR
+    "\nFatal configuration error: CMake was unable to detect any threading "
+    "support offered by the current compiler. Configuration cannot continue.\n\n"
+    )
+ENDIF()
index 87729c9ef8694fadc356f64a175a30c1d4f4cbfe..30204fbb593b36336531e1fb87c8fdd2bd9bbe6c 100644 (file)
@@ -34,8 +34,6 @@ MACRO(FEATURE_LAPACK_FIND_EXTERNAL var)
     SET(CMAKE_REQUIRED_LIBRARIES
       ${DEAL_II_LINKER_FLAGS_SAVED} ${LAPACK_LINKER_FLAGS} ${LAPACK_LIBRARIES}
       )
-    # Push -pthread as well:
-    ENABLE_IF_SUPPORTED(CMAKE_REQUIRED_FLAGS "-pthread")
 
     CHECK_C_SOURCE_COMPILES("
       char daxpy_(); char dgeev_(); char dgeevx_(); char dgelsd_(); char
diff --git a/cmake/configure/configure_1_tbb.cmake b/cmake/configure/configure_1_tbb.cmake
new file mode 100644 (file)
index 0000000..be585ac
--- /dev/null
@@ -0,0 +1,87 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2012 - 2020 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# Configuration for thread support in deal.II with the help of the tbb
+# library:
+#
+
+MACRO(FEATURE_TBB_FIND_EXTERNAL var)
+  FIND_PACKAGE(TBB)
+
+  IF(TBB_FOUND)
+    SET(${var} TRUE)
+  ENDIF()
+
+  #
+  # TBB currently uses the version numbering scheme
+  #
+  #     YYYY.X
+  #
+  # (e.g., 2018.0) where YYYY is the year of the release and X is the yearly
+  # release number. Older versions use
+  #
+  #     X.Y.Z
+  #
+  # (e.g., 4.2.1). Since we are compatible with all versions that use the new
+  # numbering scheme we only check for very old versions here.
+  #
+  # TBB versions before 4.2 are missing some explicit calls to std::atomic::load
+  # in ternary expressions; these cause compilation errors in some compilers
+  # (such as GCC 8.1 and newer). To fix this we simply blacklist all older
+  # versions:
+  #
+  IF(TBB_VERSION VERSION_LESS "4.2")
+    # Clear the previously determined version numbers to avoid confusion
+    SET(TBB_VERSION "bundled")
+    SET(TBB_VERSION_MAJOR "")
+    SET(TBB_VERSION_MINOR "")
+
+    MESSAGE(STATUS
+      "The externally provided TBB library is older than version 4.2.0, which "
+      "cannot be used with deal.II."
+      )
+    SET(TBB_ADDITIONAL_ERROR_STRING
+      "The externally provided TBB library is older than version\n"
+      "4.2.0, which is the oldest version compatible with deal.II and its\n"
+      "supported compilers."
+      )
+    SET(${var} FALSE)
+  ENDIF()
+ENDMACRO()
+
+
+MACRO(FEATURE_TBB_CONFIGURE_EXTERNAL)
+ENDMACRO()
+
+
+MACRO(FEATURE_TBB_CONFIGURE_BUNDLED)
+  #
+  # We have to disable a bunch of warnings:
+  #
+  ENABLE_IF_SUPPORTED(TBB_CXX_FLAGS "-Wno-parentheses")
+
+  #
+  # tbb uses dlopen/dlclose, so link against libdl.so as well:
+  #
+  LIST(APPEND TBB_LIBRARIES ${CMAKE_DL_LIBS})
+
+  LIST(APPEND TBB_BUNDLED_INCLUDE_DIRS ${TBB_FOLDER}/include)
+ENDMACRO()
+
+
+CONFIGURE_FEATURE(TBB)
+SET(DEAL_II_WITH_THREADS ${DEAL_II_WITH_TBB})
+
diff --git a/cmake/configure/configure_1_threads.cmake b/cmake/configure/configure_1_threads.cmake
deleted file mode 100644 (file)
index c15b94b..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-## ---------------------------------------------------------------------
-##
-## Copyright (C) 2012 - 2020 by the deal.II authors
-##
-## This file is part of the deal.II library.
-##
-## The deal.II library is free software; you can use it, redistribute
-## it, and/or modify it under the terms of the GNU Lesser General
-## Public License as published by the Free Software Foundation; either
-## version 2.1 of the License, or (at your option) any later version.
-## The full text of the license can be found in the file LICENSE.md at
-## the top level directory of deal.II.
-##
-## ---------------------------------------------------------------------
-
-#
-# Configuration for thread support in deal.II with the help of the tbb
-# library:
-#
-
-#
-# Set up general threading:
-# The macro will be included in CONFIGURE_FEATURE_THREADS_EXTERNAL/BUNDLED.
-#
-MACRO(SETUP_THREADING)
-  #
-  # Unfortunately the FindThreads macro needs a working C compiler
-  #
-  IF(CMAKE_C_COMPILER_WORKS)
-    #
-    # Clear the test flags because FindThreads.cmake will use a C compiler:
-    #
-    CLEAR_CMAKE_REQUIRED()
-
-    SWITCH_LIBRARY_PREFERENCE()
-    FIND_PACKAGE(Threads)
-    SWITCH_LIBRARY_PREFERENCE()
-
-    RESET_CMAKE_REQUIRED()
-
-    #
-    # The FindThreads macro returned a linker option instead of the actual
-    # library name in earlier versions. We still require the linker option,
-    # so we fix the corresponding variable.
-    #  - See: https://gitlab.kitware.com/cmake/cmake/issues/19747
-    #
-    IF(CMAKE_THREAD_LIBS_INIT AND NOT "${CMAKE_THREAD_LIBS_INIT}" MATCHES "^-l")
-      STRING(PREPEND CMAKE_THREAD_LIBS_INIT "-l")
-    ENDIF()
-
-  ELSE()
-
-    #
-    # We have no way to query for thread support. Just assume that it is
-    # provided by Pthreads...
-    #
-    MESSAGE(STATUS
-      "No suitable C compiler was found! Assuming threading is provided by Pthreads."
-      )
-    SET_IF_EMPTY(Threads_FOUND TRUE)
-    SET_IF_EMPTY(CMAKE_THREAD_LIBS_INIT "-lpthread")
-    SET_IF_EMPTY(CMAKE_USE_PTHREADS_INIT TRUE)
-  ENDIF()
-
-  IF(NOT Threads_FOUND)
-    #
-    # TODO: This is a dead end. Threading might be set up with internal TBB
-    # so we have no way of returning unsuccessfully...
-    #
-    MESSAGE(FATAL_ERROR
-      "\nInternal configuration error: No Threading support found\n\n"
-      )
-  ENDIF()
-
-  MARK_AS_ADVANCED(pthread_LIBRARY)
-
-  #
-  # Change -lpthread to -pthread for better compatibility on non linux
-  # platforms:
-  #
-  IF("${CMAKE_THREAD_LIBS_INIT}" MATCHES "-lpthread")
-    CHECK_CXX_COMPILER_FLAG("-pthread"
-      DEAL_II_HAVE_FLAG_pthread
-      )
-    IF(DEAL_II_HAVE_FLAG_pthread)
-      STRING(REPLACE "-lpthread" "-pthread" CMAKE_THREAD_LIBS_INIT
-        "${CMAKE_THREAD_LIBS_INIT}"
-        )
-    ENDIF()
-  ENDIF()
-
-  ADD_FLAGS(THREADS_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
-ENDMACRO()
-
-
-#
-# Set up the tbb library:
-#
-
-MACRO(FEATURE_THREADS_FIND_EXTERNAL var)
-  FIND_PACKAGE(TBB)
-
-  IF(TBB_FOUND)
-    SET(${var} TRUE)
-  ENDIF()
-
-  #
-  # TBB currently uses the version numbering scheme
-  #
-  #     YYYY.X
-  #
-  # (e.g., 2018.0) where YYYY is the year of the release and X is the yearly
-  # release number. Older versions use
-  #
-  #     X.Y.Z
-  #
-  # (e.g., 4.2.1). Since we are compatible with all versions that use the new
-  # numbering scheme we only check for very old versions here.
-  #
-  # TBB versions before 4.2 are missing some explicit calls to std::atomic::load
-  # in ternary expressions; these cause compilation errors in some compilers
-  # (such as GCC 8.1 and newer). To fix this we simply blacklist all older
-  # versions:
-  #
-  IF(TBB_VERSION VERSION_LESS "4.2")
-    # Clear the previously determined version numbers to avoid confusion
-    SET(TBB_VERSION "bundled")
-    SET(TBB_VERSION_MAJOR "")
-    SET(TBB_VERSION_MINOR "")
-
-    MESSAGE(STATUS
-      "The externally provided TBB library is older than version 4.2.0, which "
-      "cannot be used with deal.II."
-      )
-    SET(THREADS_ADDITIONAL_ERROR_STRING
-      "The externally provided TBB library is older than version\n"
-      "4.2.0, which is the oldest version compatible with deal.II and its\n"
-      "supported compilers."
-      )
-    SET(${var} FALSE)
-  ENDIF()
-ENDMACRO()
-
-
-MACRO(FEATURE_THREADS_CONFIGURE_EXTERNAL)
-
-  IF(CMAKE_BUILD_TYPE MATCHES "Debug")
-    IF(TBB_WITH_DEBUG_LIB)
-      LIST(APPEND THREADS_DEFINITIONS_DEBUG "TBB_USE_DEBUG" "TBB_DO_ASSERT=1")
-      LIST(APPEND THREADS_USER_DEFINITIONS_DEBUG "TBB_USE_DEBUG" "TBB_DO_ASSERT=1")
-    ENDIF()
-  ENDIF()
-
-  SETUP_THREADING()
-
-  LIST(APPEND THREADS_LIBRARIES ${TBB_LIBRARIES})
-  LIST(APPEND THREADS_INCLUDE_DIRS ${TBB_INCLUDE_DIRS})
-  LIST(APPEND THREADS_USER_INCLUDE_DIRS ${TBB_USER_INCLUDE_DIRS})
-
-ENDMACRO()
-
-
-MACRO(FEATURE_THREADS_CONFIGURE_BUNDLED)
-  #
-  # Setup threading (before configuring our build...)
-  #
-  SETUP_THREADING()
-
-  #
-  # We have to disable a bunch of warnings:
-  #
-  ENABLE_IF_SUPPORTED(THREADS_CXX_FLAGS "-Wno-parentheses")
-
-  #
-  # Add some definitions to use the header files in debug mode:
-  #
-  IF (CMAKE_BUILD_TYPE MATCHES "Debug")
-    LIST(APPEND THREADS_DEFINITIONS_DEBUG "TBB_USE_DEBUG" "TBB_DO_ASSERT=1")
-    LIST(APPEND THREADS_USER_DEFINITIONS_DEBUG "TBB_USE_DEBUG" "TBB_DO_ASSERT=1")
-  ENDIF()
-
-  #
-  # Workaround for an issue with C++11 mode, non gcc-compilers and missing
-  # template<typename T> std::is_trivially_copyable<T>
-  #
-  IF( NOT DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE AND
-      NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
-    LIST(APPEND THREADS_DEFINITIONS "TBB_IMPLEMENT_CPP0X=1")
-    LIST(APPEND THREADS_USER_DEFINITIONS "TBB_IMPLEMENT_CPP0X=1")
-  ENDIF()
-
-  #
-  # tbb uses dlopen/dlclose, so link against libdl.so as well:
-  #
-  # TODO: Also necessary for external lib, use preference toggle
-  #
-  LIST(APPEND THREADS_LIBRARIES ${CMAKE_DL_LIBS})
-
-  LIST(APPEND THREADS_BUNDLED_INCLUDE_DIRS ${TBB_FOLDER}/include)
-ENDMACRO()
-
-
-CONFIGURE_FEATURE(THREADS)
index 6f12ffda23077dbc055c77930ea881a7681fe38b..d7c8ce851d77e9b00ad87e51f55887081a427b97 100644 (file)
@@ -153,6 +153,17 @@ MACRO(DEAL_II_PACKAGE_HANDLE _feature _var)
       ENDIF()
     ENDFOREACH()
 
+    #
+    # Remove certain system libraries from the link interface
+    #
+    FOREACH(_suffix LIBRARIES LIBRARIES_DEBUG LIBRARIES_RELEASE)
+      IF(NOT "${${_feature}_${_suffix}}" STREQUAL "")
+        LIST(REMOVE_ITEM ${_feature}_${_suffix}
+          "pthread" "-pthread" "-lpthread" "c" "-lc"
+          )
+      ENDIF()
+    ENDFOREACH()
+
     MESSAGE(STATUS "Found ${_feature}")
 
     MARK_AS_ADVANCED(${_feature}_DIR ${_feature}_ARCH)
index 5ec62800ab3093d150b9f21e1c9735a09e68cc19..945edda850fb925e4dc4573726b8d65cf0227b19 100644 (file)
@@ -36,6 +36,7 @@ MACRO(FIND_SYSTEM_LIBRARY)
         UNSET(${_variable} CACHE)
         SET(${_variable} ${_arg} CACHE STRING "A system library.")
         SET(${_variable} ${_arg})
+        MARK_AS_ADVANCED(${_variable})
         BREAK()
       ELSE()
         UNSET(${_variable} CACHE)
index 6e26fbd51ea1adf6ef0a049933b0cd24e444a257..02790e4691c68e01911bd3cda59aed201b3ef3e8 100644 (file)
@@ -86,12 +86,6 @@ ENDIF()
 UNSET(Boost_NO_BOOST_CMAKE)
 
 IF(Boost_FOUND)
-  #
-  # Remove "pthread" from Boost_LIBRARIES. Threading, if necessary, is
-  # already set up via configure_1_threads.cmake.
-  #
-  LIST(REMOVE_ITEM Boost_LIBRARIES "pthread")
-
   SET(BOOST_VERSION_MAJOR "${Boost_MAJOR_VERSION}")
   SET(BOOST_VERSION_MINOR "${Boost_MINOR_VERSION}")
   SET(BOOST_VERSION_SUBMINOR "${Boost_SUBMINOR_VERSION}")
index 1d00591c7193b65af85973206f73f9987dc2cb79..a50b87934506b1b1734d3cd8f48e4def168beac4 100644 (file)
@@ -125,7 +125,6 @@ FIND_UMFPACK_LIBRARY(SuiteSparse_config suitesparseconfig)
 # by ldd :-( ):
 #
 FIND_SYSTEM_LIBRARY(rt_LIBRARY NAMES rt)
-MARK_AS_ADVANCED(rt_LIBRARY)
 
 DEAL_II_PACKAGE_HANDLE(UMFPACK
   LIBRARIES

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.