[cig-commits] [commit] master: Add debug vs. release flags (4f1b211)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Oct 29 16:20:24 PDT 2014


Repository : https://github.com/geodynamics/vq

On branch  : master
Link       : https://github.com/geodynamics/vq/compare/0ca7695073f8b223d815f10653613b02b6c47df8...197914f4e03e55d321cae45161deafb1a5ade706

>---------------------------------------------------------------

commit 4f1b2117b34c6209e051c3d159bd1b3a7f326f88
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Tue Oct 28 14:39:10 2014 -0700

    Add debug vs. release flags
    
    Release mode is default


>---------------------------------------------------------------

4f1b2117b34c6209e051c3d159bd1b3a7f326f88
 CMakeLists.txt          | 30 ++++++++++++++++++++++++++++++
 quakelib/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ea6c4b..26b910a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,36 @@ SET(VQ_VERSION_STR "${VQ_VERSION_MAJOR}.${VQ_VERSION_MINOR}.${VQ_VERSION_SUBMINO
 # Enable testing
 INCLUDE (CTest)
 
+ # If the user doesn't specify, build the release version by default
+IF (NOT CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE Release)
+ENDIF (NOT CMAKE_BUILD_TYPE)
+
+# Check validity of different flags
+INCLUDE(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG(-O0 COMPILER_SUPPORTS_OPT0_FLAG)
+CHECK_CXX_COMPILER_FLAG(-O3 COMPILER_SUPPORTS_OPT3_FLAG)
+CHECK_CXX_COMPILER_FLAG(-g COMPILER_SUPPORTS_DEBUG_FLAG)
+
+# Define debug vs release compiler flags
+IF(COMPILER_SUPPORTS_OPT0_FLAG)
+    SET(DEBUG_FLAGS "${DEBUG_FLAGS} -O0")
+ENDIF(COMPILER_SUPPORTS_OPT0_FLAG)
+
+IF(COMPILER_SUPPORTS_OPT3_FLAG)
+    SET(RELEASE_FLAGS "${RELEASE_FLAGS} -O3")
+    SET(RELWITHDEBINFO_FLAGS "${RELWITHDEBINFO_FLAGS} -O3")
+ENDIF(COMPILER_SUPPORTS_OPT3_FLAG)
+
+IF(COMPILER_SUPPORTS_DEBUG_FLAG)
+    SET(DEBUG_FLAGS "${DEBUG_FLAGS} -g")
+    SET(RELWITHDEBINFO_FLAGS "${RELWITHDEBINFO_FLAGS} -g")
+ENDIF(COMPILER_SUPPORTS_DEBUG_FLAG)
+
+SET(CMAKE_CXX_FLAGS_DEBUG ${DEBUG_FLAGS})
+SET(CMAKE_CXX_FLAGS_RELEASE ${RELEASE_FLAGS})
+SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${RELWITHDEBINFO_FLAGS})
+
 # Check for common include files
 INCLUDE (CheckIncludeFiles)
 CHECK_INCLUDE_FILES ("sys/time.h" VQ_HAVE_SYS_TIME_H)
diff --git a/quakelib/CMakeLists.txt b/quakelib/CMakeLists.txt
index 13ceb68..79a5d20 100644
--- a/quakelib/CMakeLists.txt
+++ b/quakelib/CMakeLists.txt
@@ -8,6 +8,37 @@ LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
 # Enable testing framework
 INCLUDE (CTest)
 
+# If the user doesn't specify, build the release version by default
+IF (NOT CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE Release)
+ENDIF (NOT CMAKE_BUILD_TYPE)
+
+# Check validity of different flags
+INCLUDE(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG(-O0 COMPILER_SUPPORTS_OPT0_FLAG)
+CHECK_CXX_COMPILER_FLAG(-O3 COMPILER_SUPPORTS_OPT3_FLAG)
+CHECK_CXX_COMPILER_FLAG(-g COMPILER_SUPPORTS_DEBUG_FLAG)
+
+ # Define debug vs release compiler flags
+IF(COMPILER_SUPPORTS_OPT0_FLAG)
+    SET(DEBUG_FLAGS "${DEBUG_FLAGS} -O0")
+ENDIF(COMPILER_SUPPORTS_OPT0_FLAG)
+
+IF(COMPILER_SUPPORTS_OPT3_FLAG)
+    SET(RELEASE_FLAGS "${RELEASE_FLAGS} -O3")
+    SET(RELWITHDEBINFO_FLAGS "${RELWITHDEBINFO_FLAGS} -O3")
+ENDIF(COMPILER_SUPPORTS_OPT3_FLAG)
+
+IF(COMPILER_SUPPORTS_DEBUG_FLAG)
+    SET(DEBUG_FLAGS "${DEBUG_FLAGS} -g")
+    SET(RELWITHDEBINFO_FLAGS "${RELWITHDEBINFO_FLAGS} -g")
+ENDIF(COMPILER_SUPPORTS_DEBUG_FLAG)
+
+SET(CMAKE_CXX_FLAGS)
+SET(CMAKE_CXX_FLAGS_DEBUG ${DEBUG_FLAGS})
+SET(CMAKE_CXX_FLAGS_RELEASE ${RELEASE_FLAGS})
+SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${RELWITHDEBINFO_FLAGS})
+
 # Check for common include files
 INCLUDE (CheckIncludeFiles)
 CHECK_INCLUDE_FILES ("float.h" QUAKELIB_HAVE_FLOAT_H)



More information about the CIG-COMMITS mailing list