#
# - maier, rewritten 2012
#
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wreturn-type -Werror")
+PUSH_TEST_FLAG("-Wreturn-type")
+PUSH_TEST_FLAG("-Werror")
CHECK_CXX_COMPILER_BUG(
"
const double foo() { return 1.; }
int main() { return 0; }
"
DEAL_II_WRETURN_TYPE_CONST_QUALIFIER_BUG)
-STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-Wreturn-type -Werror")
+POP_TEST_FLAG()
+POP_TEST_FLAG()
IF(DEAL_II_WRETURN_TYPE_CONST_QUALIFIER_BUG)
ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS -Wno-return-type)
CHECK_INCLUDE_FILE_CXX("mpi.h" HAVE_MPI_H)
IF(HAVE_MPI_H)
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wunused-parameter -Werror")
+ PUSH_TEST_FLAG("-Wunused-parameter")
+ PUSH_TEST_FLAG("-Werror")
CHECK_CXX_COMPILER_BUG(
"
#include <mpi.h>
int main() { return 0; }
"
DEAL_II_ADVANCE_WARNING_BUG)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-Wunused-parameter -Werror")
+ POP_TEST_FLAG()
+ POP_TEST_FLAG()
IF(DEAL_II_ADVANCE_WARNING_BUG)
ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-parameter")
# ...and then verify whether it actually errors out if
# -Werror is given
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+PUSH_TEST_FLAG("-Werror")
CHECK_CXX_SOURCE_COMPILES(
"
int old_fn () __attribute__((deprecated));
int main () {}
"
DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED_WARNING)
-STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-Werror")
+POP_TEST_FLAG()
IF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
AND
MESSAGE(STATUS "Compiler does not support the deprecated attribute")
SET(DEAL_II_DEPRECATED " ")
ENDIF()
+
#
FOREACH(test_flag
"-std=c++11"
- "-std=c++-x"
+ "-std=c++0x"
)
- SET(DEAL_II_CXX11_FLAG ${test_flag})
+
CHECK_CXX_COMPILER_FLAG("${test_flag}" DEAL_II_HAVE_CXX11_FLAG)
+
IF(DEAL_II_HAVE_CXX11_FLAG)
+ # We have found a CXX11_FLAG that the compiler understands
+ SET(DEAL_II_CXX11_FLAG "${test_flag}")
BREAK()
+ ELSE()
+ # Remove test result from cache and try the next flag in the list
+ UNSET(DEAL_II_HAVE_CXX11_FLAG CACHE)
ENDIF()
+
ENDFOREACH()
+
IF(DEAL_II_HAVE_CXX11_FLAG)
# Set CMAKE_REQUIRED_FLAGS for the unit tests
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX11_FLAG}")
+ PUSH_TEST_FLAG("${DEAL_II_CXX11_FLAG}")
CHECK_CXX_SOURCE_COMPILES(
"
# multithreading is requested, it will be added to CXXFLAGS
# later on so there is no need to do this here.
#
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-lpthread")
+ PUSH_TEST_FLAG("-lpthread")
CHECK_CXX_SOURCE_RUNS(
"
#include <thread>
int main(){ std::thread t(f,1); t.join(); return 0; }
"
DEAL_II_HAVE_CXX11_THREAD_RUN_OK)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-lpthread")
+ POP_TEST_FLAG()
CHECK_CXX_SOURCE_COMPILES(
"
ELSE()
MESSAGE(STATUS "Insufficient C++11 support. Disabling ${DEAL_II_CXX11_FLAG}.")
+
ENDIF()
+
IF(DEAL_II_CAN_USE_CXX11)
#
# Also test for a couple of C++11 things that we don't use in the
# library but that users may want to use in their applications and that
# we might want to test in the testsuite
#
+ # TODO: Actually we have to export the test results somehow. :-]
+ #
CHECK_CXX_SOURCE_COMPILES(
"
ENDIF()
ENDIF()
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX11_FLAG}")
+ POP_TEST_FLAG()
ELSE()
MESSAGE(STATUS "Insufficient C++11 support. Disabling ${DEAL_II_CXX11_FLAG}.")
# Test whether that is indeed the case
#
LIST(APPEND CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX11_FLAG}")
+ PUSH_TEST_FLAG("${DEAL_II_CXX11_FLAG}")
CHECK_CXX_SOURCE_COMPILES(
"
#include <Sacado_cmath.hpp>
#
# Try whether exporting HAS_C99_TR1_CMATH helps:
#
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-DHAS_C99_TR1_CMATH")
+ PUSH_TEST_FLAG("-DHAS_C99_TR1_CMATH")
CHECK_CXX_SOURCE_COMPILES(
"
#include <Sacado_cmath.hpp>
int main(){ return 0; }
"
TRILINOS_HAS_C99_TR1_WORKAROUND)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-DHAS_C99_TR1_CMATH")
+ POP_TEST_FLAG()
IF(TRILINOS_HAS_C99_TR1_WORKAROUND)
LIST(APPEND DEAL_II_DEFINITIONS "HAS_C99_TR1_CMATH")
SET(${var} FALSE)
ENDIF()
ENDIF()
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX11_FLAG")
+ POP_TEST_FLAG()
LIST(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
#
# POP_TEST_FLAG()
#
-MACRO(ADD_TEST_FLAG flag)
+MACRO(POP_TEST_FLAG)
SET(CMAKE_REQUIRED_FLAGS " ${CMAKE_REQUIRED_FLAGS}")
- STRING(REGEX_REPLACE " -[^ ]+$" ""
+ STRING(REGEX REPLACE " -[^ ]+$" ""
CMAKE_REQUIRED_FLAGS
"${CMAKE_REQUIRED_FLAGS}"
)
# PUSH_TEST_FLAG("flag")
#
-MACRO(ADD_TEST_FLAG flag)
+MACRO(PUSH_TEST_FLAG flag)
+
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
STRING(STRIP "${CMAKE_REQUIRED_FLAGS}" CMAKE_REQUIRED_FLAGS)
+
ENDMACRO()