summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <vvaintroub@mysql.com>2010-03-02 01:53:15 +0100
committerVladislav Vaintroub <vvaintroub@mysql.com>2010-03-02 01:53:15 +0100
commit40e12231fe7fdcfacc388b9be1986be48e6021ee (patch)
treea0bc75b7960cdffea7a1d7ccf3713d4c198ae047
parent77385a913621d876ad7d35f938a20c392bf1db0c (diff)
downloadmariadb-git-40e12231fe7fdcfacc388b9be1986be48e6021ee.tar.gz
Fix WITH_DEBUG problems in CMake build, so people who use configure wrappers do not
suffer. The problem was that when custom C flags were defined with in environment variable CFLAGS, WITH_DEBUG did not have any effect. Also, switch from WITH_DEBUG=ON to WITH_DEBUG=OFF was not handled correctly .Expected is switch to with RelwithDebInfo or when custom compiler flags are defined, to None.
-rwxr-xr-xCMakeLists.txt38
1 files changed, 22 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 036d0cdb9d6..d20939f33ac 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,26 +32,32 @@ IF(DEFINED CMAKE_BUILD_TYPE)
SET(HAVE_CMAKE_BUILD_TYPE TRUE)
ENDIF()
SET(CUSTOM_C_FLAGS $ENV{CFLAGS})
-IF(NOT CUSTOM_C_FLAGS)
- SET(CUSTOM_C_FLAGS ${CMAKE_C_FLAGS})
-ENDIF()
-OPTION(WITH_DEBUG "Use dbug" OFF)
+OPTION(WITH_DEBUG "Use dbug/safemutex" OFF)
OPTION(WITH_DEBUG_FULL "Use dbug and safemalloc/safemutex. Slow" OFF)
-IF(NOT HAVE_CMAKE_BUILD_TYPE)
- IF(BUILD_CONFIG OR NOT CUSTOM_C_FLAGS)
- IF(WITH_DEBUG)
- SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Debug build" FORCE)
- ELSE()
- SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
- "RelWithDebInfo build" FORCE)
- ENDIF()
- ENDIF()
-ENDIF()
-IF(WITH_DEBUG_FULL)
- SET(WITH_DEBUG ON CACHE BOOL "Use DBUG")
+# We choose to provide WITH_DEBUG as alias to standard CMAKE_BUILD_TYPE=Debug
+# which turns out to be not trivial, as this involves synchronization
+# between CMAKE_BUILD_TYPE and WITH_DEBUG. Besides, we have to deal with cases
+# where WITH_DEBUG is reset from ON to OFF and here we need to reset
+# CMAKE_BUILD_TYPE to either none or default RelWithDebInfo
+
+SET(BUILDTYPE_DOCSTRING
+ "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
+ CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel")
+
+IF(WITH_DEBUG OR WITH_DEBUG_FULL)
+ SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE)
+ SET(OLD_WITH_DEBUG 1 CACHE INTERNAL "" FORCE)
+ELSEIF(NOT HAVE_CMAKE_BUILD_TYPE OR OLD_WITH_DEBUG)
+ IF(CUSTOM_C_FLAGS)
+ SET(CMAKE_BUILD_TYPE "" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE)
+ ELSE(CMAKE_BUILD_TYPE MATCHES "Debug" OR NOT HAVE_CMAKE_BUILD_TYPE)
+ SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
+ ${BUILDTYPE_DOCSTRING} FORCE)
+ ENDIF()
+ SET(OLD_WITH_DEBUG 0 CACHE INTERNAL "" FORCE)
ENDIF()
IF(BUILD_CONFIG)