From 33c7b9701de1589e8e3875656a6bab4f8710e7a8 Mon Sep 17 00:00:00 2001 From: Nicky Dasmijn Date: Fri, 12 Apr 2024 14:15:01 +0200 Subject: Chore/cmake pretty up (#1205) * - Add an option to with ASAN - Fix GCC -Werror option. * - find_program should not set REQUIRED if per logic a fallback to ld.bfd is fine - cmake idiomatic is to test Variables without dereferencing them * Add -Wno-unknown-warning-option for clang or it will complain about some GCC only options ``` /home/runner/work/viewer/viewer/indra/llcommon/llsdutil.cpp:39:32: error: unknown warning group '-Wstringop-truncation', ignored [-Werror,-Wunknown-warning-option] #pragma GCC diagnostic ignored "-Wstringop-truncation" // It's actually okay what happens here ``` --- indra/cmake/00-Common.cmake | 14 ++++++++++++-- indra/cmake/Linker.cmake | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 21242a32be..d90a34bb6b 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -124,11 +124,20 @@ if (LINUX) add_compile_definitions( _REENTRANT - _FORTIFY_SOURCE=2 APPID=secondlife LL_IGNORE_SIGCHLD ) + if( ENABLE_ASAN ) + add_compile_options(-U_FORTIFY_SOURCE + -fsanitize=address + --param asan-stack=0 + ) + add_link_options(-fsanitize=address) + else() + add_compile_definitions( _FORTIFY_SOURCE=2 ) + endif() + add_compile_options( -fexceptions -fno-math-errno @@ -150,6 +159,7 @@ if (LINUX) set(CLANG_WARNINGS ${GCC_CLANG_COMPATIBLE_WARNINGS} # Put clang specific warning configuration here + -Wno-unknown-warning-option ) set(GCC_WARNINGS @@ -165,7 +175,7 @@ if (LINUX) -Wl,--no-undefined ) if (NOT GCC_DISABLE_FATAL_WARNINGS) - list(APPEND GCC_WARNINGS -Werror) + add_compile_options( -Werror ) endif (NOT GCC_DISABLE_FATAL_WARNINGS) # this stops us requiring a really recent glibc at runtime diff --git a/indra/cmake/Linker.cmake b/indra/cmake/Linker.cmake index 292aa25c57..8016842192 100644 --- a/indra/cmake/Linker.cmake +++ b/indra/cmake/Linker.cmake @@ -1,7 +1,7 @@ include_guard(GLOBAL) -if (${LINK_WITH_MOLD}) - find_program(MOLD_BIN mold REQUIRED) +if( LINK_WITH_MOLD ) + find_program(MOLD_BIN mold) if(MOLD_BIN) message(STATUS "Mold linker found: ${MOLD_BIN}. Enabling mold as active linker.") add_link_options("-fuse-ld=${MOLD_BIN}") -- cgit v1.2.3