cmake-utils.eclass: Wipe out default flags for std build types
authorMichał Górny <mgorny@gentoo.org>
Sun, 27 Nov 2016 13:28:55 +0000 (14:28 +0100)
committerMichał Górny <mgorny@gentoo.org>
Wed, 30 Nov 2016 09:42:11 +0000 (10:42 +0100)
Wipe out the default compiler & linker flags that are forced by CMake
for the standard build types. This improves the sanity of the build if
we are forced to use one of those types.

eclass/cmake-utils.eclass

index fbd60c24ab276b1ae0b22eb7d80f05208634adec..b21435b1782dee6ca2e57bcedd67fa7b3c3d82b7 100644 (file)
@@ -599,6 +599,19 @@ enable_cmake-utils_src_configure() {
        _EOF_
        [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
 
+       # Wipe the default optimization flags out of CMake
+       if [[ ${CMAKE_BUILD_TYPE} != Gentoo ]] && ! has "${EAPI}" 2 3 4 5; then
+               cat >> ${common_config} <<- _EOF_ || die
+                       SET (CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+                       SET (CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+                       SET (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+                       SET (CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+                       SET (CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+                       SET (CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+                       SET (CMAKE_STATIC_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+               _EOF_
+       fi
+
        # Convert mycmakeargs to an array, for backwards compatibility
        # Make the array a local variable since <=portage-2.1.6.x does not
        # support global arrays (see bug #297255).