Skip to content

Commit

Permalink
cmake: allow disabling ENABLE_CURLDEBUG with ENABLE_DEBUG=ON
Browse files Browse the repository at this point in the history
Before this patch, `ENABLE_CURLDEBUG` (memory tracking) was
unconditionally enabled when `ENABLE_DEBUGBUILD` was set. This made
testing some build configurations complicated. To fix this, after this
patch we only enable `ENABLE_CURLDEBUG` if not already defined by the
user.

This allows to use this config:
ENABLE_DEBUGBUILD=ON
ENABLE_CURLDEBUG=OFF
to enable debug features, without also enabling memory tracking.

This is important because some other build methods allow to set
one of these features but not the other. This patch allows to test
any combination with CMake.

This makes it unnecessary to use the workaround of passing
`-DDEBUGBUILD` via `CMAKE_C_FLAGS`. Which has the disadvantage
that our CMake logic cannot easily detect it, e.g. for disabling
symbol hiding on Windows for `ENABLE_DEBUG`/`DEBUGBUILD` builds.

Cherry-picked from curl#13718
Closes #xxxxx
  • Loading branch information
vszakats committed May 27, 2024
1 parent c8f61db commit e790429
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ include(PickyWarnings)
if(ENABLE_DEBUG)
# DEBUGBUILD will be defined only for Debug builds
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>)
set(ENABLE_CURLDEBUG ON)
if(NOT DEFINED ENABLE_CURLDEBUG)
set(ENABLE_CURLDEBUG ON)
endif()
endif()

if(ENABLE_CURLDEBUG)
Expand Down
2 changes: 1 addition & 1 deletion appveyor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
[ "${PRJ_CFG}" = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE='
[[ "${PRJ_GEN}" = *'Visual Studio'* ]] && options+=' -DCMAKE_VS_GLOBALS=TrackFileAccess=false'
if [ "${PRJ_GEN}" = 'Visual Studio 9 2008' ]; then
[ "${PRJ_CFG}" = 'Debug' ] && [ "${DEBUG}" = 'ON' ] && [ "${SHARED}" = 'ON' ] && SKIP_RUN='Crash on startup in -DDEBUGBUILD shared builds'
[ "${PRJ_CFG}" = 'Debug' ] && [ "${DEBUG}" = 'ON' ] && [ "${SHARED}" = 'ON' ] && SKIP_RUN='Crash on startup in ENABLE_DEBUG=ON shared builds'
# Fails to run without this due to missing MSVCR90.dll / MSVCR90D.dll
options+=' -DCURL_STATIC_CRT=ON'
fi
Expand Down

0 comments on commit e790429

Please sign in to comment.