From 1ec17aeb185ec7851a41c0ba2ae14c95a1a3942e Mon Sep 17 00:00:00 2001 From: 0scar Date: Wed, 2 Aug 2023 17:07:19 +0200 Subject: Change some flags and stuff --- CMakeLists.txt | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8928417..3e93f70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,17 +92,33 @@ target_link_libraries(${PROJECT_NAME} target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON) +if(DAW_BUILD_ASAN AND NOT C_COMPILER_ID STREQUAL MSVC) + add_compile_options(-fsanitize=address -fsanitize=leak -fsanitize-address-use-after-scope) + add_link_options(-fsanitize=address -fsanitize=leak -fsanitize-address-use-after-scope) +endif() + +if(DAW_BUILD_UBSAN AND NOT C_COMPILER_ID STREQUAL MSVC) + add_compile_options(-fsanitize=undefined -fsanitize-undefined-trap-on-error -fno-sanitize-recover) + add_link_options(-fsanitize=undefined -fsanitize-undefined-trap-on-error -fno-sanitize-recover) +endif() + +if(DAW_BUILD_DEBUG) + set(BUILD_OPTS -Og -ggdb3 -fno-omit-frame-pointer) +else() + set(BUILD_OPTS -O2 -flto=auto -fuse-linker-plugin -ffat-lto-objects + -funroll-loops -ffast-math -fno-signed-zeros -fno-trapping-math + -ffunction-sections -fdata-sections) +endif() + +add_compile_options(${RELEASE_OPTS}) +add_link_options(${RELEASE_OPTS}) + target_compile_options(${PROJECT_NAME} PUBLIC $<$>:-Wall -Wextra> # Dont be pedantic when using hot reloading. $<$>,$>>:-pedantic> $<$:/W4> # Debug related flags. sorry windows, you're just not that important. - $<$>,$>:-Og -ggdb3 -fno-omit-frame-pointer> - $<$>,$>:-fsanitize=address -fsanitize=leak -fsanitize-address-use-after-scope> - $<$>,$>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fno-sanitize-recover> - - $<$>,$>>:-O2 -flto=auto -fuse-linker-plugin -ffat-lto-objects -funroll-loops -ffast-math -fno-signed-zeros -fno-trapping-math -ffunction-sections -fdata-sections> ) target_compile_definitions(${PROJECT_NAME} PUBLIC -- cgit v1.3