cmake,makefile: think of clang++, too
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-07 05:02:52 +01:00
parent c93a524ca6
commit d4c7c61ac4
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 31 additions and 10 deletions

View File

@ -43,7 +43,9 @@ add_subdirectory(lib/da_threading EXCLUDE_FROM_ALL)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -grecord-gcc-switches")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -grecord-gcc-switches")
endif()
# Produce debugging information in the operating system's native format.
# Level 3 includes extra information, such as all the macro definitions
@ -76,8 +78,6 @@ add_subdirectory(lib/da_threading EXCLUDE_FROM_ALL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-address-use-after-scope")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-clash-protection")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
# clang-only atm
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=safe-stack")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=bounds")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=vptr")
@ -91,6 +91,13 @@ add_subdirectory(lib/da_threading EXCLUDE_FROM_ALL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=unreachable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=alignment")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=object-size")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address" OR "-fsanitize=leak")
# clang-only atm
# also doesn't like asan, leaksan et al.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=safe-stack")
endif()
endif()
endif(SAN)

View File

@ -4,11 +4,15 @@ c = cmake
c_args = -G Ninja -DCMAKE_BUILD_TYPE=
c_args_d = $(c_args)Debug
c_args_r = $(c_args)Release
cl = -DCMAKE_CXX_COMPILER=clang++
g = -DCMAKE_CXX_COMPILER=g++
n = ninja
n_args = -C
d_folder = cmake-build-debug
d_folder_cl = $(d_folder)_cl
r_folder = cmake-build-release
s_folder = cmake-build-san
s_folder_cl = $(s_folder)_cl
s_on = -DSAN=ON
s_off = -DSAN=OFF
t_on = -DTIDY=ON
@ -19,16 +23,21 @@ v_off = -DVALGRIND=OFF
v_db = $(d_folder)_valgr
v_rl = $(r_folder)_valgr
.PHONY: check tidy build debug release valgrind san test clean distclean
.PHONY: check tidy build debug debug_cl release valgrind san san_cl test clean distclean
debug:
if [ ! -d "$(d_folder)" ]; then mkdir -pv $(d_folder); fi
$(c) $(c_args_d) $(s_off) $(t_off) $(v_off) -B$(d_folder)
$(c) $(c_args_d) $(g) $(s_off) $(t_off) $(v_off) -B$(d_folder)
$(n) $(n_args) $(d_folder)
debug_cl:
if [ ! -d "$(d_folder_cl)" ]; then mkdir -pv $(d_folder_cl); fi
$(c) $(c_args_d) $(cl) $(s_off) $(t_off) $(v_off) -B$(d_folder_cl)
$(n) $(n_args) $(d_folder_cl)
release:
if [ ! -d "$(r_folder)" ]; then mkdir -pv $(r_folder); fi
$(c) $(c_args_r) $(s_off) $(t_off) $(v_off) -B$(r_folder)
$(c) $(c_args_r) $(g) $(s_off) $(t_off) $(v_off) -B$(r_folder)
$(n) $(n_args) $(r_folder)
check:
@ -37,26 +46,31 @@ check:
san:
if [ ! -d "$(s_folder)" ]; then mkdir -pv $(s_folder); fi
$(c) $(c_args_d) $(s_on) $(t_off) $(v_off) -B$(s_folder)
$(c) $(c_args_d) $(g) $(s_on) $(t_off) $(v_off) -B$(s_folder)
$(n) $(n_args) $(s_folder)
san_cl:
if [ ! -d "$(s_folder_cl)" ]; then mkdir -pv $(s_folder_cl); fi
$(c) $(c_args_d) $(cl) $(s_on) $(t_off) $(v_off) -B$(s_folder_cl)
$(n) $(n_args) $(s_folder_cl)
tidy:
if [ ! -d "$(d_folder)" ]; then mkdir -pv $(d_folder); fi
$(c) $(c_args_d) $(s_off) $(t_on) $(v_off) -B$(d_folder)
$(c) $(c_args_d) $(g) $(s_off) $(t_on) $(v_off) -B$(d_folder)
$(n) $(n_args) $(d_folder)
valgrind: valgrind-debug
valgrind-debug:
if [ ! -d "$(v_db)" ]; then mkdir -pv "$(v_db)"; fi
$(c) $(c_args_d) $(s_off) $(t_off) $(v_on) -B"$(v_db)"
$(c) $(c_args_d) $(g) $(s_off) $(t_off) $(v_on) -B"$(v_db)"
$(n) $(n_args) "$(v_db)"
$(v) --leak-check=full ./$(v_db)/fortuna
valgrind-release:
if [ ! -d "$(v_rl)" ]; then mkdir -pv "$(v_rl)"; fi
$(c) $(c_args_r) $(s_off) $(t_off) $(v_on) -B"$(v_rl)"
$(c) $(c_args_r) $(g) $(s_off) $(t_off) $(v_on) -B"$(v_rl)"
$(n) $(n_args) "$(v_rl)"
$(v) ./$(v_rl)/fortuna