From: maier Date: Mon, 24 Sep 2012 19:36:47 +0000 (+0000) Subject: Make Wolfgang happy #1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b30d51bfb8c541cfcf49b4e4e717808b335073a;p=dealii-svn.git Make Wolfgang happy #1 git-svn-id: https://svn.dealii.org/branches/branch_cmake@26677 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/README_CMAKE b/deal.II/README_CMAKE index 39eb60ef6b..258ad1639e 100644 --- a/deal.II/README_CMAKE +++ b/deal.II/README_CMAKE @@ -172,7 +172,10 @@ CONFIGURATION Build deal.II with support for netcdf DEAL_II_WITH_P4EST - Build deal.II with support for P4EST + Build deal.II with support for p4est + + DEAL_II_WITH_PETSC + Build deal.II with support for petsc DEAL_II_WITH_TBB Build deal.II with support for tbb. This will enable thread support in deal.II @@ -306,14 +309,16 @@ CONFIGURATION =================== - CMAKE_BUILD_TYPES: We support the "Debug" and "Release" build targets. - Default is the "Release" target. + CMAKE_BUILD_TYPES: We support the "Debug", "Release" and "DebugRelease" + build targets. Default is the "DebugRelease" target. - - Debug will enable a lot of debug code paths and Assertions, as well as - compiling the library with a suitable set of debug compiler flags. + - Debug will compile a debug library libdeal_II.g.so with a lot of debug + code paths and assertions enabled, as well as a suitable set of debug + compiler flags. - - Release will chose a suitable set of optimizing flags. + - Release will build an optimized libdeal_II.so. + - DebugRelease will build both. deal.II will configure sensible default CFLAGS and CXXFLAGS depending on platform, compiler and build target. There are two options, if this is @@ -327,10 +332,10 @@ CONFIGURATION - Option 2: Overwrite the default configuration by setting the following cached variables: - CMAKE_CXX_FLAGS - used during all builds - CMAKE_CXX_FLAGS_DEBUG - additional flags used during debug builds - CMAKE_CXX_FLAGS_RELEASE - additional flags used during release builds - (same for CMAKE_C_...) + CMAKE_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 + (same for *_C_FLAGS_* ...) The content of the cached variables will be preserved and added *_TO THE END_* of the default compiler flags, hence giving a possibility diff --git a/deal.II/cmake/setup_cached_variables.cmake b/deal.II/cmake/setup_cached_variables.cmake index cf89d177c5..b1b27754ec 100644 --- a/deal.II/cmake/setup_cached_variables.cmake +++ b/deal.II/cmake/setup_cached_variables.cmake @@ -1,60 +1,33 @@ # # Setup cached variables prior to the PROJECT(deal.II) call # -# -# 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, furthermore, have no idea which compiler is -# selected.) In this process CMAKE_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 initialize the cached CMAKE_CXX_FLAGS[...] variables with empty -# strings prior to initializing the compiler, so that no default values -# are set. -# -# - We save the cached variables (possibly altered by the user via command -# line or ccmake) in _SAVED and set to an empty -# string. -# -# - This way we can happily set our default flags in -# setup_compiler_flags.cmake (if the user lets us, see -# DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS) -# -# - At the end of the configuration step we add _SAVED -# _AT THE END_ of the respective allowing the user to -# effectively overwrite our default settings. -# # # Setup CMAKE_BUILD_TYPE: # SET(CMAKE_BUILD_TYPE - "Release" + "DebugRelease" CACHE STRING - "Choose the type of build, options are: Debug Release.") + "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 MATCHES "Release" AND - NOT CMAKE_BUILD_TYPE MATCHES "Debug" ) - MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE does neither match Release, nor Debug.") +IF( NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND + NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND + NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease" ) + MESSAGE(FATAL_ERROR + "CMAKE_BUILD_TYPE does neither match Release, Debug, nor DebugRelease!" + ) ENDIF() # -# Set BUILD_SHARED_LIBS to default to ON: +# Set BUILD_SHARED_LIBS to default to ON and promote to cache so that the +# user can see the value. # SET(BUILD_SHARED_LIBS "ON" CACHE BOOL "Build a shared library" @@ -62,30 +35,67 @@ SET(BUILD_SHARED_LIBS "ON" CACHE BOOL # -# Set CMAKE_INSTALL_RPATH_USE_LINK_PATH to default to ON: +# 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 ") +# +# Tell the user very prominently, that we're doing things differently w.r.t +# CMAKE_(C|CXX)_FLAGS_(DEBUG|RELEASE) +# +SET(flags C_FLAGS_RELEASE CXX_FLAGS_RELEASE C_FLAGS_DEBUG CXX_FLAGS_DEBUG) +FOREACH(flag ${flags}) + IF(NOT "${CMAKE_${flag}}" STREQUAL "") + MESSAGE(FATAL_ERROR + "\nThe deal.II cmake build system does not use CMAKE_${flag}.\n" + "Use DEAL_II_${flag}, instead!\n\n" + ) + ENDIF() +ENDFOREACH() + + +# +# Hide all unused compiler flag variables: +# +SET(flags + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELWITHDEBINFO + ) +FOREACH(flag ${flags}) + # + # Go away... + # + SET(${flag} "" CACHE INTERNAL "" FORCE) +ENDFOREACH() + + # # 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 + DEAL_II_C_FLAGS_RELEASE + DEAL_II_CXX_FLAGS_RELEASE + DEAL_II_C_FLAGS_DEBUG + DEAL_II_CXX_FLAGS_DEBUG ) -FOREACH(flags ${deal_ii_used_flags}) +FOREACH(flag ${deal_ii_used_flags}) # "CACHE" ensures that we only set the variable if it is not already set # as a cached variable, effectively we're setting a default value: - SET(${flags} "" CACHE STRING - "The user supplied cache variable will be appended _at the end_ of the auto generated ${flags} variable" + SET(${flag} "" CACHE STRING + "The user supplied cache variable will be appended _at the end_ of the auto generated ${flag} variable" ) # @@ -94,8 +104,8 @@ FOREACH(flags ${deal_ii_used_flags}) # setup_cached_compiler_flags_finalize.cmake (called at the end of the # main CMakeLists.txt file). # - SET(${flags}_SAVED "${${flags}}") - SET(${flags} "") + SET(${flag}_SAVED "${${flag}}") + SET(${flag} "") ENDFOREACH() diff --git a/deal.II/cmake/setup_compiler_flags_gnu.cmake b/deal.II/cmake/setup_compiler_flags_gnu.cmake index d1c4150967..abd20a23b7 100644 --- a/deal.II/cmake/setup_compiler_flags_gnu.cmake +++ b/deal.II/cmake/setup_compiler_flags_gnu.cmake @@ -99,73 +99,70 @@ IF(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") # TODO: Check for correct name ENDIF() -################################# -# # -# For the Release target: # -# # -################################# +############################## +# # +# For Release targets: # +# # +############################## IF (CMAKE_BUILD_TYPE MATCHES "Release") # # General optimization flags: # - ADD_FLAGS(CMAKE_CXX_FLAGS_RELEASE "-O2") + ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "-O2") - ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_RELEASE "-funroll-loops") - ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_RELEASE "-fstrict-aliasing") - ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_RELEASE "-felide-constructors") + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-funroll-loops") + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-fstrict-aliasing") + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-felide-constructors") - ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_RELEASE "-Wno-unused") + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-Wno-unused") ENDIF() -############################### -# # -# For the Debug target: # -# # -############################### +########################### +# # +# For Debug target: # +# # +########################### IF (CMAKE_BUILD_TYPE MATCHES "Debug") - # - # Define the DEBUG preprocessor macro globally: - # - ADD_DEFINITIONS("-DDEBUG") - LIST(APPEND CMAKE_EXTERNAL_DEFINTIONS "-DDEBUG") + LIST(APPEND DEAL_II_DEFINITIONS_DEBUG "-DDEBUG") + LIST(APPEND DEAL_II_USER_DEFINTIONS_DEBUG "-DDEBUG") - ADD_FLAGS(CMAKE_CXX_FLAGS_DEBUG "-O0") + ADD_FLAGS(DEAL_II_CXX_FLAGS_DEBUG "-O0") - ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_DEBUG "-ggdb") - ENABLE_IF_SUPPORTED(CMAKE_SHARED_LINKER_FLAGS "-ggdb") + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-ggdb") + ENABLE_IF_SUPPORTED(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "-ggdb") # # If -ggdb is not available, fall back to -g: # IF(NOT DEAL_II_HAVE_FLAG_-ggdb) - ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_DEBUG "-g") - ENABLE_IF_SUPPORTED(CMAKE_SHARED_LINKER_FLAGS "-g") + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-g") + ENABLE_IF_SUPPORTED(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "-g") ENDIF() ENDIF() -############################################### -# # -# Set up CMAKE_C_FLAGS<_RELEASE|_DEBUG> # -# # -############################################### +######################### +# # +# Set up C FLAGS: # +# # +######################### # # For the moment we assume that CC and CXX are the same compiler and that # we can set (almost) the same default flags for both: # SET(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS}) -SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) -SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) +SET(DEAL_II_C_FLAGS_RELEASE ${DEAL_II_CXX_FLAGS_RELEASE}) +SET(DEAL_II_C_FLAGS_DEBUG ${DEAL_II_CXX_FLAGS_DEBUG}) # # OK, touché, touché. We have to strip flags not supported by a C target: # STRIP_FLAG(CMAKE_C_FLAGS "-Wsynth") -STRIP_FLAG(CMAKE_C_FLAGS_RELEASE "-felide-constructors") +STRIP_FLAG(DEAL_II_C_FLAGS_RELEASE "-felide-constructors") # # and disable some warnings: diff --git a/deal.II/cmake/setup_finalize.cmake b/deal.II/cmake/setup_finalize.cmake index 7c4884e906..706748e38b 100644 --- a/deal.II/cmake/setup_finalize.cmake +++ b/deal.II/cmake/setup_finalize.cmake @@ -59,22 +59,28 @@ MESSAGE(" * * * * - CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} - CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} - CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR} - CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR} + CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} + CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} + CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR} + CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR} - CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} on platform ${CMAKE_SYSTEM_NAME} + CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} on platform ${CMAKE_SYSTEM_NAME} Compiler flags used for this build: - CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") + CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") IF(CMAKE_BUILD_TYPE MATCHES "Release") - MESSAGE(" CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") + MESSAGE(" DEAL_II_CXX_FLAGS_RELEASE: ${DEAL_II_CXX_FLAGS_RELEASE}") ENDIF() IF(CMAKE_BUILD_TYPE MATCHES "Debug") - MESSAGE(" CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") + MESSAGE(" DEAL_II_CXX_FLAGS_DEBUG: ${DEAL_II_CXX_FLAGS_DEBUG}") +ENDIF() +MESSAGE(" CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}") +IF(CMAKE_BUILD_TYPE MATCHES "Release") + MESSAGE(" DEAL_II_SHARED_LINKER_FLAGS_RELEASE: #${DEAL_II_SHARED_LINKER_FLAGS_RELEASE}") +ENDIF() +IF(CMAKE_BUILD_TYPE MATCHES "Debug") + MESSAGE(" DEAL_II_SHARED_LINKER_FLAGS_DEBUG: ${DEAL_II_SHARED_LINKER_FLAGS_DEBUG}") ENDIF() -MESSAGE(" CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}") IF(FEATURE_UMFPACK_CONTRIB_CONFIGURED)