]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
CMake: Respect environment CFLAGS, CXXFLAGS and LDFLAGS in a sane way.
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Apr 2013 08:47:45 +0000 (08:47 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Apr 2013 08:47:45 +0000 (08:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@29198 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/setup_cached_variables.cmake
deal.II/doc/development/cmake.html

index a86be64cf1faefc064f26b0bbbaec1823bd72efe..3e6f447bcc807efdb99761dae50410c4ff3b9c2d 100644 (file)
@@ -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:                           #
index dade8e486ec1aba57da89a8a3048659d9e54ee90..33201002c52c2c16f337c3f96474b2fef6ed008d 100644 (file)
       target. There are two options to override this behaviour:
 
       <ol>
-       <li>
-         Disable the configuration completely by setting
-         <code>DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS</code> to
-         <code>OFF</code>.  Beware of the fact that certain features
-         may still pull in necessary compiler flags.
-
        <li>
          Override the default configuration by setting the following
          cached variables:
 
     cmake -DCMAKE_CXX_FLAGS="-Wno-sign-compare" &lt;...&gt;
          </pre>
+
+        <li>
+          Set the corresponding environment variables: <code>CFLAGS</code>,
+          <code>CXXFLAGS</code>, or <code>LDFLAGS</code> environment. These
+          variables will also be appended after the default compiler flags
+          (but before the corresponding cached variables).
+
+       <li>
+         Disable the configuration completely by setting
+         <code>DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS</code> to
+         <code>OFF</code>.  Beware of the fact that certain features
+         may still pull in necessary compiler flags.
       </ol>
     </p>
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.