Skip to content

Commit

Permalink
build(c): set -Og -ggdb and warn about Conda setting -O2
Browse files Browse the repository at this point in the history
Fixes #1608.
  • Loading branch information
lidavidm committed Mar 12, 2024
1 parent 7b185fe commit 862efbf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion c/cmake_modules/AdbcDefines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT)
endif()

# Set common build options
string(TOLOWER "${CMAKE_BUILD_TYPE}" _lower_build_type)
if("${ADBC_BUILD_WARNING_LEVEL}" STREQUAL "")
string(TOLOWER "${CMAKE_BUILD_TYPE}" _lower_build_type)
if("${_lower_build_type}" STREQUAL "release")
set(ADBC_BUILD_WARNING_LEVEL "PRODUCTION")
else()
Expand Down Expand Up @@ -92,6 +92,17 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
-Werror
-Wno-unused-parameter)
set(ADBC_C_CXX_FLAGS_PRODUCTION -Wall)

string(APPEND C_DEBUG_FLAGS " -Og -ggdb")
string(APPEND CXX_DEBUG_FLAGS " -Og -ggdb")
string(APPEND C_RELWITHDEBINFO_FLAGS " -Og -ggdb")
string(APPEND CXX_RELWITHDEBINFO_FLAGS " -Og -ggdb")

if("${_lower_build_type}" STREQUAL "debug" AND "${CMAKE_CXX_FLAGS}" MATCHES "-O2")
# Activate scripts for Conda compilers set CXXFLAGS etc. with -O2.
message(WARNING "This is a debug build, but your CXXFLAGS have -O2. This is common in Conda environments.\nReset your CFLAGS, CPPFLAGS, and CXXFLAGS to -Og for debugging."
)
endif()
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
Expand Down

0 comments on commit 862efbf

Please sign in to comment.