packages, so to ensure that only external libraries are used
DEAL_II_ALLOW_CONTRIB as well as all DEAL_II_FORCE_CONTRIB_* have to be
OFF"
- OFF)
+ ON)
OPTION(DEAL_II_WITH_ARPACK
"Build deal.II with support for ARPACK."
OPTION(DEAL_II_WITH_BLAS
"Build deal.II with support for BLAS."
- OFF)
+ ON)
OPTION(DEAL_II_WITH_FUNCTIONPARSER
"Build deal.II with support for functionparser."
- OFF)
+ ON)
OPTION(DEAL_II_FORCE_CONTRIB_FUNCTIONPARSER
"Always use the bundled functionparser library instead of an external one."
- OFF)
+ ON)
OPTION(DEAL_II_WITH_LAPACK
"Build deal.II with support for LAPACK."
- OFF)
+ ON)
OPTION(DEAL_II_WITH_METIS
"Build deal.II with support for Metis."
OPTION(DEAL_II_WITH_TBB
"Build deal.II with support for tbb. This will enable thread support in deal.II."
- OFF)
+ ON)
OPTION(DEAL_II_FORCE_CONTRIB_TBB
"Always use the bundled tbb library instead of an external one."
- OFF)
+ ON)
OPTION(DEAL_II_WITH_TRILINOS
"Build deal.II with support for trilinos."
OPTION(DEAL_II_FORCE_CONTRIB_BOOST
"Always use the bundled boost library instead of an external one."
- OFF)
+ ON)
# configure the cached, user editable CMAKE_BUILD_TYPES, CMAKE_CXX_FLAGS,
# etc. variables at this point:
#
-INCLUDE(setup_cached_variables)
+INCLUDE(setup_cached_compiler_flags)
#
-# Now, set the project and configure some deal_II specific variables:
+# Now, set the project and setup the rest:
#
PROJECT(deal.II)
+
INCLUDE(setup_deal_ii)
+INCLUDE(setup_compiler_flags)
+
#
# ####################
#
# for setting necessary linker flags for the deal.II library.
#
-# CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (uncached)
+# CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (<...>_RELEASE, <...>_DEBUG)
#
# for setting necessary compiler flags, e.g. -std=c++11 (if available).
-# Note: Uncached variables are not visible to the user, and cannot be
-# altered.
#
ADD_CUSTOM_TARGET(deal_ii_target_dependencies)
#
ENDFOREACH()
+#
+# Finalize the configuration:
+#
+INCLUDE(setup_finalize)
+
+
###########################################################################
ADD_SUBDIRECTORY(source)
-MESSAGE(STATUS "Configured features:")
-GET_CMAKE_PROPERTY(res VARIABLES)
-FOREACH(var ${res})
- IF(var MATCHES "DEAL_II_WITH")
- MESSAGE(STATUS "${var} : ${${var}}")
- ENDIF()
-ENDFOREACH()
int main() { return 0; }
"
DEAL_II_EXPLICIT_DESTRUCTOR_BUG)
+
+
+#
+# TODO:
+# On Cygwin, when using shared libraries, there might occur
+# difficulties when linking libraries for several dimensions,
+# as some symbols are defined in all of them. This leads to a
+# linker error. We force the linker to ignore multiple symbols,
+# but of course this might lead to strange program behaviour if
+# you accidentally defined one symbol multiple times...
+# (added 2005/07/13, Ralf B. Schulz)
+# (modified 2005/12/20, Ralf B. Schulz)
+#
+
+# CXXFLAGSPIC=
+# LDFLAGS="$LDFLAGS -Xlinker --allow-multiple-definition"
+# SHLIBFLAGS="$SHLIBFLAGS -Xlinker --allow-multiple-definition"
+# ;;
+#
+# *)
+# CXXFLAGSPIC="-fPIC"
+# LDFLAGSPIC="-fPIC"
+# ;;
+# esac
+
+
+
-#
-# Check whether the -as-needed flag is available. If so set it to compile
-# the deal.II library
-#
-CHECK_CXX_COMPILER_FLAG(
- "-Wl,-as-needed"
- DEAL_II_COMPILER_HAS_AS_NEEDED)
-
-IF(DEAL_II_COMPILER_HAS_AS_NEEDED)
- SET(CMAKE_SHARED_LINKER_FLAGS
- "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-as-needed"
- )
-ENDIF()
-
-
-
#
# Check for minimal vector capacity
#
SET(DEAL_II_CAN_USE_CXX1X TRUE) # TODO
SET(DEAL_II_CAN_USE_CXX11 TRUE)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") # TODO
+ ADD_FLAGS(CMAKE_CXX_FLAGS "-std=c++0x")
ELSE()
MACRO(FEATURE_MPI_CONFIGURE_EXTERNAL var)
INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH})
- SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
- # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
+ ADD_FLAGS(CMAKE_CXX_FLAGS "${MPI_CXX_COMPILE_FLAGS}")
+ ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
LIST(APPEND deal_ii_external_libraries ${MPI_CXX_LIBRARIES})
SET(DEAL_II_COMPILER_SUPPORTS_MPI TRUE)
# We support threading. Go on and configure the rest:
#
- SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
+ ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
SET(DEAL_II_USE_MT TRUE)
# and if successfull return TRUE:
SETUP_THREADING(${var})
+ # We have to disable a bunch of warnings:
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wno-long-long")
+
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/contrib/tbb/tbb30_104oss/include
)
LIST(APPEND deal_ii_additional_object_files
$<TARGET_OBJECTS:obj_tbb>
)
+
+
ENDMACRO()
MACRO(FEATURE_BLAS_CONFIGURE_EXTERNAL var)
- SET(CMAKE_SHARED_LINKER_FLAGS
- "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
- )
+ ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
LIST(APPEND deal_ii_external_libraries
${BLAS_LIBRARIES}
# library:
ADD_DEFINITIONS("-DBOOST_NO_HASH" "-DBOOST_NO_SLIST")
+ #
+ # Newer versions have a flag -Wunused-local-typedefs that, though in principle
+ # a good idea, triggers a lot in BOOST in various places. Unfortunately,
+ # this warning is included in -W/-Wall, so disable it if the compiler
+ # supports it.
+ #
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wno-unused-local-typedefs")
+
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/contrib/boost-1.49.0/include
)
MACRO(FEATURE_LAPACK_CONFIGURE_EXTERNAL var)
- SET(CMAKE_SHARED_LINKER_FLAGS
- "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}"
- )
+ ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}")
LIST(APPEND deal_ii_external_libraries
${LAPACK_LIBRARIES}
# else and we better disable some of the warnings to enable us
# to see through the clutter.
#
- CHECK_CXX_COMPILER_FLAG(
- "-Wno-unused"
- DEAL_II_HAVE_WNO_UNUSED_FLAG
- )
- IF(DEAL_II_HAVE_WNO_UNUSED_FLAG)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused")
- ENDIF()
-
- CHECK_CXX_COMPILER_FLAG(
- "-Wno-overloaded-virtual"
- DEAL_II_HAVE_WNO_OVERLOADED_VIRTUAL_FLAG
- )
- IF(DEAL_II_HAVE_WNO_OVERLOADED_VIRTUAL_FLAG)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
- ENDIF()
-
- CHECK_CXX_COMPILER_FLAG(
- "-Wno-extra"
- DEAL_II_HAVE_WNO_EXTRA_FLAG
- )
- IF(DEAL_II_HAVE_WNO_EXTRA_FLAG)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extra")
- ENDIF()
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wno-unused")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wno-extra")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wno-overloaded-virtual")
SET(${var} TRUE)
--- /dev/null
+MACRO(ADD_FLAGS variable flag)
+ SET(${variable} "${${variable}} ${flag}")
+ENDMACRO()
--- /dev/null
+MACRO(ENABLE_IF_AVAILABLE variable flag)
+ CHECK_CXX_COMPILER_FLAG(
+ "${flag}"
+ DEAL_II_HAVE_FLAG_${flag})
+ IF(DEAL_II_HAVE_FLAG_${flag})
+ SET(${variable} "${${variable}} ${flag}")
+ ENDIF()
+ENDMACRO()
--- /dev/null
+#
+# FAT NOTE:
+#
+# We have a problem: We would like to setup our choice of C_FLAGS and
+# CXX_FLAGS but let the user overwrite it (if desired).
+#
+# Unfortunately this is not as easy as it sounds:
+#
+# We have to call PROJECT(deal.II) in order to set up the project and run
+# the C- and CXX-compiler detection and configuration. (Otherwise we cannot
+# compile anything and have no idea which compiler is selected.) In this
+# process CMAKE_{C|CXX}_FLAGS are already set to stupid default values.
+# (And _cannot_ be sanely set from this script afterwards...)
+#
+# To mitigate this problem, we do the following: We set cached
+# CMAKE_{C|CXX}_FLAGS variables with empty strings prior to initializing
+# the compiler, so that no default values are set.
+#
+# The compiler-flag setup in setup_compiler_flags.cmake later adds our
+# (target and platform dependend) default choice of flags.
+#
+# We add the cached variables _to the end_ of this default choice to allow
+# the user to overwrite our choice of compiler flags.
+#
+
+
+#
+# Setup CMAKE_BUILD_TYPE:
+#
+
+SET(CMAKE_BUILD_TYPE
+ "Release"
+ CACHE STRING
+ "Choose the type of build, options are: Debug Release.")
+
+IF( NOT CMAKE_BUILD_TYPE MATCHES "Release" AND
+ NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
+
+ MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE does neither match Release, nor Debug.")
+
+ENDIF()
+
+
+#
+# Set cached compiler flags to an empty string:
+#
+
+SET(deal_ii_used_flags
+ CMAKE_C_FLAGS
+ CMAKE_CXX_FLAGS
+ CMAKE_C_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_FLAGS_DEBUG
+ CMAKE_CXX_FLAGS_DEBUG
+ )
+
+FOREACH(flags ${deal_ii_used_flags})
+ SET(${flags} "" CACHE STRING
+ "The user supplied cache variable will be appended _at the end_ of the auto generated ${flags} variable"
+ )
+
+ #
+ # Save the cached variable at this point and clear it.
+ # ${flags}_SAVED will be appended to ${flags} in
+ # setup_cached_compiler_flags_finalize.cmake (called at the end of the
+ # main CMakeLists.txt file).
+ #
+ SET(${flags}_SAVED "${${flags}}")
+ SET(${flags} "")
+ENDFOREACH()
+++ /dev/null
-#
-# FAT NOTE:
-#
-# We set up the default compiler configuration, i.e. CMAKE_BUILD_TYPE,
-# CMAKE_C_FLAGS, CMAKE_CXX_FLAGS as CACHED variables, so that the user can
-# actually see and change them.
-#
-# Beware of the fact that compiler flags set later in the configuration via
-# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} <...>" are UNCACHED variables.
-#
-# cmake later concatenates cached and uncached variables together. So for a
-# release build we will end up with (more or less) something like the
-# following:
-#
-# $ <compiler> <cached CMAKE_CXX_FLAGS> <uncached CMAKE_CXX_FLAGS> \
-# <cached CMAKE_CXX_FLAGS_RELEASE> <uncached CMAKE_CXX_FLAGS_RELEASE>\
-# <Definitions> <...> <...>.c -o <...>.o
-#
-
-
-#
-# Setup CMAKE_BUILD_TYPE:
-#
-
-SET(CMAKE_BUILD_TYPE
- "Release"
- CACHE STRING
- "Choose the type of build, options are: Debug Release.")
-
-IF( NOT CMAKE_BUILD_TYPE MATCHES "Release" AND
- NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
-
- MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE does neither match Release, nor Debug.")
-
-ENDIF()
-
-
-#
-# Setup default compiler flags:
-#
-
-# TODO: Copy the CFLAGS and CXXFLAGS logic from the former build system
-
-SET(CMAKE_C_FLAGS
- "-Wfatal-errors -D_REENTRANT -fPIC -O2 -march=native"
- CACHE STRING
- "Flags used by the compiler during all build types.")
-
-SET(CMAKE_CXX_FLAGS
- "-Wfatal-errors -D_REENTRANT -fPIC -O2 -march=native"
- CACHE STRING
- "Flags used by the compiler during all build types.")
-
-
-SET(CMAKE_C_FLAGS_RELEASE
- "-O2"
- CACHE STRING
- "Flags used by the compiler during all release builds.")
-SET(CMAKE_CXX_FLAGS_RELEASE
- "-O2"
- CACHE STRING
- "Flags used by the compiler during all release builds.")
-
-
-SET(CMAKE_C_FLAGS_DEBUG
- "-O0 -ggdb -DDEBUG"
- CACHE STRING
- "Flags used by the compiler during all debug builds.")
-SET(CMAKE_CXX_FLAGS_DEBUG
- "-O0 -ggdb -DDEBUG"
- CACHE STRING
- "Flags used by the compiler during all debug builds.")
--- /dev/null
+#
+# Setup default compiler flags:
+#
+# FAT NOTE:
+#
+# TODO
+#
+
+#
+# TODO: For the moment assume that CC and CXX are the same compilers...
+#
+
+
+
+
+#######################################################
+# #
+# General setup for GCC and GCC like compilers: #
+# #
+#######################################################
+
+IF( CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+ CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
+
+ ########################
+ # #
+ # General setup: #
+ # #
+ ########################
+
+ #
+ # Set the pic flag.
+ # On some systems, -fpic/PIC is implied, so don't set anything to avoid
+ # a warning. (TODO)
+ #
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-fpic")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-fpic")
+
+ #
+ # Check whether the -as-needed flag is available. If so set it to link
+ # the deal.II library with it.
+ #
+ ENABLE_IF_AVAILABLE(CMAKE_SHARED_LINKER_FLAGS "-Wl,-as-needed")
+
+ #
+ # Set -pedantic if the compiler supports it.
+ # Do not enable -pedantic for gcc-4.4, though...
+ #
+ IF(NOT ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION MATCHES "4.4." ))
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-pedantic")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-pedantic")
+ ENDIF()
+
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-Wall")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wall")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-Wpointer-arith")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wpointer-arith")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-Wwrite-strings")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wwrite-strings")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-Wsynth")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wsynth")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-Wsign-compare")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wsign-compare")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS "-Wswitch")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS "-Wswitch")
+
+ #################################
+ # #
+ # For the Release target: #
+ # #
+ #################################
+
+ #
+ # General optimization flags:
+ #
+ ADD_FLAGS(CMAKE_C_FLAGS_RELEASE "-O2")
+ ADD_FLAGS(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS_RELEASE "-funroll-loops")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS_RELEASE "-funroll-loops")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS_RELEASE "-fstrict-aliasing")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS_RELEASE "-fstrict-aliasing")
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS_RELEASE "-felide-constructors")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS_RELEASE "-felide-constructors")
+
+ ###############################
+ # #
+ # For the Debug target: #
+ # #
+ ###############################
+
+ IF (CMAKE_BUILD_TYPE MATCHES "Debug")
+ ADD_DEFINITIONS("-DDEBUG")
+ ENDIF()
+
+ ADD_FLAGS(CMAKE_C_FLAGS_DEBUG "-O0")
+ ADD_FLAGS(CMAKE_CXX_FLAGS_DEBUG "-O0")
+
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS_DEBUG "-ggdb")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
+ ENABLE_IF_AVAILABLE(CMAKE_SHARED_LINKER_FLAGS "-ggdb")
+ IF(NOT DEAL_II_HAVE_FLAG_-ggdb)
+ # If -ggdb is not available, fall back to -g:
+ ENABLE_IF_AVAILABLE(CMAKE_C_FLAGS_DEBUG "-g")
+ ENABLE_IF_AVAILABLE(CMAKE_CXX_FLAGS_DEBUG "-g")
+ ENABLE_IF_AVAILABLE(CMAKE_SHARED_LINKER_FLAGS "-g")
+ ENDIF()
+
+ELSE()
+
+ MESSAGE(WARNING "Unrecognized compiler. Please set the relevant compiler options by hand.")
+ENDIF()
+
--- /dev/null
+FOREACH(flags ${deal_ii_used_flags})
+ #
+ # Append the saved cache variable ${flags}_SAVED at the end of ${flags}
+ #
+ SET(${flags} "${${flags}} ${${flags}_SAVED}")
+ENDFOREACH()
+
+MESSAGE("
+
+
+deal.II successfully configured!
+
+
+Compiler Flags:
+
+Flags used by the compiler during all build types:
+
+ CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}
+ CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}
+
+Additional flags used by the compiler during all release builds:
+
+ CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}
+ CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}
+
+Additional flags used by the compiler during all debug builds:
+
+ CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}
+ CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}
+
+(Note: Flags set with ccmake or the command line will be appended at the end
+of the default configuration)
+
+
+Configured Features:
+")
+
+GET_CMAKE_PROPERTY(res VARIABLES)
+FOREACH(var ${res})
+ IF(var MATCHES "DEAL_II_WITH")
+ MESSAGE(" ${var} = ${${var}}")
+ ENDIF()
+ENDFOREACH()
+
+MESSAGE("
+TODO: Tell something about contrib/external
+
+")