This is an automated email from the ASF dual-hosted git repository.

domino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/madlib.git

commit 89f7c89e882dc54545c9f50c049bf1085643b431
Author: Domino Valdano <dvald...@pivotal.io>
AuthorDate: Thu Feb 25 21:54:46 2021 -0500

    Set optimization flags based on build type, limit to max -O1
    
    Apparently, the build-specific flags automatically get appended
    to the generic flags... so we can't put them in the generic list
    of flags because the build-specific ones take precedence
    ( -O0 -O3 is the same as -O3 )
---
 CMakeLists.txt | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index df3b1f3..7231565 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,11 +52,27 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
 endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
 
 if(NOT CMAKE_BUILD_TYPE)
-  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
-      "Choose the type of build, options are: None Debug Release 
RelWithDebInfo MinSizeRel."
-      FORCE)
+    set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
+        "Choose the type of build, options are: None Debug Release 
RelWithDebInfo MinSizeRel."
+        FORCE)
 endif(NOT CMAKE_BUILD_TYPE)
 
+if (CXX11)
+    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g"
+        CACHE STRING
+        "Flags used by the CXX compiler during RELWITHDEBINFO builds." FORCE)
+    SET(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG"
+        CACHE STRING
+        "Flags used by the CXX compiler during RELEASE builds." FORCE)
+    SET(CMAKE_CXX_FLAGS_DEBUG  "-O0 -g"
+        CACHE STRING
+        "Flags used by the CXX compiler during DEBUG builds." FORCE)
+    SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG"
+        CACHE STRING
+        "Flags used by the CXX compiler during MINSIZEREL builds." FORCE)
+endif(CXX11)
+
+
 # The C++11 standard overlaps a lot with older versions of Boost.
 # So before deciding what standard to use for the whole project, we
 #  first detect Boost to see what version is on the system.
@@ -174,7 +190,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
     endif(APPLE)
 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
     if(CXX11)
-        set(CMAKE_CXX_FLAGS "-stdlib=libc++ -std=c++11"
+        SET(CMAKE_CXX_FLAGS "-stdlib=libc++ -std=c++11"
             CACHE STRING
             "Flags used by the compiler during all build types." FORCE)
     else(CXX11)

Reply via email to