]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Port MPI, BZIP2 and ZLIB to new find mechanism
authorMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 15 May 2014 20:06:30 +0000 (20:06 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 15 May 2014 20:06:30 +0000 (20:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@32911 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/configure/configure_1_bzip2.cmake
deal.II/cmake/configure/configure_1_mpi.cmake
deal.II/cmake/configure/configure_1_zlib.cmake
deal.II/cmake/macros/macro_deal_ii_package_handle.cmake
deal.II/cmake/modules/FindBZIP2.cmake [new file with mode: 0644]
deal.II/cmake/modules/FindMPI.cmake [new file with mode: 0644]
deal.II/cmake/modules/FindZLIB.cmake [new file with mode: 0644]

index 37a0f813050bb092b4d8f83c9d919b4ba2cd3cfa..42f3915ea9587940b2eb6a713cd1b8ca92dea1bd 100644 (file)
 # Configuration for the bzip2 library:
 #
 
-MACRO(FEATURE_BZIP2_FIND_EXTERNAL var)
-  FIND_PACKAGE(BZip2)
-
-  IF(BZIP2_FOUND)
-    #
-    # Rename variables:
-    #
-    SET(BZIP2_VERSION ${BZIP2_VERSION_STRING})
-    SET(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR})
-
-    SET(${var} TRUE)
-  ENDIF()
-ENDMACRO()
-
 CONFIGURE_FEATURE(BZIP2)
index 1fd25d1bf049a9d3afc8ec67c4d00276036baf83..8001da43184bfba6a839e0d81923a64367c2a375 100644 (file)
 #
 # Configuration for mpi support:
 #
-# We look for the C and Fortran libraries as well because they are needed
-# by some external libraries for the link interface:
-#
-
-MACRO(FEATURE_MPI_FIND_EXTERNAL var)
-  #
-  # Obey a manual user override: If MPI_CXX_FOUND is set to true in the
-  # cache, we skip the FIND_PACKAGE calls:
-  #
-  IF(MPI_CXX_FOUND)
-    SET(MPI_FOUND TRUE)
-  ENDIF()
-
-  #
-  # If CMAKE_CXX_COMPILER is already an MPI wrapper, use it to determine
-  # the mpi implementation. If MPI_CXX_COMPILER is defined use the value
-  # directly.
-  #
-  SET_IF_EMPTY(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER})
-  IF(CMAKE_C_COMPILER_WORKS)
-    SET_IF_EMPTY(MPI_C_COMPILER ${CMAKE_C_COMPILER}) # for good measure
-  ELSE()
-    MESSAGE(STATUS
-      "No suitable C compiler was found! MPI C interface can not be "
-      "autodetected"
-      )
-  ENDIF()
-  IF(CMAKE_Fortran_COMPILER_WORKS)
-    SET_IF_EMPTY(MPI_Fortran_COMPILER ${CMAKE_Fortran_COMPILER}) # for good measure
-  ELSE()
-    MESSAGE(STATUS
-      "No suitable Fortran compiler was found! MPI Fortran interface can "
-      "not be autodetected"
-      )
-  ENDIF()
-
-  FIND_PACKAGE(MPI)
-
-  IF(NOT MPI_CXX_FOUND AND DEAL_II_WITH_MPI)
-    #
-    # CMAKE_CXX_COMPILER is apparently not an mpi wrapper.
-    # So, let's be a bit more aggressive in finding MPI (and if
-    # DEAL_II_WITH_MPI is set).
-    #
-    MESSAGE(STATUS
-      "MPI not found but DEAL_II_WITH_MPI is set to TRUE."
-      " Try again with more aggressive search paths:"
-      )
-    SET(MPI_FOUND) # clear this value so that FIND_PACKAGE runs again.
-    UNSET(MPI_CXX_COMPILER CACHE)
-    UNSET(MPI_C_COMPILER CACHE)
-    UNSET(MPI_Fortran_COMPILER CACHE)
-    FIND_PACKAGE(MPI)
-  ENDIF()
-
-  #
-  # Manually clean up variables:
-  #
-  FOREACH(_lang C CXX Fortran)
-    IF(MPI_${_lang}_LIBRARIES MATCHES "-NOTFOUND")
-      SET(MPI_${_lang}_LIBRARIES)
-    ENDIF()
-  ENDFOREACH()
-
-  IF(MPI_CXX_FOUND)
-    #
-    # Manually assemble some version information:
-    #
-    FIND_FILE(MPI_MPI_H NAMES mpi.h
-      HINTS ${MPI_INCLUDE_PATH}
-      )
-
-    IF(NOT MPI_MPI_H MATCHES "-NOTFOUND" AND NOT DEFINED MPI_VERSION)
-      FILE(STRINGS "${MPI_MPI_H}" MPI_VERSION_MAJOR_STRING
-        REGEX "#define.*MPI_VERSION")
-      STRING(REGEX REPLACE "^.*MPI_VERSION.*([0-9]+).*" "\\1"
-        MPI_VERSION_MAJOR "${MPI_VERSION_MAJOR_STRING}"
-        )
-      FILE(STRINGS ${MPI_MPI_H} MPI_VERSION_MINOR_STRING
-        REGEX "#define.*MPI_SUBVERSION")
-      STRING(REGEX REPLACE "^.*MPI_SUBVERSION.*([0-9]+).*" "\\1"
-        MPI_VERSION_MINOR "${MPI_VERSION_MINOR_STRING}"
-        )
-      SET(MPI_VERSION "${MPI_VERSION_MAJOR}.${MPI_VERSION_MINOR}")
-      IF("${MPI_VERSION}" STREQUAL ".")
-        SET(MPI_VERSION)
-        SET(MPI_VERSION_MAJOR)
-        SET(MPI_VERSION_MINOR)
-      ENDIF()
-
-      # OMPI specific version number:
-      FILE(STRINGS ${MPI_MPI_H} OMPI_VERSION_MAJOR_STRING
-        REGEX "#define.*OMPI_MAJOR_VERSION")
-      STRING(REGEX REPLACE "^.*OMPI_MAJOR_VERSION.*([0-9]+).*" "\\1"
-        OMPI_VERSION_MAJOR "${OMPI_VERSION_MAJOR_STRING}"
-        )
-      FILE(STRINGS ${MPI_MPI_H} OMPI_VERSION_MINOR_STRING
-        REGEX "#define.*OMPI_MINOR_VERSION")
-      STRING(REGEX REPLACE "^.*OMPI_MINOR_VERSION.*([0-9]+).*" "\\1"
-        OMPI_VERSION_MINOR "${OMPI_VERSION_MINOR_STRING}"
-        )
-      FILE(STRINGS ${MPI_MPI_H} OMPI_VERSION_RELEASE_STRING
-        REGEX "#define.*OMPI_RELEASE_VERSION")
-      STRING(REGEX REPLACE "^.*OMPI_RELEASE_VERSION.*([0-9]+).*" "\\1"
-        OMPI_VERSION_SUBMINOR "${OMPI_VERSION_RELEASE_STRING}"
-        )
-      SET(OMPI_VERSION
-        "${OMPI_VERSION_MAJOR}.${OMPI_VERSION_MINOR}.${OMPI_VERSION_SUBMINOR}"
-        )
-      IF("${OMPI_VERSION}" STREQUAL "..")
-        SET(OMPI_VERSION)
-        SET(OMPI_VERSION_MAJOR)
-        SET(OMPI_VERSION_MINOR)
-        SET(OMPI_VERSION_SUBMINOR)
-      ENDIF()
-    ENDIF()
-
-    SET(${var} TRUE)
-  ENDIF()
-
-  # Hide some variables:
-  MARK_AS_ADVANCED(MPI_EXTRA_LIBRARY MPI_LIBRARY MPI_MPI_H)
-
-  #
-  # Populate correct variables:
-  #
-  SET(MPI_LIBRARIES
-    ${MPI_CXX_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${MPI_C_LIBRARIES}
-    )
-  SET(MPI_INCLUDE_DIRS ${MPI_CXX_INCLUDE_PATH})
-  SET(MPI_CXX_FLAGS ${MPI_CXX_COMPILE_FLAGS})
-  SET(MPI_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}")
-
-ENDMACRO()
-
 
 MACRO(FEATURE_MPI_ERROR_MESSAGE)
   MESSAGE(FATAL_ERROR "\n"
@@ -169,10 +34,4 @@ MACRO(FEATURE_MPI_ERROR_MESSAGE)
     )
 ENDMACRO()
 
-
 CONFIGURE_FEATURE(MPI)
-
-#
-# The user has to know the location of the mpi headers as well:
-#
-SET(MPI_USER_INCLUDE_DIRS ${MPI_INCLUDE_DIRS})
index 772f66acbcda9e085ae956f0a6c471c5aa919d21..5058a7195c6deb235cabd4f021ecfe5dc31086bf 100644 (file)
@@ -1,7 +1,7 @@
 ## ---------------------------------------------------------------------
 ## $Id$
 ##
-## Copyright (C) 2012 - 2013 by the deal.II authors
+## Copyright (C) 2012 - 2014 by the deal.II authors
 ##
 ## This file is part of the deal.II library.
 ##
@@ -19,8 +19,3 @@
 #
 
 CONFIGURE_FEATURE(ZLIB)
-
-# Export ZLIB_VERSION:
-IF(DEFINED ZLIB_VERSION_STRING)
-  SET(ZLIB_VERSION ${ZLIB_VERSION_STRING})
-ENDIF()
index 8fa5e6142dd4cb6b92f23899bf8060c1617042dc..f0deef241d98d92e48e27d871ced118a4e318262 100644 (file)
@@ -104,11 +104,11 @@ MACRO(DEAL_II_PACKAGE_HANDLE _feature _var)
           LIST(APPEND _clear ${_arg})
         ENDIF()
       ELSE()
-        IF(NOT DEFINED ${_arg} OR ${_arg} MATCHES "-NOTFOUND")
+        IF("${_arg}" STREQUAL "" OR ${_arg} MATCHES "-NOTFOUND")
           IF(_required AND _fine)
-            IF(NOT DEFINED ${_arg})
+            IF("${_arg}" STREQUAL "")
               MESSAGE(STATUS
-                "  ${_feature}_${_variable}: *** Required variable \"${_arg}\" undefined ***"
+                "  ${_feature}_${_variable}: *** Required variable \"${_arg}\" empty ***"
                 )
             ELSE()
               MESSAGE(STATUS
diff --git a/deal.II/cmake/modules/FindBZIP2.cmake b/deal.II/cmake/modules/FindBZIP2.cmake
new file mode 100644 (file)
index 0000000..e6f7cbd
--- /dev/null
@@ -0,0 +1,46 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2014 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 at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Try to find the BZIP2 library
+#
+# This module exports
+#
+#   BZIP2_LIBRARIES
+#   BZIP2_INCLUDE_DIRS
+#   BZIP2_VERSION
+#
+
+#
+# Houston, we have a problem: CMake ships its own FindBZip2.cmake module.
+# Unfortunately we want to call DEAL_II_PACKAGE_HANDLE. Therefore, use the
+# original find module and do a dummy call to DEAL_II_PACKAGE_HANDLE:
+#
+
+LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
+FIND_PACKAGE(BZip2)
+LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
+
+SET(BZIP2_VERSION ${BZIP2_VERSION_STRING})
+SET(_bzip2_libraries ${BZIP2_LIBRARIES})
+
+DEAL_II_PACKAGE_HANDLE(BZIP2
+  LIBRARIES REQUIRED _bzip2_libraries
+  INCLUDE_DIRS REQUIRED BZIP2_INCLUDE_DIR
+  CLEAR
+    BZIP2_INCLUDE_DIR BZIP2_LIBRARY_DEBUG BZIP2_LIBRARY_RELEASE
+    BZIP2_NEED_PREFIX
+  )
diff --git a/deal.II/cmake/modules/FindMPI.cmake b/deal.II/cmake/modules/FindMPI.cmake
new file mode 100644 (file)
index 0000000..111c75a
--- /dev/null
@@ -0,0 +1,163 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2012 - 2014 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 at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Find MPI
+#
+# This module exports:
+#   MPI_LIBRARIES
+#   MPI_INCLUDE_DIRS
+#   MPI_CXX_FLAGS
+#   MPI_LINKER_FLAGS
+#   MPI_VERSION
+#   OMPI_VERSION
+#
+
+#
+# Configuration for mpi support:
+#
+# We look for the C and Fortran libraries as well because they are needed
+# by some external libraries for the link interface.
+#
+
+IF(MPI_CXX_FOUND)
+  SET(MPI_FOUND TRUE)
+ENDIF()
+
+#
+# If CMAKE_CXX_COMPILER is already an MPI wrapper, use it to determine
+# the mpi implementation. If MPI_CXX_COMPILER is defined use the value
+# directly.
+#
+SET_IF_EMPTY(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER})
+IF(CMAKE_C_COMPILER_WORKS)
+  SET_IF_EMPTY(MPI_C_COMPILER ${CMAKE_C_COMPILER}) # for good measure
+ELSE()
+  MESSAGE(STATUS
+    "No suitable C compiler was found! MPI C interface can not be "
+    "autodetected"
+    )
+ENDIF()
+IF(CMAKE_Fortran_COMPILER_WORKS)
+  SET_IF_EMPTY(MPI_Fortran_COMPILER ${CMAKE_Fortran_COMPILER}) # for good measure
+ELSE()
+  MESSAGE(STATUS
+    "No suitable Fortran compiler was found! MPI Fortran interface can "
+    "not be autodetected"
+    )
+ENDIF()
+
+#
+# Call the system FindMPI.cmake module:
+#
+LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
+FIND_PACKAGE(MPI)
+
+IF(NOT MPI_CXX_FOUND AND DEAL_II_WITH_MPI)
+  #
+  # CMAKE_CXX_COMPILER is apparently not an mpi wrapper.
+  # So, let's be a bit more aggressive in finding MPI (and if
+  # DEAL_II_WITH_MPI is set).
+  #
+  MESSAGE(STATUS
+    "MPI not found but DEAL_II_WITH_MPI is set to TRUE."
+    " Try again with more aggressive search paths:"
+    )
+  # Clear variables so that FIND_PACKAGE runs again:
+  SET(MPI_FOUND)
+  UNSET(MPI_CXX_COMPILER CACHE)
+  UNSET(MPI_C_COMPILER CACHE)
+  UNSET(MPI_Fortran_COMPILER CACHE)
+  FIND_PACKAGE(MPI)
+ENDIF()
+LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
+
+
+#
+# Manually assemble some version information:
+#
+
+DEAL_II_FIND_FILE(MPI_MPI_H
+  NAMES mpi.h
+  HINTS ${MPI_CXX_INCLUDE_PATH} ${MPI_C_INCLUDE_PATH}
+  )
+IF(NOT MPI_MPI_H MATCHES "-NOTFOUND" AND NOT DEFINED MPI_VERSION)
+  FILE(STRINGS "${MPI_MPI_H}" MPI_VERSION_MAJOR_STRING
+    REGEX "#define.*MPI_VERSION")
+  STRING(REGEX REPLACE "^.*MPI_VERSION.*([0-9]+).*" "\\1"
+    MPI_VERSION_MAJOR "${MPI_VERSION_MAJOR_STRING}"
+    )
+  FILE(STRINGS ${MPI_MPI_H} MPI_VERSION_MINOR_STRING
+    REGEX "#define.*MPI_SUBVERSION")
+  STRING(REGEX REPLACE "^.*MPI_SUBVERSION.*([0-9]+).*" "\\1"
+    MPI_VERSION_MINOR "${MPI_VERSION_MINOR_STRING}"
+    )
+  SET(MPI_VERSION "${MPI_VERSION_MAJOR}.${MPI_VERSION_MINOR}")
+  IF("${MPI_VERSION}" STREQUAL ".")
+    SET(MPI_VERSION)
+    SET(MPI_VERSION_MAJOR)
+    SET(MPI_VERSION_MINOR)
+  ENDIF()
+
+  # OMPI specific version number:
+  FILE(STRINGS ${MPI_MPI_H} OMPI_VERSION_MAJOR_STRING
+    REGEX "#define.*OMPI_MAJOR_VERSION")
+  STRING(REGEX REPLACE "^.*OMPI_MAJOR_VERSION.*([0-9]+).*" "\\1"
+    OMPI_VERSION_MAJOR "${OMPI_VERSION_MAJOR_STRING}"
+    )
+  FILE(STRINGS ${MPI_MPI_H} OMPI_VERSION_MINOR_STRING
+    REGEX "#define.*OMPI_MINOR_VERSION")
+  STRING(REGEX REPLACE "^.*OMPI_MINOR_VERSION.*([0-9]+).*" "\\1"
+    OMPI_VERSION_MINOR "${OMPI_VERSION_MINOR_STRING}"
+    )
+  FILE(STRINGS ${MPI_MPI_H} OMPI_VERSION_RELEASE_STRING
+    REGEX "#define.*OMPI_RELEASE_VERSION")
+  STRING(REGEX REPLACE "^.*OMPI_RELEASE_VERSION.*([0-9]+).*" "\\1"
+    OMPI_VERSION_SUBMINOR "${OMPI_VERSION_RELEASE_STRING}"
+    )
+  SET(OMPI_VERSION
+    "${OMPI_VERSION_MAJOR}.${OMPI_VERSION_MINOR}.${OMPI_VERSION_SUBMINOR}"
+    )
+  IF("${OMPI_VERSION}" STREQUAL "..")
+    SET(OMPI_VERSION)
+    SET(OMPI_VERSION_MAJOR)
+    SET(OMPI_VERSION_MINOR)
+    SET(OMPI_VERSION_SUBMINOR)
+  ENDIF()
+ENDIF()
+
+DEAL_II_PACKAGE_HANDLE(MPI
+  LIBRARIES
+    REQUIRED MPI_CXX_LIBRARIES
+    OPTIONAL MPI_Fortran_LIBRARIES MPI_C_LIBRARIES
+  INCLUDE_DIRS
+    REQUIRED MPI_CXX_INCLUDE_PATH
+    OPTIONAL MPI_C_INCLUDE_PATH
+  USER_INCLUDE_DIRS
+    REQUIRED MPI_CXX_INCLUDE_PATH
+    OPTIONAL MPI_C_INCLUDE_PATH
+  CXX_FLAGS OPTIONAL MPI_CXX_COMPILE_FLAGS
+  LINKER_FLAGS OPTIONAL MPI_CXX_LINK_FLAGS
+  CLEAR
+    MPI_MPI_H
+    MPI_HEADER_PATH
+    MPI_LIB
+    MPIEXEC
+    MPI_CXX_COMPILER
+    MPI_C_COMPILER
+    MPI_Fortran_COMPILER
+  )
+
diff --git a/deal.II/cmake/modules/FindZLIB.cmake b/deal.II/cmake/modules/FindZLIB.cmake
new file mode 100644 (file)
index 0000000..d902289
--- /dev/null
@@ -0,0 +1,51 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2014 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 at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Try to find the ZLIB library
+#
+# This module exports
+#
+#   ZLIB_LIBRARIES
+#   ZLIB_INCLUDE_DIRS
+#   ZLIB_VERSION
+#
+
+SET(ZLIB_DIR "" CACHE PATH "An optional hint to a ZLIB installation")
+SET_IF_EMPTY(ZLIB_DIR "$ENV{ZLIB_DIR}")
+
+#
+# Houston, we have a problem: CMake ships its own FindZLIB.cmake module.
+# Unfortunately we want to call DEAL_II_PACKAGE_HANDLE. Therefore, use the
+# original find module and do a dummy call to DEAL_II_PACKAGE_HANDLE:
+#
+
+IF(NOT "${ZLIB_DIR}" STREQUAL "")
+  SET(ZLIB_ROOT ${ZLIB_DIR})
+ENDIF()
+LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
+FIND_PACKAGE(ZLIB)
+LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
+
+SET(ZLIB_VERSION ${ZLIB_VERSION_STRING})
+SET(_zlib_libraries ${ZLIB_LIBRARIES})
+SET(_zlib_include_dirs ${ZLIB_INCLUDE_DIRS})
+
+DEAL_II_PACKAGE_HANDLE(ZLIB
+  LIBRARIES REQUIRED _zlib_libraries
+  INCLUDE_DIRS REQUIRED _zlib_include_dirs
+  CLEAR ZLIB_INCLUDE_DIR ZLIB_LIBRARY
+  )

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.