From 91d84b3884b831532fc06a6798a61c746f4d8bc5 Mon Sep 17 00:00:00 2001 From: maier Date: Tue, 18 Sep 2012 15:36:42 +0000 Subject: [PATCH] Add a rudimentary C/CXX-Flags configuration git-svn-id: https://svn.dealii.org/branches/branch_cmake@26475 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 40 +++---- .../cmake/check/check_for_compiler_bugs.cmake | 27 +++++ .../check/check_for_compiler_features.cmake | 16 --- .../cmake/check/check_for_cxx_features.cmake | 2 +- .../cmake/configure/configure_1_mpi.cmake | 4 +- .../cmake/configure/configure_1_tbb.cmake | 7 +- .../cmake/configure/configure_blas.cmake | 4 +- .../cmake/configure/configure_boost.cmake | 8 ++ .../cmake/configure/configure_lapack.cmake | 4 +- .../cmake/configure/configure_trilinos.cmake | 26 +--- .../cmake/macros/macro_add_flags.cmake | 3 + .../macros/macro_enable_if_available.cmake | 8 ++ .../cmake/setup_cached_compiler_flags.cmake | 70 +++++++++++ .../cmake/setup_cached_variables.cmake | 72 ----------- .../contrib/cmake/setup_compiler_flags.cmake | 113 ++++++++++++++++++ deal.II/contrib/cmake/setup_finalize.cmake | 48 ++++++++ 16 files changed, 311 insertions(+), 141 deletions(-) create mode 100644 deal.II/contrib/cmake/macros/macro_add_flags.cmake create mode 100644 deal.II/contrib/cmake/macros/macro_enable_if_available.cmake create mode 100644 deal.II/contrib/cmake/setup_cached_compiler_flags.cmake delete mode 100644 deal.II/contrib/cmake/setup_cached_variables.cmake create mode 100644 deal.II/contrib/cmake/setup_compiler_flags.cmake create mode 100644 deal.II/contrib/cmake/setup_finalize.cmake diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 238ef5bc96..1a77fbf04a 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -93,7 +93,7 @@ OPTION(DEAL_II_ALLOW_CONTRIB 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." @@ -101,18 +101,18 @@ OPTION(DEAL_II_WITH_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." @@ -132,10 +132,10 @@ OPTION(DEAL_II_WITH_P4EST 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." @@ -154,7 +154,7 @@ OPTION(DEAL_II_WITH_ZLIB OPTION(DEAL_II_FORCE_CONTRIB_BOOST "Always use the bundled boost library instead of an external one." - OFF) + ON) @@ -197,14 +197,17 @@ INCLUDE(setup_external_macros) # 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) + # # #################### @@ -219,11 +222,9 @@ INCLUDE(setup_deal_ii) # # 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) # @@ -262,6 +263,12 @@ FOREACH(file ${configure_files}) ENDFOREACH() +# +# Finalize the configuration: +# +INCLUDE(setup_finalize) + + ########################################################################### @@ -297,10 +304,3 @@ ADD_SUBDIRECTORY(include) 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() diff --git a/deal.II/contrib/cmake/check/check_for_compiler_bugs.cmake b/deal.II/contrib/cmake/check/check_for_compiler_bugs.cmake index ca7fae17c1..a5ebe270d2 100644 --- a/deal.II/contrib/cmake/check/check_for_compiler_bugs.cmake +++ b/deal.II/contrib/cmake/check/check_for_compiler_bugs.cmake @@ -77,3 +77,30 @@ CHECK_CXX_COMPILER_BUG( 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 + + + diff --git a/deal.II/contrib/cmake/check/check_for_compiler_features.cmake b/deal.II/contrib/cmake/check/check_for_compiler_features.cmake index 28d4fc0b90..7145acdd19 100644 --- a/deal.II/contrib/cmake/check/check_for_compiler_features.cmake +++ b/deal.II/contrib/cmake/check/check_for_compiler_features.cmake @@ -328,22 +328,6 @@ ENDIF() -# -# 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 # diff --git a/deal.II/contrib/cmake/check/check_for_cxx_features.cmake b/deal.II/contrib/cmake/check/check_for_cxx_features.cmake index 7056da90ef..2d365e29df 100644 --- a/deal.II/contrib/cmake/check/check_for_cxx_features.cmake +++ b/deal.II/contrib/cmake/check/check_for_cxx_features.cmake @@ -144,7 +144,7 @@ IF(DEAL_II_HAVE_CXX11_FLAG) 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() diff --git a/deal.II/contrib/cmake/configure/configure_1_mpi.cmake b/deal.II/contrib/cmake/configure/configure_1_mpi.cmake index 7007f90fd6..81f39f5bdf 100644 --- a/deal.II/contrib/cmake/configure/configure_1_mpi.cmake +++ b/deal.II/contrib/cmake/configure/configure_1_mpi.cmake @@ -16,8 +16,8 @@ ENDMACRO() 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) diff --git a/deal.II/contrib/cmake/configure/configure_1_tbb.cmake b/deal.II/contrib/cmake/configure/configure_1_tbb.cmake index 64206014f7..54c10d8a34 100644 --- a/deal.II/contrib/cmake/configure/configure_1_tbb.cmake +++ b/deal.II/contrib/cmake/configure/configure_1_tbb.cmake @@ -17,7 +17,7 @@ MACRO(SETUP_THREADING var) # 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) @@ -130,6 +130,9 @@ MACRO(FEATURE_TBB_CONFIGURE_CONTRIB var) # 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 ) @@ -139,6 +142,8 @@ MACRO(FEATURE_TBB_CONFIGURE_CONTRIB var) LIST(APPEND deal_ii_additional_object_files $ ) + + ENDMACRO() diff --git a/deal.II/contrib/cmake/configure/configure_blas.cmake b/deal.II/contrib/cmake/configure/configure_blas.cmake index ae48d4cebb..023f19f12c 100644 --- a/deal.II/contrib/cmake/configure/configure_blas.cmake +++ b/deal.II/contrib/cmake/configure/configure_blas.cmake @@ -15,9 +15,7 @@ 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} diff --git a/deal.II/contrib/cmake/configure/configure_boost.cmake b/deal.II/contrib/cmake/configure/configure_boost.cmake index bf119601cd..2f0b29c80c 100644 --- a/deal.II/contrib/cmake/configure/configure_boost.cmake +++ b/deal.II/contrib/cmake/configure/configure_boost.cmake @@ -65,6 +65,14 @@ MACRO(FEATURE_BOOST_CONFIGURE_CONTRIB var) # 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 ) diff --git a/deal.II/contrib/cmake/configure/configure_lapack.cmake b/deal.II/contrib/cmake/configure/configure_lapack.cmake index bfe389a6f5..1c7d8830b2 100644 --- a/deal.II/contrib/cmake/configure/configure_lapack.cmake +++ b/deal.II/contrib/cmake/configure/configure_lapack.cmake @@ -15,9 +15,7 @@ ENDMACRO() 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} diff --git a/deal.II/contrib/cmake/configure/configure_trilinos.cmake b/deal.II/contrib/cmake/configure/configure_trilinos.cmake index 55f3766c0a..999f7d59b6 100644 --- a/deal.II/contrib/cmake/configure/configure_trilinos.cmake +++ b/deal.II/contrib/cmake/configure/configure_trilinos.cmake @@ -158,30 +158,10 @@ MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL var) # 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) diff --git a/deal.II/contrib/cmake/macros/macro_add_flags.cmake b/deal.II/contrib/cmake/macros/macro_add_flags.cmake new file mode 100644 index 0000000000..9fdb657330 --- /dev/null +++ b/deal.II/contrib/cmake/macros/macro_add_flags.cmake @@ -0,0 +1,3 @@ +MACRO(ADD_FLAGS variable flag) + SET(${variable} "${${variable}} ${flag}") +ENDMACRO() diff --git a/deal.II/contrib/cmake/macros/macro_enable_if_available.cmake b/deal.II/contrib/cmake/macros/macro_enable_if_available.cmake new file mode 100644 index 0000000000..b4e444a536 --- /dev/null +++ b/deal.II/contrib/cmake/macros/macro_enable_if_available.cmake @@ -0,0 +1,8 @@ +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() diff --git a/deal.II/contrib/cmake/setup_cached_compiler_flags.cmake b/deal.II/contrib/cmake/setup_cached_compiler_flags.cmake new file mode 100644 index 0000000000..d9df7c961b --- /dev/null +++ b/deal.II/contrib/cmake/setup_cached_compiler_flags.cmake @@ -0,0 +1,70 @@ +# +# 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() diff --git a/deal.II/contrib/cmake/setup_cached_variables.cmake b/deal.II/contrib/cmake/setup_cached_variables.cmake deleted file mode 100644 index 67f1047b6a..0000000000 --- a/deal.II/contrib/cmake/setup_cached_variables.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# -# 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: -# -# $ \ -# \ -# <...> <...>.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.") diff --git a/deal.II/contrib/cmake/setup_compiler_flags.cmake b/deal.II/contrib/cmake/setup_compiler_flags.cmake new file mode 100644 index 0000000000..c21a02eb90 --- /dev/null +++ b/deal.II/contrib/cmake/setup_compiler_flags.cmake @@ -0,0 +1,113 @@ +# +# 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() + diff --git a/deal.II/contrib/cmake/setup_finalize.cmake b/deal.II/contrib/cmake/setup_finalize.cmake new file mode 100644 index 0000000000..3301366a4b --- /dev/null +++ b/deal.II/contrib/cmake/setup_finalize.cmake @@ -0,0 +1,48 @@ +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 + +") -- 2.39.5