mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-03 08:46:36 +00:00
introduces native llvm source-based coverage as an alternative to the existing gcov + gcovr pipeline. driven by a new -Dcoverage_tool cache variable (default 'gcov' for backwards compat; 'llvm' enables -fprofile-instr-generate / -fcoverage-mapping + llvm-profdata + llvm-cov). cmake: - RippledSettings.cmake: add coverage_tool with validation - RippledInterface.cmake: split coverage compile/link flags by tool - RippledCov.cmake: dispatch to the new helper when tool=llvm - CodeCoverageLLVM.cmake (new): setup_target_for_coverage_llvm() driving profraw -> profdata -> export with format-aware output (lcov/json/txt/html) ci: - new clang-20 llvm-cov coverage matrix row (apt.llvm.org bootstrap for clang >= 19 since 24.04 default repos cap at clang-18) - conditional install of llvm-N vs gcovr based on coverage_tool - artifact + codecov upload generalised to coverage.lcov | coverage.xml - coverage cmake-args switched to *_FLAGS_DEBUG so the build action's stdlib flag isn't clobbered temp (revert before merging to dev): - matrix narrowed to just the llvm-cov row on non-main refs so we can iterate without burning runners - 'coverage-llm' added to push trigger for direct-push CI runs
111 lines
4.2 KiB
CMake
111 lines
4.2 KiB
CMake
#[===================================================================[
|
|
rippled compile options/settings via an interface library
|
|
#]===================================================================]
|
|
|
|
add_library (opts INTERFACE)
|
|
add_library (Ripple::opts ALIAS opts)
|
|
target_compile_definitions (opts
|
|
INTERFACE
|
|
BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS
|
|
BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT
|
|
BOOST_CONTAINER_FWD_BAD_DEQUE
|
|
HAS_UNCAUGHT_EXCEPTIONS=1
|
|
$<$<BOOL:${boost_show_deprecated}>:
|
|
BOOST_ASIO_NO_DEPRECATED
|
|
BOOST_FILESYSTEM_NO_DEPRECATED
|
|
>
|
|
$<$<NOT:$<BOOL:${boost_show_deprecated}>>:
|
|
BOOST_COROUTINES_NO_DEPRECATION_WARNING
|
|
BOOST_BEAST_ALLOW_DEPRECATED
|
|
BOOST_FILESYSTEM_DEPRECATED
|
|
>
|
|
$<$<BOOL:${beast_no_unit_test_inline}>:BEAST_NO_UNIT_TEST_INLINE=1>
|
|
$<$<BOOL:${beast_disable_autolink}>:BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES=1>
|
|
$<$<BOOL:${single_io_service_thread}>:RIPPLE_SINGLE_IO_SERVICE_THREAD=1>
|
|
$<$<BOOL:${voidstar}>:ENABLE_VOIDSTAR>)
|
|
target_compile_options (opts
|
|
INTERFACE
|
|
$<$<AND:$<BOOL:${is_gcc}>,$<COMPILE_LANGUAGE:CXX>>:-Wsuggest-override>
|
|
$<$<BOOL:${is_gcc}>:-Wno-maybe-uninitialized>
|
|
$<$<BOOL:${perf}>:-fno-omit-frame-pointer>
|
|
$<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${coverage}>,$<STREQUAL:${coverage_tool},gcov>>:-g --coverage -fprofile-abs-path>
|
|
$<$<AND:$<BOOL:${is_clang}>,$<BOOL:${coverage}>,$<STREQUAL:${coverage_tool},gcov>>:-g --coverage>
|
|
$<$<AND:$<BOOL:${is_clang}>,$<BOOL:${coverage}>,$<STREQUAL:${coverage_tool},llvm>>:-g -fprofile-instr-generate -fcoverage-mapping>
|
|
$<$<BOOL:${profile}>:-pg>
|
|
$<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${profile}>>:-p>)
|
|
|
|
target_link_libraries (opts
|
|
INTERFACE
|
|
$<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${coverage}>,$<STREQUAL:${coverage_tool},gcov>>:-g --coverage -fprofile-abs-path>
|
|
$<$<AND:$<BOOL:${is_clang}>,$<BOOL:${coverage}>,$<STREQUAL:${coverage_tool},gcov>>:-g --coverage>
|
|
$<$<AND:$<BOOL:${is_clang}>,$<BOOL:${coverage}>,$<STREQUAL:${coverage_tool},llvm>>:-g -fprofile-instr-generate -fcoverage-mapping>
|
|
$<$<BOOL:${profile}>:-pg>
|
|
$<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${profile}>>:-p>)
|
|
|
|
if (jemalloc)
|
|
if (static)
|
|
set(JEMALLOC_USE_STATIC ON CACHE BOOL "" FORCE)
|
|
endif ()
|
|
find_package (jemalloc REQUIRED)
|
|
target_compile_definitions (opts INTERFACE PROFILE_JEMALLOC)
|
|
target_include_directories (opts SYSTEM INTERFACE ${JEMALLOC_INCLUDE_DIRS})
|
|
target_link_libraries (opts INTERFACE ${JEMALLOC_LIBRARIES})
|
|
get_filename_component (JEMALLOC_LIB_PATH ${JEMALLOC_LIBRARIES} DIRECTORY)
|
|
## TODO see if we can use the BUILD_RPATH target property (is it transitive?)
|
|
set (CMAKE_BUILD_RPATH ${CMAKE_BUILD_RPATH} ${JEMALLOC_LIB_PATH})
|
|
endif ()
|
|
|
|
if (san)
|
|
target_compile_options (opts
|
|
INTERFACE
|
|
# sanitizers recommend minimum of -O1 for reasonable performance
|
|
$<$<CONFIG:Debug>:-O1>
|
|
${SAN_FLAG}
|
|
-fno-omit-frame-pointer)
|
|
target_compile_definitions (opts
|
|
INTERFACE
|
|
$<$<STREQUAL:${san},address>:SANITIZER=ASAN>
|
|
$<$<STREQUAL:${san},thread>:SANITIZER=TSAN>
|
|
$<$<STREQUAL:${san},memory>:SANITIZER=MSAN>
|
|
$<$<STREQUAL:${san},undefined>:SANITIZER=UBSAN>)
|
|
target_link_libraries (opts INTERFACE ${SAN_FLAG} ${SAN_LIB})
|
|
endif ()
|
|
|
|
#[===================================================================[
|
|
rippled transitive library deps via an interface library
|
|
#]===================================================================]
|
|
|
|
add_library (ripple_syslibs INTERFACE)
|
|
add_library (Ripple::syslibs ALIAS ripple_syslibs)
|
|
target_link_libraries (ripple_syslibs
|
|
INTERFACE
|
|
$<$<BOOL:${MSVC}>:
|
|
legacy_stdio_definitions.lib
|
|
Shlwapi
|
|
kernel32
|
|
user32
|
|
gdi32
|
|
winspool
|
|
comdlg32
|
|
advapi32
|
|
shell32
|
|
ole32
|
|
oleaut32
|
|
uuid
|
|
odbc32
|
|
odbccp32
|
|
crypt32
|
|
>
|
|
$<$<NOT:$<BOOL:${MSVC}>>:dl>
|
|
$<$<NOT:$<OR:$<BOOL:${MSVC}>,$<BOOL:${APPLE}>>>:rt>)
|
|
|
|
if (NOT MSVC)
|
|
set (THREADS_PREFER_PTHREAD_FLAG ON)
|
|
find_package (Threads)
|
|
target_link_libraries (ripple_syslibs INTERFACE Threads::Threads)
|
|
endif ()
|
|
|
|
add_library (ripple_libs INTERFACE)
|
|
add_library (Ripple::libs ALIAS ripple_libs)
|
|
target_link_libraries (ripple_libs INTERFACE Ripple::syslibs)
|