From 2df7c94490c4bf3693f8ad2fa3d7231a1fa4f789 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sun, 28 Oct 2012 09:25:43 +1100 Subject: [PATCH 1/4] Remove duplicate CMAKE_C_FLAGS inside CMAKE_C_FLAGS_DEBUG. - For Debug builds, CMake uses concatenated CMAKE_C_FLAGS and CMAKE_C_FLAGS_DEBUG - This reverts commit 291f7122927d2cc170dc63c378a08fa78515d987. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5111213bd..bf82782f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,8 @@ IF (MSVC) # Precompiled headers ELSE () - SET(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS "-O2 -g -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}") + SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF (MINGW) # MinGW always does PIC and complains if we tell it to STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}") ELSE () From 54c56d3efd572f647ced5ac9a999b55c5983ced6 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sun, 28 Oct 2012 09:42:54 +1100 Subject: [PATCH 2/4] Remove "-O2 -g" from default CMAKE_C_FLAGS. - Those are the RelWithDebInfo flags. - They should be controlled from CMAKE_BUILD_TYPE --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf82782f4..854852cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ IF (MSVC) # Precompiled headers ELSE () - SET(CMAKE_C_FLAGS "-O2 -g -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}") + SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF (MINGW) # MinGW always does PIC and complains if we tell it to STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}") From 4a3be934decde9a7bda9483a5750f73ff5425675 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sun, 28 Oct 2012 09:56:18 +1100 Subject: [PATCH 3/4] Removed overwrite of CMAKE_C_FLAGS_DEBUG. - No overwriting allows control from cmake cache or cmdline - -g is already the CMake default - -O0 is already gcc's default --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 854852cad..fdced6148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,6 @@ IF (MSVC) ELSE () SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}") - SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF (MINGW) # MinGW always does PIC and complains if we tell it to STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}") ELSE () From 88149fae9f004733b0b9829a1296afa5b3593c77 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sun, 28 Oct 2012 10:21:28 +1100 Subject: [PATCH 4/4] Leave CMAKE_BUILD_TYPE absent on those generators which don't use it. --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdced6148..59c6b4388 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,10 +110,15 @@ ELSE () ENDIF () ENDIF() -# Build Debug by default -IF (NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) -ENDIF () +IF( NOT CMAKE_CONFIGURATION_TYPES ) + # Build Debug by default + IF (NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) + ENDIF () +ELSE() + # Using a multi-configuration generator eg MSVC or Xcode + # that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE +ENDIF() IF (OPENSSL_FOUND) ADD_DEFINITIONS(-DGIT_SSL)