Fix RelWithDebInfo name bugs, and use full optimization.
authorErik Lindahl <erik@kth.se>
Sat, 20 Sep 2014 12:12:02 +0000 (14:12 +0200)
committerErik Lindahl <erik@kth.se>
Sat, 20 Sep 2014 13:19:25 +0000 (15:19 +0200)
Gromacs was previously using a different name (RelWithDebugInfo) in
a few places, which caused the build types not to match, and
flags did not propagate correctly. Second, we now add our own
optimization flags at the end of the flag variables, to make it more
likely they override the CMake default choices. Otherwise, the -O2
flag at the end of the default RelWithDebInfo flags might revert our flags.

Change-Id: I4b7e220fbb2d625416e939e71d44412601394c0f

CMakeLists.txt
cmake/gmxCFlags.cmake

index e4c92d25265da83fe2fd613ce8433cc0fd3c9472..46306e7402ef1f9ec89bce8c7619633943bb4e92 100644 (file)
@@ -128,7 +128,7 @@ if(CMAKE_CONFIGURATION_TYPES)
         "List of configuration types"
         FORCE)
 endif()
-set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBUGINFO RELWITHASSERT MINSIZEREL)
+set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBINFO RELWITHASSERT MINSIZEREL)
 
 enable_language(C)
 enable_language(CXX)
index 0ccbc001ff4ea200c0ec184174f85703ce3763f6..124107b65c41c8105f528ebb91ae1c6e3a31cb09 100644 (file)
@@ -64,7 +64,7 @@ function(gmx_set_cmake_compiler_flags)
         # be set up elsewhere and passed to this function, but it is
         # inconvenient in CMake to pass more than one list, and such a
         # list is only used here.
-        foreach(build_type RELWITHDEBUGINFO RELWITHASSERT MINSIZEREL)
+        foreach(build_type RELWITHDEBINFO RELWITHASSERT MINSIZEREL)
             set(GMXC_${language}FLAGS_${build_type} "${GMXC_${language}FLAGS_RELEASE}")
         endforeach()
         # Copy the flags that are only used by the real Release build
@@ -85,9 +85,12 @@ function(gmx_set_cmake_compiler_flags)
             endif()
 
             # Append to the variables for the given build type for
-            # each language, in the parent scope.
+            # each language, in the parent scope. We add our new variables at the end, so
+            # compiler-specific choices are more likely to override default CMake choices.
+            # This is for instance useful for RelWithDebInfo builds, where we want to use the full
+            # set of our optimization flags detected in this file, rather than having -O2 override them.
             set(CMAKE_${language}_FLAGS${punctuation}${build_type}
-                "${GMXC_${language}FLAGS${punctuation}${build_type}} ${CMAKE_${language}_FLAGS${punctuation}${build_type}}"
+                "${CMAKE_${language}_FLAGS${punctuation}${build_type}} ${GMXC_${language}FLAGS${punctuation}${build_type}}"
                 PARENT_SCOPE)
         endforeach()
     endforeach()