From 79cdf779e78f4f4c0c8573dc686004b9af94eb33 Mon Sep 17 00:00:00 2001 From: Erik Lindahl Date: Sat, 20 Sep 2014 14:12:02 +0200 Subject: [PATCH] Fix RelWithDebInfo name bugs, and use full optimization. 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 | 2 +- cmake/gmxCFlags.cmake | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c92d2526..46306e7402 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/gmxCFlags.cmake b/cmake/gmxCFlags.cmake index 0ccbc001ff..124107b65c 100644 --- a/cmake/gmxCFlags.cmake +++ b/cmake/gmxCFlags.cmake @@ -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() -- 2.22.0