Files
TrinityCore/cmake/compiler/clang/settings.cmake
Peter Keresztes Schmidt 44ea32ace4 Build: Enable -Wimplicit-fallthrough on clang (#25056)
* Misc: Use [[fallthrough]] attribute instead of comment to mark intentional fallthroughs

Related: #25006

* Misc: Add some missing breaks (no-ops) to satisfy clang

Related: #25006
Closes #25055

* Build: Enable -Wimplicit-fallthrough on clang

Closes #25006
2022-01-23 22:16:15 +01:00

120 lines
3.1 KiB
CMake

include(CheckCXXSourceCompiles)
# Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="$<CONFIG>")
if(WITH_WARNINGS)
target_compile_options(trinity-warning-interface
INTERFACE
-W
-Wall
-Wextra
-Wimplicit-fallthrough
-Winit-self
-Wfatal-errors
-Wno-mismatched-tags
-Woverloaded-virtual)
message(STATUS "Clang: All warnings enabled")
endif()
if(WITH_COREDEBUG)
target_compile_options(trinity-compile-option-interface
INTERFACE
-g3)
message(STATUS "Clang: Debug-flags set (-g3)")
endif()
if(ASAN)
target_compile_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=address
-fsanitize-recover=address
-fsanitize-address-use-after-scope)
target_link_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=address
-fsanitize-recover=address
-fsanitize-address-use-after-scope)
message(STATUS "Clang: Enabled Address Sanitizer ASan")
endif()
if(MSAN)
target_compile_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=memory
-fsanitize-memory-track-origins
-mllvm
-msan-keep-going=1)
target_link_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=memory
-fsanitize-memory-track-origins)
message(STATUS "Clang: Enabled Memory Sanitizer MSan")
endif()
if(UBSAN)
target_compile_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=undefined)
target_link_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=undefined)
message(STATUS "Clang: Enabled Undefined Behavior Sanitizer UBSan")
endif()
if(TSAN)
target_compile_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=thread)
target_link_options(trinity-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=thread)
message(STATUS "Clang: Enabled Thread Sanitizer TSan")
endif()
# -Wno-narrowing needed to suppress a warning in g3d
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
# -Wno-deprecated-copy needed to suppress a warning in g3d
target_compile_options(trinity-compile-option-interface
INTERFACE
-Wno-narrowing
-Wno-deprecated-register)
if(BUILD_SHARED_LIBS)
# -fPIC is needed to allow static linking in shared libs.
# -fvisibility=hidden sets the default visibility to hidden to prevent exporting of all symbols.
target_compile_options(trinity-compile-option-interface
INTERFACE
-fPIC)
target_compile_options(trinity-hidden-symbols-interface
INTERFACE
-fvisibility=hidden)
# --no-undefined to throw errors when there are undefined symbols
# (caused through missing TRINITY_*_API macros).
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --no-undefined")
message(STATUS "Clang: Disallow undefined symbols")
endif()