From 33c12662f7e502c4ceec783893ad6035694bd777 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 22 Jul 2013 23:30:27 +0000 Subject: [PATCH] Merge revisions 30117, 30118 from mainline. git-svn-id: https://svn.dealii.org/branches/releases/Branch-8-0@30119 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 12 +--- deal.II/cmake/configure/configure_1_mpi.cmake | 3 + .../macro_enable_language_optional.cmake | 65 +++++++++++++++++++ deal.II/cmake/modules/FindSCALAPACK.cmake | 2 +- deal.II/cmake/setup_compiler_flags.cmake | 4 +- deal.II/doc/development/Config.sample | 20 +++++- deal.II/doc/development/cmake.html | 14 ++-- 7 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 deal.II/cmake/macros/macro_enable_language_optional.cmake diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 10ee330876..04dba539c6 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -69,16 +69,8 @@ INCLUDE(setup_cached_variables) # Now, set the project and set up the rest: # PROJECT(deal.II CXX) -ENABLE_LANGUAGE(C) - -# -# TODO: A quick test. Refactor. -# It would be highly appreciated to use ENABLE_LANGUAGE(... OPTIONAL) here -# - but this is broken beyond believe up until cmake-2.11.* *sigh* -# -IF(ENABLE_FORTRAN) - ENABLE_LANGUAGE(Fortran) -ENDIF() +ENABLE_LANGUAGE_OPTIONAL(C) +ENABLE_LANGUAGE_OPTIONAL(Fortran) INCLUDE(setup_deal_ii) INCLUDE(setup_compiler_flags) diff --git a/deal.II/cmake/configure/configure_1_mpi.cmake b/deal.II/cmake/configure/configure_1_mpi.cmake index 2b15c452c3..85de2a41c2 100644 --- a/deal.II/cmake/configure/configure_1_mpi.cmake +++ b/deal.II/cmake/configure/configure_1_mpi.cmake @@ -17,6 +17,9 @@ # # Configuration for mpi support: # +# We look for the C and Fortran libraries as well because they are needed +# by some external libraries: +# MACRO(FEATURE_MPI_FIND_EXTERNAL var) # diff --git a/deal.II/cmake/macros/macro_enable_language_optional.cmake b/deal.II/cmake/macros/macro_enable_language_optional.cmake new file mode 100644 index 0000000000..975f476059 --- /dev/null +++ b/deal.II/cmake/macros/macro_enable_language_optional.cmake @@ -0,0 +1,65 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## Copyright (C) 2013 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. +## +## --------------------------------------------------------------------- + + +# +# Test whether a usable language compiler is available and if yes, call +# ENABLE_LANGUAGE(language) +# +# This works around a severe bug [1] in +# +# ENABLE_LANGUAGE(Fortran OPTIONAL) +# +# [1] http://public.kitware.com/Bug/view.php?id=9220 +# +# Usage: +# ENABLE_LANGUAGE_FORTRAN_OPTIONAL(language) +# +# where language is either C or Fortran +# + +MACRO(ENABLE_LANGUAGE_OPTIONAL _language) + # + # Run this check exactly once: + # + IF(NOT ${_language}_CHECKED) + SET(${_language}_CHECKED TRUE CACHE INTERNAL "" FORCE) + + SET(_tmp ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/${_language}_test) + file(REMOVE ${_tmp}) + + IF(DEFINED CMAKE_${_language}_COMPILER) + SET(_hint "-DCMAKE_${_language}_COMPILER=${CMAKE_${_language}_COMPILER}") + ENDIF() + + FILE(WRITE ${_tmp}/CMakeLists.txt + "PROJECT(foobar ${_language})" + ) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} ${_hint} . + WORKING_DIRECTORY ${_tmp} + RESULT_VARIABLE _result + OUTPUT_QUIET + ERROR_QUIET + ) + + IF("${_result}" STREQUAL "0") + ENABLE_LANGUAGE(${_language}) + ELSE() + MESSAGE(STATUS "No working ${_language} compiler found, disabling ${_language}") + ENDIF() + ENDIF() +ENDMACRO() diff --git a/deal.II/cmake/modules/FindSCALAPACK.cmake b/deal.II/cmake/modules/FindSCALAPACK.cmake index 32adc9b5ff..4cd616dbae 100644 --- a/deal.II/cmake/modules/FindSCALAPACK.cmake +++ b/deal.II/cmake/modules/FindSCALAPACK.cmake @@ -51,7 +51,7 @@ FIND_PACKAGE(LAPACK) FOREACH(_lib blacs blacsCinit blacsF77init) STRING(TOUPPER "${_lib}" _lib_upper) FIND_LIBRARY(${_lib_upper}_LIBRARY - NAMES ${_lib} ${_lib}_MPI-LINUX-0 + NAMES ${_lib} ${_lib}_MPI-LINUX-0 ${_lib}_MPI-DARWIN-0 HINTS ${BLACS_DIR} ${SCALAPACK_DIR} diff --git a/deal.II/cmake/setup_compiler_flags.cmake b/deal.II/cmake/setup_compiler_flags.cmake index 92baf5eb1a..4815abf65f 100644 --- a/deal.II/cmake/setup_compiler_flags.cmake +++ b/deal.II/cmake/setup_compiler_flags.cmake @@ -65,9 +65,7 @@ # # Check the user provided CXX flags: # -# -# Omit to test for a sane C and Fortran toolchain for now.. -# +MESSAGE(STATUS "") IF(NOT "${CMAKE_CXX_FLAGS_SAVED}" STREQUAL "${DEAL_II_CXX_FLAGS_SAVED}") UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE) ENDIF() diff --git a/deal.II/doc/development/Config.sample b/deal.II/doc/development/Config.sample index 61716f2d5f..6f4ad89247 100644 --- a/deal.II/doc/development/Config.sample +++ b/deal.II/doc/development/Config.sample @@ -83,6 +83,10 @@ # "C Compiler." # ) # +# SET(CMAKE_Fortran_COMPILER "" CACHE STRING +# "Fortran Compiler." +# ) +# # SET(CMAKE_CXX_FLAGS "" CACHE STRING # "The user supplied cache variable will be appended _at the end_ of the auto generated CMAKE_CXX_FLAGS variable" # ) @@ -288,17 +292,23 @@ # conservative. Only the current compiler and the variable MPI_CXX_COMPILER # is used to find MPI. (MPI_CXX_COMPILER takes precedence.) # +# (MPI_C_COMPILER and MPI_Fortran_COMPILER are considered, too) +# +# # DEAL_II_WITH_MPI=ON will trigger a more sophisticated search for MPI. # # The best way to force a specific MPI implementation to be used is to set -# CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to the appropriate MPI wrapper -# (See above). +# CMAKE_CXX_COMPILER, CMAKE_C_COMPILER and CMAKE_Fortran_COMPILER to the +# appropriate MPI wrapper (See above). # # Alternatively, specify the mpi wrapper that will be queried for the mpi # link interface: # # SET(MPI_CXX_COMPILER "mpicxx" CACHE STRING "") # +# SET(MPI_C_COMPILER "mpicc" CACHE STRING "") +# SET(MPI_Fortran_COMPILER "mpif90" CACHE STRING "") +# # # Manual setup: # @@ -313,6 +323,12 @@ # SET(MPI_CXX_COMPILE_FLAGS "..." CACHE STRING "") # SET(MPI_CXX_LINK_FLAGS "..." CACHE STRING "") # +# Additionally: +# +# SET(MPI_C_LIBRARIES "library;and;semicolon;separated;list;of;link;interface" CACHE STRING "") +# SET(MPI_Fortran_LIBRARIES "library;and;semicolon;separated;list;of;link;interface" CACHE STRING "") +# +# # diff --git a/deal.II/doc/development/cmake.html b/deal.II/doc/development/cmake.html index 75c7bb8451..05fe95d6e9 100644 --- a/deal.II/doc/development/cmake.html +++ b/deal.II/doc/development/cmake.html @@ -597,12 +597,12 @@

Compilers can be switched either by command line or by setting - CMAKE_(C|CXX)_COMPILER: + CMAKE_(C|CXX|Fortran)_COMPILER:
 
      CC=mpicc CXX=mpicxx cmake <...>
 
-     cmake -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" <...>
+     cmake -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" -DCMAKE_Fortran_COMPILER="mpif90" <...>
       
Please note that

- deal.II will configure sensible default CFLAGS and - CXXFLAGS depending on platform, compiler and build - target. There are two options to override this behaviour: + deal.II will configure sensible default CXXFLAGS + depending on platform, compiler and build target. There are two + options to override this behaviour:

  1. -- 2.39.5