From 39544189e8eab970159eef6f781eb2804c96f8d3 Mon Sep 17 00:00:00 2001 From: maier Date: Fri, 5 Apr 2013 08:47:45 +0000 Subject: [PATCH] CMake: Respect environment CFLAGS, CXXFLAGS and LDFLAGS in a sane way. git-svn-id: https://svn.dealii.org/trunk@29198 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/setup_cached_variables.cmake | 22 ++++++++++++---------- deal.II/doc/development/cmake.html | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/deal.II/cmake/setup_cached_variables.cmake b/deal.II/cmake/setup_cached_variables.cmake index a86be64cf1..3e6f447bcc 100644 --- a/deal.II/cmake/setup_cached_variables.cmake +++ b/deal.II/cmake/setup_cached_variables.cmake @@ -194,16 +194,6 @@ FOREACH(_flag SET(${_flag} "" CACHE INTERNAL "" FORCE) ENDFOREACH() -# -# Read in CFLAGS, CXXFLAGS and LDFLAGS from environment -# -SET_IF_EMPTY(CMAKE_C_FLAGS "$ENV{CFLAGS}") -SET_IF_EMPTY(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS}") -SET_IF_EMPTY(CMAKE_SHARED_LINKER_FLAGS "$ENV{LDFLAGS}") -UNSET(ENV{CFLAGS}) -UNSET(ENV{CXXFLAGS}) -UNSET(ENV{LDFLAGS}) - # # Set cached compiler flags to an empty string: # @@ -241,6 +231,18 @@ FOREACH(_flag ${DEAL_II_USED_FLAGS}) ENDFOREACH() +# +# Finally, read in CFLAGS, CXXFLAGS and LDFLAGS from environment and +# prepend them to the saved variables: +# +SET(CMAKE_C_FLAGS_SAVED "$ENV{CFLAGS} ${CMAKE_C_FLAGS_SAVED}") +SET(CMAKE_CXX_FLAGS_SAVED "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_SAVED}") +SET(CMAKE_SHARED_LINKER_FLAGS_SAVED "$ENV{LDFLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") +UNSET(ENV{CFLAGS}) +UNSET(ENV{CXXFLAGS}) +UNSET(ENV{LDFLAGS}) + + ########################################################################### # # # Miscellanious setup: # diff --git a/deal.II/doc/development/cmake.html b/deal.II/doc/development/cmake.html index dade8e486e..33201002c5 100644 --- a/deal.II/doc/development/cmake.html +++ b/deal.II/doc/development/cmake.html @@ -580,12 +580,6 @@ target. There are two options to override this behaviour:
    -
  1. - Disable the configuration completely by setting - DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS to - OFF. Beware of the fact that certain features - may still pull in necessary compiler flags. -
  2. Override the default configuration by setting the following cached variables: @@ -605,6 +599,18 @@ cmake -DCMAKE_CXX_FLAGS="-Wno-sign-compare" <...> + +
  3. + Set the corresponding environment variables: CFLAGS, + CXXFLAGS, or LDFLAGS environment. These + variables will also be appended after the default compiler flags + (but before the corresponding cached variables). + +
  4. + Disable the configuration completely by setting + DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS to + OFF. Beware of the fact that certain features + may still pull in necessary compiler flags.

-- 2.39.5