## ---------------------------------------------------------------------
#
-# Remove -Wall and -pedantic from CMAKE_CXX_FLAGS (in directory scope) to
+# Remove -Wall and -pedantic from DEAL_II_CXX_FLAGS (in directory scope) to
# avoid some annoying warnings...
#
-STRIP_FLAG(CMAKE_CXX_FLAGS "-Wall")
-STRIP_FLAG(CMAKE_CXX_FLAGS "-pedantic")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-Wall")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-pedantic")
DEAL_II_ADD_LIBRARY(obj_functionparser OBJECT
fparser.cc
## ---------------------------------------------------------------------
#
-# Remove -Wall and -pedantic from CMAKE_CXX_FLAGS (in directory scope) to
+# Remove -Wall and -pedantic from DEAL_II_CXX_FLAGS (in directory scope) to
# avoid some annoying warnings...
#
-STRIP_FLAG(CMAKE_CXX_FLAGS "-Wall")
-STRIP_FLAG(CMAKE_CXX_FLAGS "-pedantic")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-Wall")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-pedantic")
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
INCLUDE_DIRECTORIES(
#
# *Shush!*
#
-STRIP_FLAG(CMAKE_CXX_FLAGS "-pedantic")
-STRIP_FLAG(CMAKE_CXX_FLAGS "-Wall")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-sign-compare")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-write-strings")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-pedantic")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-Wall")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-sign-compare")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-write-strings")
SET(src_umfpack_UMF
umf_2by2.cc
SET(DEAL_II_USE_CXX11 TRUE)
- ADD_FLAGS(CMAKE_CXX_FLAGS "${DEAL_II_CXX11_FLAG}")
+ ADD_FLAGS(DEAL_II_CXX_FLAGS "${DEAL_II_CXX11_FLAG}")
ELSE()
MESSAGE(STATUS "Insufficient C++11 support. Disabling ${DEAL_II_CXX11_FLAG}.")
# warnings. However, newer gccs on that platform do not have
# this flag any more, so check whether we can indeed do this
#
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-double")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-long-double")
#
# On Mac OS X, -rdynamic is accepted by the compiler (i.e.
POP_TEST_FLAG()
IF(DEAL_II_WRETURN_TYPE_CONST_QUALIFIER_BUG)
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS -Wno-return-type)
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS -Wno-return-type)
ENDIF()
#
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
CMAKE_CXX_COMPILER_VERSION MATCHES "4.4.")
- STRIP_FLAG(CMAKE_CXX_FLAGS "-pedantic")
+ STRIP_FLAG(DEAL_II_CXX_FLAGS "-pedantic")
ENDIF()
DEAL_II_TYPE_QUALIFIER_BUG)
IF(DEAL_II_TYPE_QUALIFIER_BUG)
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS -Wno-ignored-qualifiers)
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS -Wno-ignored-qualifiers)
ENDIF()
MESSAGE(STATUS
"Intel C++11 bug found, disabling C++11 support"
)
- STRIP_FLAG(CMAKE_CXX_FLAGS "${DEAL_II_CXX11_FLAG}")
+ STRIP_FLAG(DEAL_II_CXX_FLAGS "${DEAL_II_CXX11_FLAG}")
SET(DEAL_II_CAN_USE_CXX1X FALSE)
SET(DEAL_II_USE_CXX11 FALSE)
ENDIF()
MESSAGE(STATUS
"Mac OS-X C99 bug found, disabling C++11 support"
)
- STRIP_FLAG(CMAKE_CXX_FLAGS "${DEAL_II_CXX11_FLAG}")
+ STRIP_FLAG(DEAL_II_CXX_FLAGS "${DEAL_II_CXX11_FLAG}")
SET(DEAL_II_CAN_USE_CXX1X FALSE)
SET(DEAL_II_USE_CXX11 FALSE)
ENDIF()
########################################################################
#
-# Strip -Wno-deprecated from CMAKE_CXX_FLAGS so that deprecation warnings
+# Strip -Wno-deprecated from DEAL_II_CXX_FLAGS so that deprecation warnings
# are actually shown for user code:
#
-STRIP_FLAG(CMAKE_CXX_FLAGS "-Wno-deprecated")
-STRIP_FLAG(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-Wno-deprecated")
+STRIP_FLAG(DEAL_II_CXX_FLAGS "-Wno-deprecated-declarations")
#
# Populate a bunch of CONFIG_* variables with useful information:
# Set up our linker flags:
#
SET(MAKEFILE_LDFLAGS_${build}
- "${CMAKE_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}} ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
+ "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}} ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
)
ENDFOREACH()
SET(DEAL_II_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
# used for all targets:
-SET(DEAL_II_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
+SET(DEAL_II_CXX_FLAGS "@DEAL_II_CXX_FLAGS@")
# _additionally_ used for debug targets:
SET(DEAL_II_CXX_FLAGS_DEBUG "@DEAL_II_CXX_FLAGS_DEBUG@")
# compiler flags for debug and optimized mode
-CXXFLAGS.g = @CMAKE_CXX_FLAGS@ @DEAL_II_CXX_FLAGS_DEBUG@ @MAKEFILE_DEFINITIONS@ @MAKEFILE_DEFINITIONS_DEBUG@ $(INCLUDE)
-CXXFLAGS.o = @CMAKE_CXX_FLAGS@ @DEAL_II_CXX_FLAGS_RELEASE@ @MAKEFILE_DEFINITIONS@ @MAKEFILE_DEFINITIONS_RELEASE@ $(INCLUDE)
+CXXFLAGS.g = @DEAL_II_CXX_FLAGS@ @DEAL_II_CXX_FLAGS_DEBUG@ @MAKEFILE_DEFINITIONS@ @MAKEFILE_DEFINITIONS_DEBUG@ $(INCLUDE)
+CXXFLAGS.o = @DEAL_II_CXX_FLAGS@ @DEAL_II_CXX_FLAGS_RELEASE@ @MAKEFILE_DEFINITIONS@ @MAKEFILE_DEFINITIONS_RELEASE@ $(INCLUDE)
ifeq ($(enable-threads),yes)
MT = MT
#
# We have to disable a bunch of warnings:
#
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-parentheses")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-long")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-parentheses")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-long-long")
#
# Add some definitions to use the header files in debug mode:
#
# Disable a bunch of warnings caused by Trilinos headers:
#
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-extra")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-overloaded-virtual")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-extra")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-overloaded-virtual")
ENDMACRO()
#
# Disable a bunch of warnings when compiling with petsc:
#
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-long")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-long-long")
SET(DEAL_II_EXPAND_PETSC_VECTOR "PETScWrappers::Vector")
SET(DEAL_II_EXPAND_PETSC_BLOCKVECTOR "PETScWrappers::BlockVector")
#
# as well as the global (for all build types)
# DEAL_II_LINKER_FLAGS
-# CMAKE_CXX_FLAGS
+# DEAL_II_CXX_FLAGS
# DEAL_II_DEFINITIONS
#
SET_TARGET_PROPERTIES(${_library}.${_build_lowercase} PROPERTIES
LINK_FLAGS "${DEAL_II_LINKER_FLAGS};${DEAL_II_LINKER_FLAGS_${_build}}"
COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}"
- COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}"
+ COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
LINKER_LANGUAGE "CXX"
)
SET_TARGET_PROPERTIES(${_target} PROPERTIES
LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}"
- COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}"
+ COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
LINKER_LANGUAGE "CXX"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_test_short}"
)
# DEAL_II_LINKER_FLAGS
#
# - add ${feature}_CXX_FLAGS and ${feature}_COMPILE_FLAGS to
-# CMAKE_CXX_FLAGS
+# DEAL_II_CXX_FLAGS
#
# - add ${feature}_LIBRARIES to the list of deal.II libraries depending
# on general, optimized or debug keyword
# variables for compiler flags:
FOREACH(_var ${_feature}_CXX_FLAGS ${_feature}_COMPILE_FLAGS)
IF(DEFINED ${_var})
- ADD_FLAGS(CMAKE_CXX_FLAGS "${${_var}}")
+ ADD_FLAGS(DEAL_II_CXX_FLAGS "${${_var}}")
ENDIF()
ENDFOREACH()
#
MACRO(RESET_CMAKE_REQUIRED)
- SET(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS_SAVED})
+ SET(CMAKE_REQUIRED_FLAGS ${DEAL_II_CXX_FLAGS_SAVED})
SET(CMAKE_REQUIRED_INCLUDES)
SET(CMAKE_REQUIRED_LIBRARIES)
ENDMACRO()
# DEAL_II_PREFER_STATIC_LIBS
# DEAL_II_STATIC_EXECUTABLE
# CMAKE_INSTALL_RPATH_USE_LINK_PATH
-# CMAKE_CXX_FLAGS *)
-# DEAL_II_LINKER_FLAGS *)
+# DEAL_II_CXX_FLAGS *)
# DEAL_II_CXX_FLAGS_DEBUG
-# DEAL_II_LINKER_FLAGS_DEBUG
# DEAL_II_CXX_FLAGS_RELEASE
+# DEAL_II_LINKER_FLAGS *)
+# DEAL_II_LINKER_FLAGS_DEBUG
# DEAL_II_LINKER_FLAGS_RELEASE
+#
# DEAL_II_WITH_64BIT_INDICES
#
# *) May also be set via environment variable (CXXFLAGS, LDFLAGS)
# overwritten by environment)
#
+MESSAGE(STATUS "")
+MESSAGE(STATUS "Set up cached variables.")
+
########################################################################
# #
)
+
########################################################################
# #
# Compilation and linking: #
#
# Setup CMAKE_BUILD_TYPE:
#
+
SET(CMAKE_BUILD_TYPE
"DebugRelease"
CACHE STRING
"Choose the type of build, options are: Debug, Release and DebugRelease."
)
-#
# This is cruel, I know. But it is better to only have a known number of
# options for CMAKE_BUILD_TYPE...
-#
IF( NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND
NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND
NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease" )
)
ENDIF()
+#
+# Configuration behaviour:
+#
OPTION(DEAL_II_ALLOW_PLATFORM_INTROSPECTION
"Allow platform introspection for CPU command sets, SSE and AVX"
)
ENDIF()
-
-#
-# Set CMAKE_INSTALL_RPATH_USE_LINK_PATH to default to ON and promote to
-# cache so that the user can see the value.
-#
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH "ON" CACHE BOOL
"Set the rpath of the library to the external link pathes on installation"
)
#
-# Define the variable that defines whether we should use 32- or 64-bit
-# global DoF indices.
+# Translate CMake specific variables to deal.II naming:
#
-OPTION(DEAL_II_WITH_64BIT_INDICES
- "If set to ON, then use 64-bit data types to represent global degree of freedom indices. The default is to OFF. You only want to set this to ON if you will solve problems with more than 2^31 (approximately 2 billion) unknowns. If set to ON, you also need to ensure that both Trilinos and/or PETSc support 64-bit indices."
- OFF
- )
-
-#
-# Tell the user very prominently, that we're doing things differently w.r.t
-# CMAKE_(C|CXX)_FLAGS_(DEBUG|RELEASE)
-#
-FOREACH(_flag
- CXX_FLAGS_RELEASE
- CXX_FLAGS_DEBUG
- SHARED_LINKER_FLAGS_RELEASE
- SHARED_LINKER_FLAGS_DEBUG
- )
+FOREACH(_flag CXX_FLAGS CXX_FLAGS_RELEASE CXX_FLAGS_DEBUG)
IF(NOT "${CMAKE_${_flag}}" STREQUAL "")
- UNSET(${CMAKE_${_flag}} CACHE)
- MESSAGE(FATAL_ERROR
- "\nThe deal.II cmake build system does not use CMAKE_${_flag}.\n"
- "Use DEAL_II_${_flag}, instead!\n\n"
+ MESSAGE(STATUS
+ "Prepending \${CMAKE_${_flag}} to \${DEAL_II_${_flag}}"
)
+ SET(DEAL_II_${_flag} "${CMAKE_${_flag}} ${DEAL_II_${_flag}}")
ENDIF()
ENDFOREACH()
+FOREACH(_flag LINKER_FLAGS LINKER_FLAGS_DEBUG LINKER_FLAGS_RELEASE)
+ IF(NOT "${CMAKE_SHARED_${_flag}}" STREQUAL "")
+ MESSAGE(STATUS
+ "Prepending \${CMAKE_SHARED_${_flag}} to \${DEAL_II_${_flag}}"
+ )
+ SET(DEAL_II_${_flag} "${CMAKE_${_flag}} ${DEAL_II_${_flag}}")
+ ENDIF()
+ENDFOREACH()
#
-# Hide all unused compiler flag variables:
+# Hide all unused CMake variables:
#
-FOREACH(_flag
+
+SET(DEAL_II_REMOVED_FLAGS
+ CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_Fortran_FLAGS
CMAKE_Fortran_FLAGS_RELEASE
CMAKE_Fortran_FLAGS_DEBUG
CMAKE_Fortran_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
)
+FOREACH(_flag ${DEAL_II_REMOVED_FLAGS})
# Go away...
- SET(${_flag} "" CACHE INTERNAL "" FORCE)
+ SET(${_flag} ${${_flag}} CACHE INTERNAL "" FORCE)
+ # Also set it to an empty string for the configuration run so that it
+ # does not confuse the build system (to unset is not an option - it is
+ # cached...)
+ SET(${_flag} "")
ENDFOREACH()
-
#
-# Set cached compiler flags to an empty string:
+# Promote our configuration variables to cache:
#
+
SET(DEAL_II_USED_FLAGS
- CMAKE_CXX_FLAGS
+ DEAL_II_CXX_FLAGS
DEAL_II_CXX_FLAGS_DEBUG
DEAL_II_CXX_FLAGS_RELEASE
DEAL_II_LINKER_FLAGS
DEAL_II_LINKER_FLAGS_DEBUG
DEAL_II_LINKER_FLAGS_RELEASE
)
-
FOREACH(_flag ${DEAL_II_USED_FLAGS})
#
# Promote to cache:
#
SET(${_flag} "${${_flag}}" CACHE STRING
- "The user supplied cache variable will be appended _at the end_ of the auto generated ${_flag} variable"
- )
+ "The user supplied cache variable will be appended _at the end_ of the configuration step to the auto generated ${_flag} variable"
+ )
+ MARK_AS_ADVANCED(${_flag})
#
- # Save the initial (cached) variable at this point and clear it.
- # ${flags}_SAVED will be appended to ${flags} in
- # setup_finalize.cmake (called at the end of the
- # main CMakeLists.txt file).
+ # The order of compiler and linker flags is important. In order to
+ # provide an override mechanism we have to save the initial (cached)
+ # variable at this point and clear it.
+ # ${flags}_SAVED will be appended to ${flags} again in
+ # setup_finalize.cmake (called at the end of the main CMakeLists.txt
+ # file).
#
- SET(${_flag}_SAVED "${${_flag}}")
- SET(${_flag} "")
+ SET(${_flag}_SAVED ${${_flag}})
+ SET(${_flag})
+ENDFOREACH()
+FOREACH(_variable
+ DEAL_II_DEFINITIONS
+ DEAL_II_DEFINITIONS_DEBUG
+ DEAL_II_DEFINITIONS_RELEASE
+ )
#
- # Mark these flags as advanced.
+ # Promote to cache:
#
- MARK_AS_ADVANCED(${_flag})
+ SET(${_variable} ${${_variable}} CACHE STRING
+ "Additional, user supplied compile definitions"
+ )
+ MARK_AS_ADVANCED(${_variable})
ENDFOREACH()
# Finally, read in CXXFLAGS and LDFLAGS from environment and prepend them
# to the saved variables:
#
+
SET(CMAKE_CXX_FLAGS_SAVED "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_SAVED}")
SET(DEAL_II_LINKER_FLAGS_SAVED "$ENV{LDFLAGS} ${DEAL_II_LINKER_FLAGS_SAVED}")
UNSET(ENV{CXXFLAGS})
UNSET(ENV{LDFLAGS})
+
+
+########################################################################
+# #
+# Components: #
+# #
+########################################################################
+
#
-# Also respect DEAL_II_CXX_FLAGS - it just too easy to accientally write
-# DEAL_II_CXX_FLAGS instead of CMAKE_CXX_FLAGS... (this was a poor design
-# choice, I know...)
+# Configuration option for the 64 bit indices component:
#
-IF(NOT "${DEAL_II_CXX_FLAGS}" STREQUAL "")
- MESSAGE(STATUS
- "Appending \${DEAL_II_CXX_FLAGS} to saved \${CMAKE_CXX_FLAGS}"
- )
- SET(CMAKE_CXX_FLAGS_SAVED "${CMAKE_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS}")
-ENDIF()
+
+OPTION(DEAL_II_WITH_64BIT_INDICES
+ "If set to ON, then use 64-bit data types to represent global degree of freedom indices. The default is to OFF. You only want to set this to ON if you will solve problems with more than 2^31 (approximately 2 billion) unknowns. If set to ON, you also need to ensure that both Trilinos and/or PETSc support 64-bit indices."
+ OFF
+ )
)
ENDIF()
+#
+# Miscellaneous renaming:
+#
GET_CMAKE_PROPERTY(_res VARIABLES)
FOREACH(_var ${_res})
# All configuration in setup_compiler_flags.cmake and
# setup_compiler_flags_<compiler>.cmake shall ONLY modify:
#
-# CMAKE_CXX_FLAGS
+# DEAL_II_CXX_FLAGS
# DEAL_II_CXX_FLAGS_DEBUG
# DEAL_II_CXX_FLAGS_RELEASE
# DEAL_II_LINKER_FLAGS
# All modifications shall be guarded with the ENABLE_IF_SUPPORTED
# or ENABLE_IF_LINKS macro, e.g.
#
-# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
+# ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
# ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
#
# Checks for compiler features (such as C++11 support) and compiler
# Check the user provided CXX flags:
#
-MESSAGE(STATUS "")
-IF(NOT "${CMAKE_CXX_FLAGS_SAVED}" STREQUAL "${CACHED_CMAKE_CXX_FLAGS_SAVED}")
+IF(NOT "${DEAL_II_CXX_FLAGS_SAVED}" STREQUAL "${CACHED_DEAL_II_CXX_FLAGS_SAVED}")
+ MESSAGE(STATUS "")
# Rerun this test if cxx flags changed:
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
ENDIF()
-SET(CACHED_CMAKE_CXX_FLAGS_SAVED "${CMAKE_CXX_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
+SET(CACHED_DEAL_II_CXX_FLAGS_SAVED "${DEAL_II_CXX_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
# Initialize all CMAKE_REQUIRED_* variables a this point:
RESET_CMAKE_REQUIRED()
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
MESSAGE(FATAL_ERROR "\n"
"Configuration error: Cannot compile with the user supplied CXX flags:\n"
- "${CMAKE_CXX_FLAGS_SAVED}\n"
- "Please check the CMake variable CMAKE_CXX_FLAGS and the\n"
+ "${DEAL_II_CXX_FLAGS_SAVED}\n"
+ "Please check the CMake variable DEAL_II_CXX_FLAGS and the\n"
"environment variable CXXFLAGS\n\n"
)
ENDIF()
#
IF(NOT (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.4"))
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-pedantic")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-pedantic")
ENDIF()
#
# Set the pic flag.
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
#
# Check whether the -as-needed flag is available. If so set it to link
#
# Setup various warnings:
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wall")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wpointer-arith")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wwrite-strings")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wsynth")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wsign-compare")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wswitch")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wall")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wpointer-arith")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wwrite-strings")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wsynth")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wsign-compare")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wswitch")
#
# Newer versions of gcc have a flag -Wunused-local-typedefs that, though in
# Unfortunately, this warning is included in -W/-Wall, so disable it if the
# compiler supports it.
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-local-typedefs")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-local-typedefs")
#
# Disable Wlong-long that will trigger a lot of warnings when compiling
# with disabled C++11 support:
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-long")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-long-long")
#
# Disable deprecation warnings
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-deprecated")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-deprecated")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-deprecated-declarations")
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#
# Silence Clang warnings about unused parameters:
#
- SET(CMAKE_CXX_FLAGS "-Qunused-arguments ${CMAKE_CXX_FLAGS}")
+ SET(DEAL_II_CXX_FLAGS "-Qunused-arguments ${DEAL_II_CXX_FLAGS}")
#
# *Boy*, clang seems to be the very definition of "pedantic" in
# (that are mainly triggered in third party headers so that we cannot
# easily fix them...)
#
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-dangling-else")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-delete-non-virtual-dtor") # not harmless but needed for boost <1.50.0
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-long")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-newline-eof")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-function")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-private-field")
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-variable")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-dangling-else")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-delete-non-virtual-dtor") # not harmless but needed for boost <1.50.0
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-long-long")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-newline-eof")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-function")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-private-field")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-variable")
ENDIF()
#
# Set the pic flag.
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
#
# Check whether the -as-needed flag is available. If so set it to link
#
# Set ansi mode:
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-ansi")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-ansi")
#
# Enable verbose warnings:
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-w2")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-w2")
#
# Disable some warnings that lead to a lot of false positives:
# -w1572 floating-point equality and inequality comparisons are unreliable
# -w2536 type qualifiers are meaningless here
#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd68")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd135")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd175")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd177")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd279")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd327")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd383")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd981")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd1418")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd1478")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd1572")
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd2536")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd68")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd135")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd175")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd177")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd279")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd327")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd383")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd981")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd1418")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd1478")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd1572")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-wd2536")
IF(DEAL_II_STATIC_EXECUTABLE)
########################
# enable exception handling:
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "/EHsc")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/EHsc")
#enable warnings:
-ADD_FLAGS(CMAKE_CXX_FLAGS "/W3")
+ADD_FLAGS(DEAL_II_CXX_FLAGS "/W3")
# Globally disable some legacy min and max macros that cause problems:
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "/NOMINMAX")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/NOMINMAX")
#############################
# #
STRING(STRIP "${${_flags}} ${${_flags}_SAVED}" ${_flags})
ENDFOREACH()
+#
+# Sanity check: The variables defined in DEAL_II_REMOVED_FLAGS must not be
+# used during the comfiguration stage:
+#
+FOREACH(_flag ${DEAL_II_REMOVED_FLAGS})
+ IF(NOT "${_flag}" STREQUAL "")
+ MESSAGE(FATAL_ERROR
+ "\nInternal configuration error: The variable ${_flag} was set to a "
+ "non empty value during the configuration! (The corresponding "
+ "DEAL_II_* variable should have been used.)\n"
+ "${_flag}=\"${${_flag}}\"\n"
+ )
+ ENDIF()
+ENDFOREACH()
+
#
# Deduplicate entries in DEAL_II_USER_INCLUDE_DIRS
#
_detailed(
"# Compiler flags used for this build:
-# CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}
+# DEAL_II_CXX_FLAGS: ${DEAL_II_CXX_FLAGS}
"
)
IF(CMAKE_BUILD_TYPE MATCHES "Release")
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
_detailed("# DEAL_II_CXX_FLAGS_DEBUG: ${DEAL_II_CXX_FLAGS_DEBUG}\n")
ENDIF()
+
_detailed("# DEAL_II_LINKER_FLAGS: ${DEAL_II_LINKER_FLAGS}\n")
IF(CMAKE_BUILD_TYPE MATCHES "Release")
_detailed("# DEAL_II_LINKER_FLAGS_RELEASE: ${DEAL_II_LINKER_FLAGS_RELEASE}\n")
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
_detailed("# DEAL_II_LINKER_FLAGS_DEBUG: ${DEAL_II_LINKER_FLAGS_DEBUG}\n")
ENDIF()
+
+_detailed("# DEAL_II_DEFINITIONS: ${DEAL_II_DEFINITIONS}\n")
+IF(CMAKE_BUILD_TYPE MATCHES "Release")
+ _detailed("# DEAL_II_DEFINITIONS_RELEASE: ${DEAL_II_DEFINITIONS_RELEASE}\n")
+ENDIF()
+IF(CMAKE_BUILD_TYPE MATCHES "Debug")
+ _detailed("# DEAL_II_DEFINITIONS_DEBUG: ${DEAL_II_DEFINITIONS_DEBUG}\n")
+ENDIF()
+
_detailed("#\n")
IF(NOT DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS)
# All configuration in setup_compiler_flags.cmake and
# setup_compiler_flags_<compiler>.cmake shall ONLY modify:
#
-# CMAKE_CXX_FLAGS
+# DEAL_II_CXX_FLAGS
# DEAL_II_CXX_FLAGS_DEBUG
# DEAL_II_CXX_FLAGS_RELEASE
# DEAL_II_LINKER_FLAGS
# All modifications shall be guarded with the ENABLE_IF_SUPPORTED
# or ENABLE_IF_LINKS macro, e.g.
#
-# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
+# ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
# ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
#
# Compiler flags for platform dependent optimization (such as
# DEAL_II_ALLOW_PLATFORM_INTROSPECTION:
#
# IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
-# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-march=native")
+# ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-march=native")
# ENDIF()
#
# Checks for compiler features (such as C++11 support) and compiler
For internal use, for setting necessary compiler flags, e.g.
<code>-std=c++11</code> (if available):
<ul>
- <li> <code>CMAKE_CXX_FLAGS</code>
+ <li> <code>DEAL_II_CXX_FLAGS</code>
<li> <code>DEAL_II_CXX_FLAGS_DEBUG</code>
<li> <code>DEAL_II_CXX_FLAGS_RELEASE</code>
</ul>
<code>-DDEAL_II_SETUP_DEFAULT_COMPILER_FLAGS=OFF</code> and set all
necessary compiler flags by hand via
<pre>
-CMAKE_CXX_FLAGS - used during all builds
+DEAL_II_CXX_FLAGS - used during all builds
DEAL_II_CXX_FLAGS_DEBUG - additional flags for the debug library
DEAL_II_CXX_FLAGS_RELEASE - additional flags for the release library
</pre>
# "Fortran Compiler."
# )
#
-# SET(CMAKE_CXX_FLAGS "" CACHE STRING
+# SET(DEAL_II_CXX_FLAGS "" CACHE STRING
# "The user supplied cache variable will be appended _at the end_ of the auto generated CMAKE_CXX_FLAGS variable"
# )
#
# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_LINKER_FLAGS_RELEASE variable"
# )
#
+# SET(DEAL_II_DEFINITIONS "" CACHE STRING
+# "Additional, user supplied compile definitions"
+# )
+#
+# SET(DEAL_II_DEFINITIONS_DEBUG "" CACHE STRING
+# "Additional, user supplied compile definitions"
+# )
+#
+# SET(DEAL_II_DEFINITIONS_RELEASE "" CACHE STRING
+# "Additional, user supplied compile definitions"
+# )
+#
# SET(BUILD_SHARED_LIBS "ON" CACHE BOOL
# "Build a shared library"
# )
Override the default configuration by setting the following
cached variables:
<pre class="cmake">
-CMAKE_CXX_FLAGS - used during all builds
+DEAL_II_CXX_FLAGS - used during all builds
DEAL_II_CXX_FLAGS_DEBUG - additional flags for the debug library
DEAL_II_CXX_FLAGS_RELEASE - additional flags for the release library
</pre>
<code>-Wsign-compare</code>, set by the build system, can be
overwritten by specifying:
<pre class="cmake">
-cmake -DCMAKE_CXX_FLAGS="-Wno-sign-compare" <...>
+cmake -DDEAL_II_CXX_FLAGS="-Wno-sign-compare" <...>
</pre>
<li>
<p>
Furthermore, this macro sets the C++ compiler and the compile flags to
default values (the same values that were used to compile deal.II itself).
-These are <code>CMAKE_CXX_COMPILER</code> and <code>CMAKE_CXX_FLAGS</code>,
+These are <code>CMAKE_CXX_COMPILER</code> and <code>DEAL_II_CXX_FLAGS</code>,
as well as - depending on the configuration -
-<code>DEAL_II_FLAGS_DEBUG</code>, or <code>DEAL_II_FLAGS_RELEASE</code>, or
+<code>DEAL_II_CXX_FLAGS_DEBUG</code>, or <code>DEAL_II_CXX_FLAGS_RELEASE</code>, or
both.
</p>