- Add ENABLE_COVERAGE CMake option with gcov flags - Create collect-coverage.sh script for LCOV workflow - Add Qt6 test files with QTest framework - Update Jenkinsfile with Coverage stage (main/master/coverage.*) - Update CI Docker image with lcov and genhtml packages - Add .gitignore entries for coverage artifacts - Add COVERAGE.md documentation Coverage workflow: 1. Configure with -DENABLE_COVERAGE=ON 2. Build and run tests to generate .gcda/.gcno files 3. Collect coverage with lcov 4. Filter out Qt/system libraries 5. Generate HTML report and lcov.info for Jenkins Jenkins publishes coverage/lcov.info using Coverage Plugin. Coverage stage only runs on protected branches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: 7783c7698334 Entire-Checkpoint: 70341e29996b Signed-off-by: twi-devel <torsten.wierschin@life-maps.com>
96 lines
2.1 KiB
CMake
96 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(Qt6MigratedBenchmark LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTOUIC ON)
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
# Coverage option - disabled by default
|
|
option(ENABLE_COVERAGE "Enable code coverage with gcov/lcov" OFF)
|
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
|
|
|
qt_standard_project_setup(REQUIRES 6.5)
|
|
|
|
add_executable(Qt6MigratedBenchmark
|
|
main.cpp
|
|
MainWindow.h
|
|
MainWindow.cpp
|
|
MainWindow.ui
|
|
resources.qrc
|
|
)
|
|
|
|
target_link_libraries(Qt6MigratedBenchmark PRIVATE
|
|
Qt6::Core
|
|
Qt6::Gui
|
|
Qt6::Widgets
|
|
)
|
|
|
|
# Coverage configuration
|
|
if(ENABLE_COVERAGE)
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
message(STATUS "Coverage enabled for ${CMAKE_CXX_COMPILER_ID}")
|
|
|
|
# Add coverage flags
|
|
target_compile_options(Qt6MigratedBenchmark PRIVATE
|
|
-g
|
|
-O0
|
|
--coverage
|
|
-fprofile-arcs
|
|
-ftest-coverage
|
|
)
|
|
|
|
target_link_options(Qt6MigratedBenchmark PRIVATE
|
|
--coverage
|
|
-fprofile-arcs
|
|
-ftest-coverage
|
|
)
|
|
else()
|
|
message(WARNING "Coverage is only supported with GCC or Clang")
|
|
endif()
|
|
endif()
|
|
|
|
# Enable testing
|
|
enable_testing()
|
|
|
|
# Add test executable
|
|
add_executable(Qt6MigratedBenchmarkTest
|
|
tests/test_main.cpp
|
|
tests/test_mainwindow.cpp
|
|
MainWindow.h
|
|
MainWindow.cpp
|
|
)
|
|
|
|
target_link_libraries(Qt6MigratedBenchmarkTest PRIVATE
|
|
Qt6::Core
|
|
Qt6::Gui
|
|
Qt6::Widgets
|
|
Qt6::Test
|
|
)
|
|
|
|
# Apply same coverage flags to test target
|
|
if(ENABLE_COVERAGE)
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
target_compile_options(Qt6MigratedBenchmarkTest PRIVATE
|
|
-g
|
|
-O0
|
|
--coverage
|
|
-fprofile-arcs
|
|
-ftest-coverage
|
|
)
|
|
|
|
target_link_options(Qt6MigratedBenchmarkTest PRIVATE
|
|
--coverage
|
|
-fprofile-arcs
|
|
-ftest-coverage
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
# Register tests with CTest
|
|
add_test(NAME Qt6MigratedBenchmarkTest COMMAND Qt6MigratedBenchmarkTest) |