Skip to content

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Sep 3, 2025

To sync up with the --enable-code-coverage ./configure option.

Ref: https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html
Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
Ref: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html


w/o sp https://github.com/curl/curl/pull/18468/files?w=1

@vszakats vszakats marked this pull request as draft September 3, 2025 15:04
@vszakats vszakats force-pushed the cm-codecov branch 2 times, most recently from d79cb1f to 78fa01b Compare September 3, 2025 16:23
@vszakats vszakats changed the title cmake: try adding CURL_CODE_COVERAGE option, sync up autotools cmake: add CURL_CODE_COVERAGE option, sync up autotools Sep 3, 2025
@vszakats vszakats marked this pull request as ready for review September 3, 2025 16:38
@vszakats
Copy link
Member Author

vszakats commented Sep 3, 2025

Seems to work. Also with unity builds, and llvm and Apple clang. Only tested with cmake.
I was suprised that gcov-15 needs the .o filename (not .c) as an argument to work.

Similar capability, but for build-only, would be useful to ensure that most code lines are
compiled at least once in CI. Also to avoid over-building certain configs.

@vszakats vszakats changed the title cmake: add CURL_CODE_COVERAGE option, sync up autotools cmake: add CURL_CODE_COVERAGE option Sep 5, 2025
vszakats added a commit that referenced this pull request Sep 19, 2025
@vszakats vszakats closed this in 91720b6 Sep 19, 2025
@vszakats vszakats deleted the cm-codecov branch September 19, 2025 23:29
vszakats added a commit that referenced this pull request Sep 29, 2025
- replace `COMPILE_FLAGS` with `COMPILE_OPTIONS` that superceded it.

  Follow-up to 6140dfc
  https://cmake.org/cmake/help/v4.1/prop_sf/COMPILE_FLAGS.html

- replace `target_link_libraries()` with `LINK_FLAGS` property for
  CMake <=3.12, because we are passing linker options (not libs).

  Follow-up to 91720b6 #18468
  Follow-up to 5488739 #17670
  Follow-up to 95aea79 #5843
  https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html
  https://cmake.org/cmake/help/v3.7/prop_tgt/LINK_FLAGS.html

- replace `target_link_options()` with `LINK_OPTIONS` propery for
  CMake 3.13+, to use the modern style.

  Follow-up to 91720b6 #18468
  Follow-up to 5488739 #17670
  https://cmake.org/cmake/help/v3.13/command/target_link_options.html
  https://cmake.org/cmake/help/v3.13/prop_tgt/LINK_OPTIONS.html

Also:

- fix to append to, not override, previously set linker options when
  using `CURL_LIBCURL_VERSIONED_SYMBOLS=ON`. Before this patch, it was
  overwriting linker options when using `CURL_CODE_COVERAGE=ON`.

  Follow-up to 91720b6 #18468

Closes #18762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant