#
# - maier, rewritten 2012
#
-LIST(APPEND CMAKE_REQUIRED_FLAGS "-Wreturn-type -Werror")
+ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wreturn-type -Werror")
CHECK_CXX_COMPILER_BUG(
"
const double foo() { return 1.; }
int main() { return 0; }
"
DEAL_II_WRETURN_TYPE_CONST_QUALIFIER_BUG)
-LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-Wreturn-type -Werror")
+STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-Wreturn-type -Werror")
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)
- LIST(APPEND CMAKE_REQUIRED_FLAGS "-Wunused-parameter -Werror")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wunused-parameter -Werror")
CHECK_CXX_COMPILER_BUG(
"
#include <mpi.h>
int main() { return 0; }
"
DEAL_II_ADVANCE_WARNING_BUG)
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-Wunused-parameter -Werror")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-Wunused-parameter -Werror")
IF(DEAL_II_ADVANCE_WARNING_BUG)
ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-parameter")
IF(DEAL_II_HAVE_CXX11_FLAG)
# Set CMAKE_REQUIRED_FLAGS for the unit tests
- LIST(APPEND CMAKE_REQUIRED_FLAGS "-std=c++0x")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-std=c++0x")
CHECK_CXX_SOURCE_COMPILES(
"
"
DEAL_II_HAVE_CXX11_SHARED_PTR)
- LIST(APPEND CMAKE_REQUIRED_FLAGS "-lpthreads")
-
CHECK_CXX_SOURCE_COMPILES(
"
#include <thread>
DEAL_II_HAVE_CXX11_THREAD)
#
- #On some systems with gcc 4.5.0, we can compile the code
- #above but it will throw an exception when run. So test
- #that as well. The test will only be successful if we have
- #libpthread available, so link it in for this test. If
- #multithreading is requested, it will be added to CXXFLAGS
- #later on so there is no need to do this here.
+ # On some systems with gcc 4.5.0, we can compile the code
+ # above but it will throw an exception when run. So test
+ # that as well. The test will only be successful if we have
+ # libpthread available, so link it in for this test. If
+ # 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")
CHECK_CXX_SOURCE_RUNS(
"
#include <thread>
int main(){ std::thread t(f,1); t.join(); return 0; }
"
DEAL_II_HAVE_CXX11_THREAD_RUN_OK)
-
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-lpthreads")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-lpthread")
CHECK_CXX_SOURCE_COMPILES(
"
ENDIF()
ENDIF()
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-std=c++0x")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-std=c++0x")
ELSE()
MESSAGE(STATUS "Insufficient C++11 support. Disabling -std=c++0x.")
#
# Check whether posix thread barriers are available:
#
- LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
CHECK_CXX_SOURCE_COMPILES(
"
#include <pthread.h>
}
"
DEAL_II_HAVE_MT_POSIX_BARRIERS)
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS)
SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE)
# switches on some preprocessor flags. If this is not the case,
# then define them explicitely.
#
- LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
CHECK_CXX_SOURCE_COMPILES(
"
#if !defined (_REENTRANT) && !defined (_THREAD_SAFE)
int main(){ return 0; }
"
DEAL_II_HAVE_SANE_MT_DEFINITIONS)
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
IF(NOT DEAL_II_HAVE_SANE_MT_DEFINITIONS)
ADD_DEFINITIONS("-D_REENTRANT" "-D_THREAD_SAFE")
# TODO: Reduce to the really necessary parts.
#
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES}")
- LIST(APPEND CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
CHECK_FUNCTION_EXISTS(daxpy_ HAVE_DAXPY_)
CHECK_FUNCTION_EXISTS(dgeevx_ HAVE_DGEEVX_)
CHECK_FUNCTION_EXISTS(dgeev_ AVE_DGEEV_)
CHECK_FUNCTION_EXISTS(ssygvx_ HAVE_SSYGVX_)
CHECK_FUNCTION_EXISTS(strtrs_ HAVE_STRTRS_)
LIST(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES}")
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
SET(HAVE_LIBLAPACK TRUE)
# Test whether that is indeed the case
#
LIST(APPEND CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIR})
- LIST(APPEND CMAKE_REQUIRED_FLAGS "-std=c++0x")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-std=c++0x")
CHECK_CXX_SOURCE_COMPILES(
"
#include <Sacado_cmath.hpp>
int main(){ return 0; }
"
TRILINOS_SUPPORTS_CPP11)
- LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "-std=c++0x")
+ STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-std=c++0x")
LIST(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIR})
IF(DEAL_II_CAN_USE_CXX11 AND NOT TRILINOS_SUPPORTS_CPP11)
#
-# A small macro used for (string-)appending flags to a variable
+# A small macro used for (string-)appending a string flags to a
+# string variable
#
# Usage:
-# ADD_FLAGS(variable flag)
+# ADD_FLAGS(variable flags)
#
-MACRO(ADD_FLAGS variable flag)
- SET(${variable} "${${variable}} ${flag}")
+MACRO(ADD_FLAGS variable flags)
+ SET(${variable} "${${variable}} ${flags}")
ENDMACRO()
#
-# Remove the first occurence of flag in the string variable.
+# Remove all occurences of "${flag}" in the string variable.
#
# Usage:
# STRIP_FLAG(variable flag)
MACRO(STRIP_FLAG variable flag)
IF(NOT "${variable}" STREQUAL "")
- STRING(REGEX REPLACE " ${flag}" "" ${variable} ${${variable}})
+ SET(${variable} " ${${variable}}")
+ STRING(REPLACE " ${flag}" "" ${variable} ${${variable}})
+ IF(NOT "${variable}" STREQUAL "")
+ STRING(STRIP ${${variable}} ${variable})
+ ENDIF()
ENDIF()
ENDMACRO()