IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
-
- #
- # These tests depend on certain cpu instruction sets being enabled, so
- # use the user supplied compiler flags for the tests as well:
- #
- SET(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_SAVED}")
-
-
#
# Take care that the following tests are rerun if CMAKE_REQUIRED_FLAGS
# changes..
}
"
DEAL_II_HAVE_AVX)
-
- SET(CMAKE_REQUIRED_FLAGS "")
ENDIF()
+
IF(DEAL_II_HAVE_SSE2)
IF(DEAL_II_HAVE_AVX)
SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 2)
ELSE()
SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
ENDIF()
-
MARK_AS_ADVANCED(m_LIBRARY)
IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
- SET(CMAKE_REQUIRED_LIBRARIES ${m_LIBRARY})
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${m_LIBRARY})
CHECK_CXX_SYMBOL_EXISTS("jn" "math.h" HAVE_JN)
- SET(CMAKE_REQUIRED_LIBRARIES)
+ RESET_CMAKE_REQUIRED()
IF(HAVE_JN)
LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_LIBRARY})
ENDIF()
)
MACRO(CHECK_FOR_LAPACK_FUNCTIONS)
- SET(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
#
# Push -pthread as well:
ENDFOREACH()
ENDIF()
- SET(CMAKE_REQUIRED_LIBRARIES)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-pthread")
+ RESET_CMAKE_REQUIRED()
ENDMACRO()
}
"
DEAL_II_HAVE_MT_POSIX_BARRIERS)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ RESET_CMAKE_REQUIRED()
IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS)
SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE)
ENDIF()
# Test whether that is indeed the case
#
IF(${var})
- SET(CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
+ LIST(APPEND CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
PUSH_TEST_FLAG("${DEAL_II_CXX11_FLAG}")
CHECK_CXX_SOURCE_COMPILES(
ENDIF()
ENDIF()
- POP_TEST_FLAG()
- SET(CMAKE_REQUIRED_INCLUDES)
+ RESET_CMAKE_REQUIRED()
#
# Remove the following variables from the cache to force a recheck:
STRING(REPLACE "," "" _flag_name "${_flag_name}")
STRING(REPLACE "--" "__" _flag_name "${_flag_name}")
SET(_backup ${CMAKE_REQUIRED_LIBRARIES})
- SET(CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
CHECK_CXX_COMPILER_FLAG(
""
DEAL_II_HAVE_FLAG_${_flag_name}
--- /dev/null
+## ---------------------------------------------------------------------
+## $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.
+##
+## ---------------------------------------------------------------------
+
+#
+# A small macro to reset the CMAKE_REQUIRED_* variables to its default
+# values
+#
+# Usage:
+# RESET_CMAKE_REQUIRED_FLAGS
+#
+
+MACRO(RESET_CMAKE_REQUIRED)
+ SET(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS_SAVED})
+ SET(CMAKE_REQUIRED_INCLUDES)
+ SET(CMAKE_REQUIRED_LIBRARIES)
+ENDMACRO()
+
#
# Check the user provided CXX flags:
#
+
MESSAGE(STATUS "")
IF(NOT "${CMAKE_CXX_FLAGS_SAVED}" STREQUAL "${DEAL_II_CXX_FLAGS_SAVED}")
+ # Rerun this test if cxx flags changed:
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
ENDIF()
SET(DEAL_II_CXX_FLAGS_SAVED "${CMAKE_CXX_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
-SET(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_SAVED}")
+# 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)
-SET(CMAKE_REQUIRED_FLAGS "")
IF(NOT DEAL_II_HAVE_USABLE_CXX_FLAGS)
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
MESSAGE(FATAL_ERROR "\n"
- "Configuration error: Cannot compile with the specified CXX flags: "
+ "Configuration error: Cannot compile with the user supplied CXX flags:\n"
"${CMAKE_CXX_FLAGS_SAVED}\n"
)
ENDIF()
POP_TEST_FLAG()
</pre>
- <li> Libraries necessary for linkage can be set in the list variable
- <code>CMAKE_REQUIRED_LIBRARIES</code>. It is best two hard set
- this variable to a specific value and later on cleaning it,
- instead of appending/removing:
+ <li> Necessary include directories and libraries necessary for
+ linkage can be set in the list variables
+ <code>CMAKE_REQUIRED_INCLUDES</code> and
+ <code>CMAKE_REQUIRED_LIBRARIES</code>. It is best ot append these
+ lists and later on reset <code>CMAKE_REQUIRED_*</code> (including
+ <code>CMAKE_REQUIRED_FLAGS</code>) to their default values:
<pre>
- SET(CMAKE_REQUIRED_LIBRARIES <a list of libraries>
+ LIST(APPEND CMAKE_REQUIRED_INCLUDES <a list of includes>)
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES <a list of libraries>)
CHECK_CXX_SOURCE_COMPILES(...)
- SET(CMAKE_REQUIRED_LIBRARIES)
+ RESET_CMAKE_REQUIRED()
</pre>
</ul>
</p>