diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2023-08-02 15:07:19 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2023-08-14 10:11:28 +0000 |
| commit | 1ec17aeb185ec7851a41c0ba2ae14c95a1a3942e (patch) | |
| tree | 7062435e115f6c0895a7ea9c1c3336691da99e75 /CMakeLists.txt | |
| parent | 1713482a2af615daa83887278716736799389c3d (diff) | |
Change some flags and stuff
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 26 |
1 files 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 $<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wall -Wextra> # Dont be pedantic when using hot reloading. $<$<AND:$<NOT:$<C_COMPILER_ID:MSVC>>,$<NOT:$<BOOL:${DAW_BUILD_HOTRELOAD}>>>:-pedantic> $<$<C_COMPILER_ID:MSVC>:/W4> # Debug related flags. sorry windows, you're just not that important. - $<$<AND:$<NOT:$<C_COMPILER_ID:MSVC>>,$<BOOL:${DAW_BUILD_DEBUG}>>:-Og -ggdb3 -fno-omit-frame-pointer> - $<$<AND:$<NOT:$<C_COMPILER_ID:MSVC>>,$<BOOL:${DAW_BUILD_ASAN}>>:-fsanitize=address -fsanitize=leak -fsanitize-address-use-after-scope> - $<$<AND:$<NOT:$<C_COMPILER_ID:MSVC>>,$<BOOL:${DAW_BUILD_UBSAN}>>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fno-sanitize-recover> - - $<$<AND:$<NOT:$<C_COMPILER_ID:MSVC>>,$<NOT:$<BOOL:${DAW_BUILD_DEBUG}>>>:-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 |
