Commit 4f397d2f authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent 361cb7e4
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment