mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
* Add FPRIME_CMAKE_QUIET option * Remove makefile deadcode * Attempt CI debug Add debugging message for FPRIME_SUB_BUILD_JOBS variable. * Fix argument passing for sub-build jobs * Update cmake/sub-build/sub-build.cmake * Update cmake/sub-build/sub-build.cmake --------- Co-authored-by: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com>
53 lines
2.0 KiB
CMake
53 lines
2.0 KiB
CMake
####
|
|
# sanitizers.cmake:
|
|
#
|
|
# Enables sanitizers in the build settings when requested by the user with -DENABLE_SANITIZER_<...>=ON.
|
|
#
|
|
# Sanitizers, by default, output their logs to stderr. To redirect the output to files instead, use the
|
|
# `log_path` option from the sanitizer <SAN>_OPTIONS environment variable at runtime. For example, with UBSAN:
|
|
# >>> UBSAN_OPTIONS="log_path=/path/to/output_dir/file_prefix" fprime-util check
|
|
# or
|
|
# >>> UBSAN_OPTIONS="log_path=/path/to/output_dir/file_prefix" ./path/to/executable
|
|
#
|
|
# Note: <file_prefix> is a prefix to which the sanitizer will add a unique ID to generate a unique filename.
|
|
# If a relative path is specified, this will be relative to the component's folder **in the build cache**
|
|
# if using fprime-util check, OR relative to the current directory if running a single executable.
|
|
####
|
|
include(utilities)
|
|
include_guard()
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
|
set(SANITIZERS)
|
|
|
|
if(ENABLE_SANITIZER_ADDRESS)
|
|
list(APPEND SANITIZERS "address")
|
|
endif()
|
|
|
|
if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR)
|
|
list(APPEND SANITIZERS "undefined")
|
|
endif()
|
|
|
|
if(ENABLE_SANITIZER_LEAK)
|
|
if(APPLE)
|
|
fprime_cmake_warning("Leak sanitizer is not supported on macOS")
|
|
else()
|
|
list(APPEND SANITIZERS "leak")
|
|
endif()
|
|
endif()
|
|
|
|
if(ENABLE_SANITIZER_THREAD)
|
|
if("address" IN_LIST SANITIZERS OR "leak" IN_LIST SANITIZERS)
|
|
fprime_cmake_warning("Thread sanitizer does not work with Address or Leak sanitizer enabled")
|
|
else()
|
|
list(APPEND SANITIZERS "thread")
|
|
endif()
|
|
endif()
|
|
|
|
list(JOIN SANITIZERS "," LIST_OF_SANITIZERS)
|
|
|
|
if(LIST_OF_SANITIZERS AND NOT "${LIST_OF_SANITIZERS}" STREQUAL "")
|
|
fprime_cmake_status("Enabled the following sanitizers: ${LIST_OF_SANITIZERS}")
|
|
add_compile_options(-fsanitize=${LIST_OF_SANITIZERS})
|
|
add_link_options(-fsanitize=${LIST_OF_SANITIZERS})
|
|
endif()
|
|
endif()
|