Changeset View
Changeset View
Standalone View
Standalone View
src/CMakeLists.txt
Show All 17 Lines | |||||
# Cmake uses the CMAKE_BUILD_TYPE variable to select the build configuration. | # Cmake uses the CMAKE_BUILD_TYPE variable to select the build configuration. | ||||
# By default it supports more configurations that needed for Bitcoin ABC, and | # By default it supports more configurations that needed for Bitcoin ABC, and | ||||
# all the releases types set NDEBUG which is unwanted as it disables the assert | # all the releases types set NDEBUG which is unwanted as it disables the assert | ||||
# completely. | # completely. | ||||
# We redefine here the flags to suite our needs, by overriding the built-in | # We redefine here the flags to suite our needs, by overriding the built-in | ||||
# RelWithDebInfo configuration (release with debug info). | # RelWithDebInfo configuration (release with debug info). | ||||
# RelWithDebInfo CFLAGS are set to -g -O2 | # CFLAGS are set to -g -O2 for all the configurations | ||||
set(RELWITHDEBINFO_G_C_FLAG "-g") | set(DEFAULT_G_C_FLAG "-g") | ||||
set(RELWITHDEBINFO_O_C_FLAG "-O2") | set(DEFAULT_O_C_FLAG "-O2") | ||||
# RelWithDebInfo CXXFLAGS flags are set to -g -O2 | # RelWithDebInfo CXXFLAGS flags are set to -g -O2 | ||||
set(RELWITHDEBINFO_G_CXX_FLAG "-g") | set(RELWITHDEBINFO_G_CXX_FLAG "-g") | ||||
set(RELWITHDEBINFO_O_CXX_FLAG "-O2") | set(RELWITHDEBINFO_O_CXX_FLAG "-O2") | ||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${DEFAULT_G_C_FLAG} ${DEFAULT_O_C_FLAG}") | ||||
deadalnix: The RELWITHDEBINFO_G_CXX_FLAG and it's O friend are now useless if you change this this way. | |||||
FabienAuthorUnsubmitted Done Inline ActionsI kept the C and CXX flags separated deliberately so one can update them independently. Fabien: I kept the C and CXX flags separated deliberately so one can update them independently. | |||||
"${RELWITHDEBINFO_G_C_FLAG} ${RELWITHDEBINFO_O_C_FLAG}") | |||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO | ||||
"${RELWITHDEBINFO_G_CXX_FLAG} ${RELWITHDEBINFO_O_CXX_FLAG}") | "${RELWITHDEBINFO_G_CXX_FLAG} ${RELWITHDEBINFO_O_CXX_FLAG}") | ||||
# Overrides the flags for the Debug cbuild type | |||||
include(CheckCXXCompilerFlag) | |||||
# Prefer -g3, defaults to -g if unavailable | |||||
set(DEBUG_G_CXX_FLAG "-g3") | |||||
CHECK_CXX_COMPILER_FLAG(${DEBUG_G_CXX_FLAG} FLAG_IS_SUPPORTED) | |||||
if(NOT FLAG_IS_SUPPORTED) | |||||
set(DEBUG_G_CXX_FLAG "-g") | |||||
endif() | |||||
deadalnixUnsubmitted Not Done Inline ActionsLooks like you'd need some kind of function or macro to do this. So you can do it for both C and C++. add_flag_with_fallback or something. deadalnix: Looks like you'd need some kind of function or macro to do this. So you can do it for both C… | |||||
FabienAuthorUnsubmitted Done Inline ActionsI will add a function or macro. The C flags remain -g -O2 here to get the same behavior than configure --enable-debug. Fabien: I will add a function or macro.
The C flags remain `-g -O2` here to get the same behavior than… | |||||
# Prefer -Og, defaults to -O0 if unavailable | |||||
set(DEBUG_O_CXX_FLAG "-Og") | |||||
CHECK_CXX_COMPILER_FLAG(${DEBUG_O_CXX_FLAG} FLAG_IS_SUPPORTED) | |||||
if(NOT FLAG_IS_SUPPORTED) | |||||
set(DEBUG_O_CXX_FLAG "-O0") | |||||
endif() | |||||
set(CMAKE_C_FLAGS_DEBUG "${DEFAULT_G_C_FLAG} ${DEFAULT_O_C_FLAG}") | |||||
set(CMAKE_CXX_FLAGS_DEBUG "${DEBUG_G_CXX_FLAG} ${DEBUG_O_CXX_FLAG}") | |||||
# Define the debugging symbols DEBUG and DEBUG_LOCKORDER | |||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DDEBUG_LOCKORDER") | |||||
# Ensure that WINDRES_PREPROC is enabled when using windres. | # Ensure that WINDRES_PREPROC is enabled when using windres. | ||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
list(APPEND CMAKE_RC_FLAGS "-DWINDRES_PREPROC") | list(APPEND CMAKE_RC_FLAGS "-DWINDRES_PREPROC") | ||||
endif() | endif() | ||||
# Enable warning | # Enable warning | ||||
include(AddCompilerFlags) | include(AddCompilerFlags) | ||||
▲ Show 20 Lines • Show All 282 Lines • Show Last 20 Lines |
The RELWITHDEBINFO_G_CXX_FLAG and it's O friend are now useless if you change this this way.