cmake: add {-g3,-gsplit-dwarf} flags for debugging
All checks were successful
continuous-integration/drone/push Build is passing

cmake:
* check if we're being run for valgrind, in which case do not split
  dwarf information, valgrinds does not like it (see #1).

makefile:
* build for vagrant into a separate folder entirely.

ci:
* install gcc, cmake and ninja along with vagrant, since now we are
  building inside of the ci container as well.

close #1
This commit is contained in:
surtur 2021-11-01 09:10:32 +01:00
parent 5f8f8ca67e
commit 46a6cdba3a
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
3 changed files with 35 additions and 6 deletions

@ -58,7 +58,7 @@ def main(ctx):
"depends_on": ["build debug"],
"commands": [
"uname -r",
"pacman -Sy valgrind --noconfirm --needed",
"pacman -Sy gcc cmake ninja valgrind --noconfirm --needed",
"valgrind --version",
"make valgrind"
]
@ -70,7 +70,7 @@ def main(ctx):
"depends_on": ["build release"],
"commands": [
"uname -r",
"pacman -Sy valgrind --noconfirm --needed",
"pacman -Sy gcc cmake ninja valgrind --noconfirm --needed",
"valgrind --version",
"make valgrind-release"
]

@ -4,6 +4,26 @@ project(fortuna LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
# Produce debugging information in the operating system's native format.
# Level 3 includes extra information, such as all the macro definitions
# present in the program. Some debuggers support macro expansion when you
# use -g3
if(NOT CMAKE_CXX_FLAGS MATCHES "-g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-g")
if(NOT $ENV{VALGRIND} MATCHES "true")
# If DWARF debugging information is enabled, separate as much debugging
# information as possible into a separate output file with the extension
# .dwo. This option allows the build system to avoid linking files with
# debug information.
if(NOT CMAKE_CXX_FLAGS MATCHES "-gsplit-dwarf")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-gsplit-dwarf")
else()
message(STATUS "VALGRIND=true, not setting '-gsplit-dwarf'")
endif(NOT $ENV{VALGRIND} MATCHES "true")
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")

@ -10,17 +10,20 @@ r_folder = cmake-build-release
t = clang-tidy
t_args = --config="" --format-style=google --checks="clang-diagnostic-*,clang-analyzer-*,google-*" --use-color=true -p $(d_folder) ./*.{cpp,h}
v = valgrind
v_env = VALGRIND=
v_db = $(d_folder)_valgr
v_rl = $(r_folder)_valgr
.PHONY: check tidy build debug release valgrind test
debug:
if [ ! -d "$(d_folder)" ]; then mkdir -pv $(d_folder); fi
$(c) $(c_args)Debug -B $(d_folder) $(cpp_flags) && \
$(v_env)false $(c) $(c_args)Debug -B $(d_folder) $(cpp_flags) && \
$(n) $(n_args) $(d_folder)
release:
if [ ! -d "$(r_folder)" ]; then mkdir -pv $(r_folder); fi
$(c) $(c_args)Release -B $(r_folder) $(cpp_flags) && \
$(v_env)false $(c) $(c_args)Release -B $(r_folder) $(cpp_flags) && \
$(n) $(n_args) $(r_folder)
check:
@ -33,10 +36,16 @@ tidy:
valgrind: valgrind-debug
valgrind-debug:
$(v) ./$(d_folder)/fortuna
if [ ! -d "$(v_db)" ]; then mkdir -pv "$(v_db)"; fi
$(v_env)true $(c) $(c_args)Debug -B "$(v_db)" $(cpp_flags) && \
$(n) $(n_args) "$(v_db)"
$(v) ./$(v_db)/fortuna
valgrind-release:
$(v) ./$(r_folder)/fortuna
if [ ! -d "$(v_rl)" ]; then mkdir -pv "$(v_rl)"; fi
$(v_env)true $(c) $(c_args)Release -B "$(v_rl)" $(cpp_flags) && \
$(n) $(n_args) "$(v_rl)"
$(v) ./$(v_rl)/fortuna
build: debug