Files
scylladb/cmake/mode.Coverage.cmake
Kefu Chai 4f361b73c4 build: cmake: consolidate the setting of cxx_flags
before this change, we define the CMAKE_CXX_FLAGS_${CONFIG} directly.
and some of the configurations are supposed to generate debugging info with
"-g -gz" options, but they failed to include these options in the cxx
flags.

in this change:

* a macro named `update_cxx_flags` is introduced to set this option.
* this macro also sets -O option

instead of using function, this facility is implemented as a macro so
that we can update the CMAKE_CXX_FLAGS_${CONFIG} without setting
this variable with awkward syntax like set

```cmake
set(${flags} "${${flags}}" PARENT_SCOPE)
```

this mirrors the behavior in configure.py in sense that the latter
sets the option on a per-mode basis, and interprets the option to
compiling option.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#16043
2023-11-14 11:21:52 +02:00

26 lines
669 B
CMake

set(Seastar_OptimizationLevel_COVERAGE "g")
set(CMAKE_CXX_FLAGS_COVERAGE
"-fprofile-instr-generate -fcoverage-mapping"
CACHE
INTERNAL
"")
update_cxx_flags(CMAKE_CXX_FLAGS_COVERAGE
WITH_DEBUG_INFO
OPTIMIZATION_LEVEL ${Seastar_OptimizationLevel_COVERAGE})
set(Seastar_DEFINITIONS_COVERAGE
SCYLLA_BUILD_MODE=coverage
DEBUG
SANITIZE
DEBUG_LSA_SANITIZER
SCYLLA_ENABLE_ERROR_INJECTION)
foreach(definition ${Seastar_DEFINITIONS_COVERAGE})
add_compile_definitions(
$<$<CONFIG:Coverage>:${definition}>)
endforeach()
set(CMAKE_STATIC_LINKER_FLAGS_COVERAGE
"-fprofile-instr-generate -fcoverage-mapping")
maybe_limit_stack_usage_in_KB(40 Coverage)