--- /dev/null
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2016 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.
+##
+## ---------------------------------------------------------------------
+
+#
+# Usage:
+# CHECK_COMPILER_FLAGS(_compiler_flags_variable _linker_flags_variable _var)
+#
+# This macro tries to compile and link a simple "int main(){ return 0; }
+# with the given set of compiler and flags provided in
+# _compiler_flags_variable and _linker_flags_variable. If the test is
+# succesful the variable ${_var} is set to true, otherwise to false.
+#
+
+MACRO(CHECK_COMPILER_FLAGS _compiler_flags_variable _linker_flags_variable _var)
+ #
+ # Rerun this test if flags have changed:
+ #
+ IF(NOT "${${_compiler_flags_variable}}" STREQUAL "${CACHED_${_var}_${_compiler_flags_variable}}"
+ OR NOT "${${_linker_flags_variable}}" STREQUAL "${CACHED_${_var}_${_linker_flags_variable}}")
+ UNSET(${_var} CACHE)
+ ENDIF()
+
+ SET(CACHED_${_var}_${_compiler_flags_variable} "${${_compiler_flags_variable}}"
+ CACHE INTERNAL "" FORCE
+ )
+ SET(CACHED_${_var}_${_linker_flags_variable} "${${_linker_flags_variable}}"
+ CACHE INTERNAL "" FORCE
+ )
+
+ SET(CMAKE_REQUIRED_FLAGS ${${_compiler_flags_variable}})
+ SET(CMAKE_REQUIRED_LIBRARIES ${${_linker_flags_variable}})
+ CHECK_CXX_SOURCE_COMPILES("int main(){ return 0; }" ${_var})
+ RESET_CMAKE_REQUIRED()
+
+ IF(${_var})
+ SET(${_var} TRUE CACHE INTERNAL "")
+ ENDIF()
+ENDMACRO()
## ---------------------------------------------------------------------
##
-## Copyright (C) 2012 - 2015 by the deal.II authors
+## Copyright (C) 2012 - 2016 by the deal.II authors
##
## This file is part of the deal.II library.
##
# Check the user provided CXX flags:
#
-IF(NOT "${DEAL_II_CXX_FLAGS_SAVED}" STREQUAL "${CACHED_DEAL_II_CXX_FLAGS_SAVED}"
- OR NOT "${DEAL_II_LINKER_FLAGS_SAVED}" STREQUAL "${CACHED_DEAL_II_LINKER_FLAGS_SAVED}")
- # Rerun this test if cxx flags changed:
- UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
-ELSE()
- SET(DEAL_II_HAVE_USABLE_CXX_FLAGS TRUE CACHE INTERNAL "")
-ENDIF()
-SET(CACHED_DEAL_II_CXX_FLAGS_SAVED "${DEAL_II_CXX_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
-SET(CACHED_DEAL_II_LINKER_FLAGS_SAVED "${DEAL_II_LINKER_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
-
-# Initialize all CMAKE_REQUIRED_* variables a this point:
-RESET_CMAKE_REQUIRED()
-
-CHECK_CXX_SOURCE_COMPILES(
- "int main(){ return 0; }"
- DEAL_II_HAVE_USABLE_CXX_FLAGS)
-
-IF(NOT DEAL_II_HAVE_USABLE_CXX_FLAGS)
- UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
- MESSAGE(FATAL_ERROR "
-Configuration error: Cannot compile with the user supplied flags:
-CXX flags: ${DEAL_II_CXX_FLAGS_SAVED}
-LD flags: ${DEAL_II_LINKER_FLAGS_SAVED}
-Please check the CMake variables DEAL_II_CXX_FLAGS, DEAL_II_LINKER_FLAGS
-and the environment variables CXXFLAGS, LDFLAGS.\n\n"
+FOREACH(build ${DEAL_II_BUILD_TYPES})
+ SET(_cxx_flags_${build} "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}")
+ SET(_linker_flags_${build} "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}")
+
+ CHECK_COMPILER_FLAGS(_cxx_flags_${build} _linker_flags_${build}
+ DEAL_II_HAVE_USABLE_USER_FLAGS_${build}
)
-ENDIF()
+
+ IF(NOT DEAL_II_HAVE_USABLE_USER_FLAGS_${build})
+ MESSAGE(FATAL_ERROR "
+ Configuration error: Cannot compile with the user supplied flags:
+ CXX flags (${build}): ${_cxx_flags_${build}}
+ LD flags (${build}): ${_linker_flags_${build}}
+ Please check the CMake variables
+ DEAL_II_CXX_FLAGS, DEAL_II_CXX_FLAGS_${build},
+ DEAL_II_LINKER_FLAGS, DEAL_II_CXX_FLAGS_${build}
+ and the environment variables CXXFLAGS, LDFLAGS.\n\n"
+ )
+ ENDIF()
+ENDFOREACH()
########################################################################