build: put coverage items in more sane locations

This commit is contained in:
sithlord48 2026-07-19 12:05:59 -04:00 committed by Nick Bolton
parent d3e5a94861
commit 48ee839357
3 changed files with 23 additions and 23 deletions

View file

@ -18,6 +18,7 @@ endif()
#Project level options #Project level options
option(BUILD_INSTALLER "Build installer" ON) option(BUILD_INSTALLER "Build installer" ON)
option(ENABLE_COVERAGE "Enable test coverage" OFF)
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
option(BUILD_OSX_BUNDLE "Build mac os bundle" ON) option(BUILD_OSX_BUNDLE "Build mac os bundle" ON)
@ -198,6 +199,16 @@ message(STATUS "Qt version: ${Qt6_VERSION}")
include(cmake/Libraries.cmake) include(cmake/Libraries.cmake)
configure_libs() configure_libs()
if(ENABLE_COVERAGE)
message(STATUS "Enabling code coverage")
include(cmake/CodeCoverage.cmake)
append_coverage_compiler_flags()
# Apparently solves the bug in gcov where it returns negative counts and confuses gcovr.
# > Got negative hit value in gcov line 'branch 2 taken -1' caused by a bug in gcov tool
# Bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-update=atomic")
endif()
if(BUILD_OSX_BUNDLE AND APPLE_CODESIGN_DEV) if(BUILD_OSX_BUNDLE AND APPLE_CODESIGN_DEV)
include(cmake/MacCodesign.cmake) include(cmake/MacCodesign.cmake)
endif() endif()

View file

@ -32,28 +32,6 @@ macro(configure_libs)
if(HAVE_FORMAT) if(HAVE_FORMAT)
add_definitions(-DHAVE_FORMAT) add_definitions(-DHAVE_FORMAT)
endif() endif()
option(ENABLE_COVERAGE "Enable test coverage" OFF)
if(ENABLE_COVERAGE)
message(STATUS "Enabling code coverage")
include(cmake/CodeCoverage.cmake)
append_coverage_compiler_flags()
set(test_exclude subprojects/* build/* src/unittests/*)
set(test_src ${PROJECT_SOURCE_DIR}/src)
# Apparently solves the bug in gcov where it returns negative counts and confuses gcovr.
# > Got negative hit value in gcov line 'branch 2 taken -1' caused by a bug in gcov tool
# Bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-update=atomic")
setup_target_for_coverage_gcovr_xml(
NAME coverage-legacytests
EXECUTABLE legacytests
BASE_DIRECTORY ${test_src}
EXCLUDE ${test_exclude}
)
endif()
endmacro() endmacro()
# #
@ -80,7 +58,6 @@ macro(configure_unix_libs)
message(FATAL_ERROR "Missing header: sys/socket.h") message(FATAL_ERROR "Missing header: sys/socket.h")
endif() endif()
check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(unistd.h HAVE_UNISTD_H)
if (NOT HAVE_UNISTD_H) if (NOT HAVE_UNISTD_H)
message(FATAL_ERROR "Missing unistd.h") message(FATAL_ERROR "Missing unistd.h")

View file

@ -7,3 +7,15 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(target legacytests) set(target legacytests)
add_executable(${target} ${sources} ${headers}) add_executable(${target} ${sources} ${headers})
target_link_libraries(${target} ${test_libs} common) target_link_libraries(${target} ${test_libs} common)
if(ENABLE_COVERAGE)
set(test_exclude subprojects/* build/* src/unittests/*)
set(test_src ${PROJECT_SOURCE_DIR}/src)
setup_target_for_coverage_gcovr_xml(
NAME coverage-${target}
EXECUTABLE ${target}
BASE_DIRECTORY ${test_src}
EXCLUDE ${test_exclude}
)
endif()