From 6834cb502501a330aca868f7a84dcb9272d0b90e Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 4 Dec 2023 10:43:50 -0800 Subject: [PATCH] Implement coverage option To use pass -DCMAKE_BUILD_TYPE=Debug or Asan -DCOVERAGE=ON and build as usual, then do ninja lcov-initialize && ninja check && ninja lcov-collect. The result will be a directory, /Coverage containing lcov tracefiles, including an aggregate file gnucash.info which you can use for further processing. It will also report an overall summary. Note that only C/C++ files are included. There's one more target, lcov-generate-html, that you can run after lcov-collect. It will generate a simple website in /Coverage-HTML showing coverage by source directory (the directories in have coverage for generated files). Each directory path is a clickable link to a page that shows coverage for each source file; the filenames link to a page for each showing which lines have been exercised. --- CMakeLists.txt | 14 ++- common/cmake_modules/GncCoverage.cmake | 111 ++++++++++++++++++ gnucash/CMakeLists.txt | 5 + gnucash/gnome-search/CMakeLists.txt | 4 + gnucash/gnome-utils/CMakeLists.txt | 4 + gnucash/gnome/CMakeLists.txt | 3 + gnucash/html/CMakeLists.txt | 5 + gnucash/import-export/CMakeLists.txt | 4 + gnucash/import-export/aqb/CMakeLists.txt | 4 + .../import-export/bi-import/CMakeLists.txt | 4 + gnucash/import-export/csv-exp/CMakeLists.txt | 4 + gnucash/import-export/csv-imp/CMakeLists.txt | 4 + .../customer-import/CMakeLists.txt | 4 + .../import-export/log-replay/CMakeLists.txt | 4 + gnucash/import-export/ofx/CMakeLists.txt | 4 + gnucash/import-export/qif-imp/CMakeLists.txt | 4 + gnucash/register/ledger-core/CMakeLists.txt | 4 + gnucash/register/register-core/CMakeLists.txt | 4 + .../register/register-gnome/CMakeLists.txt | 4 + gnucash/report/CMakeLists.txt | 4 + libgnucash/app-utils/CMakeLists.txt | 6 +- libgnucash/backend/dbi/CMakeLists.txt | 4 + libgnucash/backend/sql/CMakeLists.txt | 4 + libgnucash/backend/xml/CMakeLists.txt | 8 ++ libgnucash/core-utils/CMakeLists.txt | 4 + libgnucash/engine/CMakeLists.txt | 4 + libgnucash/gnc-module/CMakeLists.txt | 4 + libgnucash/tax/CMakeLists.txt | 4 + 28 files changed, 233 insertions(+), 3 deletions(-) create mode 100644 common/cmake_modules/GncCoverage.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 8128186844..7660a7f55e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ option (WITH_OFX "compile with ofx support (needs LibOFX)" ON) option (WITH_PYTHON "enable python plugin and bindings" OFF) option (ENABLE_BINRELOC "compile with binary relocation support" ON) option (DISABLE_NLS "do not use Native Language Support" OFF) -option (COVERAGE "Instrument an Asan build for coverage reporting" OFF) +option (COVERAGE "Instrument a Debug or Asan build for coverage reporting" OFF) option (LEAKS "Report leaks for tests in a non-Apple Asan build." OFF) option (ODR "Report One Definition Rule violations in tests in a non-Apple Asan build." OFF) # ############################################################ @@ -628,7 +628,13 @@ elseif(UNIX) endif () set(ASAN_LINK_OPTIONS -fsanitize=address -fsanitize=undefined) if (COVERAGE) - list(APPEND ASAN_LINK_OPTIONS --coverage) + include(GncCoverage) +endif() +if (COVERAGE) + set(COVERAGE_COMPILE_OPTION --coverage) + add_compile_options("$<$:${COVERAGE_COMPILE_OPTION}>") + add_link_options("$<$:${COVERAGE_COMPILE_OPTION}>") + list(APPEND ASAN_LINK_OPTIONS ${COVERAGE_COMPILE_OPTION}) endif() set(ASAN_COMPILE_OPTIONS -g ${ASAN_LINK_OPTIONS}) add_compile_options("$<$:${ASAN_COMPILE_OPTIONS}>") @@ -689,6 +695,10 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} ) +if (COVERAGE) + add_dependencies(check lcov-initialize) +endif() + set(gnucash_DOCS AUTHORS ChangeLog.1999 diff --git a/common/cmake_modules/GncCoverage.cmake b/common/cmake_modules/GncCoverage.cmake new file mode 100644 index 0000000000..79dde288a0 --- /dev/null +++ b/common/cmake_modules/GncCoverage.cmake @@ -0,0 +1,111 @@ +#lcov command options: +# -a, --add-tracefile (takes glob) +# -c, --capture; create a trace file from the .da files +# -e, --extract; a reduced scope for analysis +# -l, --list; the contents of a tracefile +# -r, --remove; remove pattern-match from tracefile +# -z, --zerocounters; run this first, then -c -i +# --diff +# --summary +# other necessary options: +# --directory; points to the source root. If left off it analyzes the kernel +# --no-external; only analyze code in --directory +# --build-directory; where the .no when different from the .da files +# --branch-coverage; to ensure branch info is saved +# --demangle-cpp; requires c++filt + +if (COVERAGE) + find_program(LCOV lcov) + find_program(GENINFO geninfo) + find_program(GENHTML genhtml) + find_program(CPPFILT c++filt) + + if (NOT LCOV OR NOT GENINFO OR NOT GENHTML OR NOT CPPFILT) + MESSAGE(WARNING "A required program for presenting coverage information isn't available, disabling coverage") + set(COVERAGE OFF CACHE INTERNAL "") + return() + endif() +else() + return() +endif() + +execute_process(COMMAND lcov --version OUTPUT_VARIABLE lcov_version_response) +string(REGEX MATCH "[-.0-9]+" lcov_version ${lcov_version_response}) +set(LCOV_VERSION ${lcov_version} CACHE INTERNAL "") + +set(excludes_arg "") +foreach (sys_path ${CMAKE_SYSTEM_PREFIX_PATH}) + list(APPEND excludes_arg "--exclude" "${sys_path}/*") +endforeach() + +set(ignores_arg "--ignore-errors" "unused,unused" "--ignore-errors" "mismatch,mismatch" + "--ignore-errors" "empty,empty") +list(APPEND ignores_arg "--rc" "geninfo_unexecuted_blocks=1") +set(generate_flags "") +set(geninfo_flags --quiet ${excludes_arg}) +if (LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + list(APPEND geninfo_flags ${ignores_arg}) + list(APPEND generate_flags "--branch-coverage" "--demangle-cpp" "c++filt") +else() + list(APPEND generate_flags "--rc" "lcov_branch_coverage=1" "--rc" "genhtml_demangle_cpp=1") +endif() +set(coverage_dir "${CMAKE_BINARY_DIR}/Coverage" CACHE INTERNAL "Directory to accumulate coverage tracefiles") +set(coverage_html_dir "${CMAKE_BINARY_DIR}/Coverage-HTML" CACHE INTERNAL "Directory to place HTML coverage results pages") + +file(MAKE_DIRECTORY ${coverage_dir}) + +add_custom_target(lcov-initialize) +if (LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + add_custom_target(lcov-collect + COMMAND lcov ${geninfo_flags} -a ${coverage_dir}/*.info -o ${coverage_dir}/gnucash.info + COMMAND lcov --summary ${coverage_dir}/gnucash.info + VERBATIM + COMMAND_EXPAND_LISTS) +else() + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/collect.sh + CONTENT + "#!/bin/bash +if [ -e $2 ] + then rm $2 +fi +j=\"\" +for i in $1/*.info +do j=\"$j -a $i\" +done +lcov $j -o $2 +" + FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE WORLD_EXECUTE) + + add_custom_target(lcov-collect + COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/collect.sh ${coverage_dir} ${coverage_dir}/gnucash.info + DEPENDS ${CMAKE_BINARY_DIR}/collect.sh + VERBATIM + COMMAND_EXPAND_LISTS) +endif() +set_target_properties(lcov-collect PROPERTIES ADDITIONAL_CLEAN_FILES "${coverage_dir}/gnucash.info") + +add_custom_target(lcov-generate-html + genhtml --quiet --output-directory "${coverage_html_dir}" --legend --function-coverage ${generate_flags} ${coverage_dir}/gnucash.info + VERBATIM + COMMAND_EXPAND_LISTS) +set_target_properties(lcov-generate-html PROPERTIES ADDITIONAL_CLEAN_FILES "${coverage_html_dir}") + +function (add_coverage_target tgt) + get_target_property(build_dir ${tgt} BINARY_DIR) + set(target_dir "${build_dir}/CMakeFiles/${tgt}.dir") + + add_custom_target(lcov-initialize-${tgt} + lcov ${geninfo_flags} -z --directory ${target_dir} + COMMAND lcov ${geninfo_flags} ${generate_flags} -c -i --directory ${target_dir} -o "${coverage_dir}/${tgt}_base.info" + VERBATIM + COMMAND_EXPAND_LISTS) + add_dependencies(lcov-initialize lcov-initialize-${tgt}) + add_dependencies(lcov-initialize-${tgt} ${tgt}) + + add_custom_target(lcov-collect-${tgt} + COMMAND lcov ${geninfo_flags} ${generate_flags} -c --directory ${target_dir} -o "${coverage_dir}/${tgt}_result.info" + VERBATIM + COMMAND_EXPAND_LISTS) + add_dependencies(lcov-collect lcov-collect-${tgt}) + set_target_properties(${tgt} PROPERTIES ADDITIONAL_CLEAN_FILES "${coverage_dir}/${tgt}_base.info;${coverage_dir}/${tgt}_result.info") +endFunction() diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt index a9461979b3..7bc6fa91e1 100644 --- a/gnucash/CMakeLists.txt +++ b/gnucash/CMakeLists.txt @@ -160,6 +160,11 @@ if (MAC_INTEGRATION) target_link_options(gnucash-cli PRIVATE -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_SOURCE_DIR}/Info.plist) endif() +if (COVERAGE AND LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + add_coverage_target(gnucash) + add_coverage_target(gnucash-cli) +endif() + install(TARGETS gnucash gnucash-cli DESTINATION ${CMAKE_INSTALL_BINDIR}) # No headers to install. diff --git a/gnucash/gnome-search/CMakeLists.txt b/gnucash/gnome-search/CMakeLists.txt index 55c9ab3241..e945bf1665 100644 --- a/gnucash/gnome-search/CMakeLists.txt +++ b/gnucash/gnome-search/CMakeLists.txt @@ -55,6 +55,10 @@ if (APPLE) set_target_properties (gnc-gnome-search PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE) + add_coverage_target(gnc-gnome-search) +endif() + install(TARGETS gnc-gnome-search LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt index e02b68795e..8040cade84 100644 --- a/gnucash/gnome-utils/CMakeLists.txt +++ b/gnucash/gnome-utils/CMakeLists.txt @@ -224,6 +224,10 @@ if (MAC_INTEGRATION) target_link_libraries(gnc-gnome-utils ${OSX_EXTRA_LIBRARIES}) endif() +if (COVERAGE) + add_coverage_target(gnc-gnome-utils) +endif() + target_include_directories(gnc-gnome-utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index e0c7dc9320..68006a01d9 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -163,6 +163,9 @@ if (MAC_INTEGRATION) target_link_libraries(gnc-gnome ${OSX_EXTRA_LIBRARIES}) endif() +if (COVERAGE) + add_coverage_target(gnc-gnome) +endif() install(TARGETS gnc-gnome LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/gnucash/html/CMakeLists.txt b/gnucash/html/CMakeLists.txt index acd8ea0b5d..1efdaf0133 100644 --- a/gnucash/html/CMakeLists.txt +++ b/gnucash/html/CMakeLists.txt @@ -73,6 +73,11 @@ if (APPLE) endif() add_dependencies(gnc-html swig-gnc-html-c) + +if (COVERAGE) + add_coverage_target(gnc-html) +endif() + install(TARGETS gnc-html LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 5cdde066f4..3765468acd 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -61,6 +61,10 @@ if (APPLE) set_target_properties (gnc-generic-import PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") endif() +if (COVERAGE) + add_coverage_target(gnc-generic-import) +endif() + install(TARGETS gnc-generic-import LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/gnucash/import-export/aqb/CMakeLists.txt b/gnucash/import-export/aqb/CMakeLists.txt index cf90236227..662638a849 100644 --- a/gnucash/import-export/aqb/CMakeLists.txt +++ b/gnucash/import-export/aqb/CMakeLists.txt @@ -81,6 +81,10 @@ if(WITH_AQBANKING) set_target_properties (gncmod-aqbanking PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() + if (COVERAGE) + add_coverage_target(gncmod-aqbanking) + endif() + install(TARGETS gncmod-aqbanking LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/bi-import/CMakeLists.txt b/gnucash/import-export/bi-import/CMakeLists.txt index 53b0c2ed52..54839a65bb 100644 --- a/gnucash/import-export/bi-import/CMakeLists.txt +++ b/gnucash/import-export/bi-import/CMakeLists.txt @@ -37,6 +37,10 @@ if (APPLE) set_target_properties (gnc-bi-import PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE AND LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + add_coverage_target(gnc-bi-import) +endif() + install(TARGETS gnc-bi-import LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/csv-exp/CMakeLists.txt b/gnucash/import-export/csv-exp/CMakeLists.txt index d413a74569..5ff28385d7 100644 --- a/gnucash/import-export/csv-exp/CMakeLists.txt +++ b/gnucash/import-export/csv-exp/CMakeLists.txt @@ -43,6 +43,10 @@ if (APPLE) set_target_properties (gnc-csv-export PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE) + add_coverage_target(gnc-csv-export) +endif() + install(TARGETS gnc-csv-export LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/csv-imp/CMakeLists.txt b/gnucash/import-export/csv-imp/CMakeLists.txt index 5347cfdec2..b164c7cac6 100644 --- a/gnucash/import-export/csv-imp/CMakeLists.txt +++ b/gnucash/import-export/csv-imp/CMakeLists.txt @@ -84,6 +84,10 @@ if (APPLE) set_target_properties (gnc-csv-import PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE) + add_coverage_target(gnc-csv-import) +endif() + install(TARGETS gnc-csv-import LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/customer-import/CMakeLists.txt b/gnucash/import-export/customer-import/CMakeLists.txt index 126f5b6dd7..f0b2892c30 100644 --- a/gnucash/import-export/customer-import/CMakeLists.txt +++ b/gnucash/import-export/customer-import/CMakeLists.txt @@ -35,6 +35,10 @@ if (APPLE) set_target_properties (gnc-customer-import PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (0 AND COVERAGE) # Generates no coverage data + add_coverage_target(gnc-customer-import) +endif() + install(TARGETS gnc-customer-import LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/log-replay/CMakeLists.txt b/gnucash/import-export/log-replay/CMakeLists.txt index 742c3dc7b5..c25ab751e9 100644 --- a/gnucash/import-export/log-replay/CMakeLists.txt +++ b/gnucash/import-export/log-replay/CMakeLists.txt @@ -32,6 +32,10 @@ if (APPLE) set_target_properties (gnc-log-replay PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE AND LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + add_coverage_target(gnc-log-replay) +endif() + install(TARGETS gnc-log-replay LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/ofx/CMakeLists.txt b/gnucash/import-export/ofx/CMakeLists.txt index 479e16e24d..f5dace314a 100644 --- a/gnucash/import-export/ofx/CMakeLists.txt +++ b/gnucash/import-export/ofx/CMakeLists.txt @@ -48,6 +48,10 @@ if (WITH_OFX) set_target_properties (gncmod-ofx PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() + if (COVERAGE AND LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + add_coverage_target(gncmod-ofx) + endif() + install(TARGETS gncmod-ofx LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/import-export/qif-imp/CMakeLists.txt b/gnucash/import-export/qif-imp/CMakeLists.txt index 8d7223233d..ec4a6fa52f 100644 --- a/gnucash/import-export/qif-imp/CMakeLists.txt +++ b/gnucash/import-export/qif-imp/CMakeLists.txt @@ -36,6 +36,10 @@ if (APPLE) set_target_properties (gnc-qif-import PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE AND LCOV_VERSION VERSION_GREATER_EQUAL "2.0") + add_coverage_target(gnc-qif-import) +endif() + install(TARGETS gnc-qif-import LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/register/ledger-core/CMakeLists.txt b/gnucash/register/ledger-core/CMakeLists.txt index 3bfa5b0df1..19563f3a58 100644 --- a/gnucash/register/ledger-core/CMakeLists.txt +++ b/gnucash/register/ledger-core/CMakeLists.txt @@ -56,6 +56,10 @@ if (APPLE) set_target_properties (gnc-ledger-core PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE) + add_coverage_target(gnc-ledger-core) +endif() + install(TARGETS gnc-ledger-core LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/register/register-core/CMakeLists.txt b/gnucash/register/register-core/CMakeLists.txt index 8c1afeee44..a463a34244 100644 --- a/gnucash/register/register-core/CMakeLists.txt +++ b/gnucash/register/register-core/CMakeLists.txt @@ -60,6 +60,10 @@ install(TARGETS gnc-register-core ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +if (COVERAGE) + add_coverage_target(gnc-register-core) +endif() + install(FILES ${register_core_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gnucash) set_local_dist(register_core_DIST_local CMakeLists.txt README ${register_core_SOURCES} ${register_core_HEADERS}) diff --git a/gnucash/register/register-gnome/CMakeLists.txt b/gnucash/register/register-gnome/CMakeLists.txt index 6d893fe2aa..2960f85dfa 100644 --- a/gnucash/register/register-gnome/CMakeLists.txt +++ b/gnucash/register/register-gnome/CMakeLists.txt @@ -55,6 +55,10 @@ if (APPLE) set_target_properties (gnc-register-gnome PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE) + add_coverage_target(gnc-register-gnome) +endif() + install(TARGETS gnc-register-gnome LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/gnucash/report/CMakeLists.txt b/gnucash/report/CMakeLists.txt index 25331a1d88..c70e13c561 100644 --- a/gnucash/report/CMakeLists.txt +++ b/gnucash/report/CMakeLists.txt @@ -43,6 +43,10 @@ if (APPLE) set_target_properties (gnc-report PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() +if (COVERAGE) + add_coverage_target(gnc-report) +endif() + install(TARGETS gnc-report LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/libgnucash/app-utils/CMakeLists.txt b/libgnucash/app-utils/CMakeLists.txt index a9ca0acad1..b3b0efd421 100644 --- a/libgnucash/app-utils/CMakeLists.txt +++ b/libgnucash/app-utils/CMakeLists.txt @@ -84,7 +84,11 @@ if (APPLE) set_target_properties (gnc-app-utils PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") endif() -install(TARGETS gnc-app-utils +if (COVERAGE) + add_coverage_target(gnc-app-utils) +endif() + +install (TARGETS gnc-app-utils LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/libgnucash/backend/dbi/CMakeLists.txt b/libgnucash/backend/dbi/CMakeLists.txt index 9db2ebbe22..ac6fe7058d 100644 --- a/libgnucash/backend/dbi/CMakeLists.txt +++ b/libgnucash/backend/dbi/CMakeLists.txt @@ -43,6 +43,10 @@ if (WITH_SQL) set_target_properties (gncmod-backend-dbi PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") endif() + if (COVERAGE) + add_coverage_target(gncmod-backend-dbi) + endif() + install(TARGETS gncmod-backend-dbi LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash diff --git a/libgnucash/backend/sql/CMakeLists.txt b/libgnucash/backend/sql/CMakeLists.txt index 3fc3fa3d03..b197c39a1d 100644 --- a/libgnucash/backend/sql/CMakeLists.txt +++ b/libgnucash/backend/sql/CMakeLists.txt @@ -80,5 +80,9 @@ if(WITH_SQL) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + if (COVERAGE) + add_coverage_target(gnc-backend-sql) + endif() + # No headers to install endif() diff --git a/libgnucash/backend/xml/CMakeLists.txt b/libgnucash/backend/xml/CMakeLists.txt index dbd6a25fa8..b21cf5d733 100644 --- a/libgnucash/backend/xml/CMakeLists.txt +++ b/libgnucash/backend/xml/CMakeLists.txt @@ -96,6 +96,10 @@ install(TARGETS gnc-backend-xml-utils ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # No headers to install +if (COVERAGE) + add_coverage_target(gnc-backend-xml-utils) +endif() + # ---- @@ -119,6 +123,10 @@ if (APPLE) set_target_properties (gncmod-backend-xml PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") endif() +if (COVERAGE) + add_coverage_target(gncmod-backend-xml) +endif() + install(TARGETS gncmod-backend-xml LIBRARY DESTINATION ${LIB_DIR} ARCHIVE DESTINATION ${LIB_DIR} diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt index 2c77d45a02..773eb875dc 100644 --- a/libgnucash/core-utils/CMakeLists.txt +++ b/libgnucash/core-utils/CMakeLists.txt @@ -72,6 +72,10 @@ install(TARGETS gnc-core-utils RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) +if (COVERAGE) + add_coverage_target(gnc-core-utils) +endif() + ### gncla-dir.h set(prefix ${CMAKE_INSTALL_PREFIX}) diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt index cb78372b8b..6fc7f8b118 100644 --- a/libgnucash/engine/CMakeLists.txt +++ b/libgnucash/engine/CMakeLists.txt @@ -263,6 +263,10 @@ if (APPLE) set_target_properties (gnc-engine PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") endif() +if (COVERAGE) + add_coverage_target(gnc-engine) +endif() + install(TARGETS gnc-engine LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/libgnucash/gnc-module/CMakeLists.txt b/libgnucash/gnc-module/CMakeLists.txt index b686d24725..80c997cea5 100644 --- a/libgnucash/gnc-module/CMakeLists.txt +++ b/libgnucash/gnc-module/CMakeLists.txt @@ -27,6 +27,10 @@ target_include_directories (gnc-module ${CMAKE_BINARY_DIR}/common # for config.h ) +if (COVERAGE) + add_coverage_target(gnc-module) +endif() + install(TARGETS gnc-module LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/libgnucash/tax/CMakeLists.txt b/libgnucash/tax/CMakeLists.txt index 945bc7b8c5..fef9682dd6 100644 --- a/libgnucash/tax/CMakeLists.txt +++ b/libgnucash/tax/CMakeLists.txt @@ -23,6 +23,10 @@ if (APPLE) set_target_properties (gnc-locale-tax PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") endif() +if (COVERAGE) + add_coverage_target(gnc-locale-tax) +endif() + install(TARGETS gnc-locale-tax LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}