bitcoin-core / secp256k1

Optimized C library for EC operations on curve secp256k1
MIT License
2.06k stars 1k forks source link

cmake: Rework `tests` target for Coverage configuartion and multi-config generators #1592

Open hebasto opened 1 month ago

hebasto commented 1 month ago

The "experimental" status of the CMake-based build system can be reconsidered once it is adopted in the Bitcoin Core project. Fixing all known bugs is essential before this reconsideration.

Currently, I'm aware of a single issue: when using a multi-config generator, such as "Ninja Multi-Config", the build system still builds the tests binary for the "Coverage" configuration, which is meaningless:

$ cmake -B build -G "Ninja Multi-Config"
$ cmake --build build --config Coverage
[18/19] Building C object src/CMakeFiles/tests.dir/Coverage/tests.c.o
/home/hebasto/git/secp256k1/secp256k1/src/tests.c:18:13: note: ‘#pragma message: Defining VERIFY for tests being built for coverage analysis support is meaningless.’
   18 |     #pragma message("Defining VERIFY for tests being built for coverage analysis support is meaningless.")
      |             ^~~~~~~
[19/19] Linking C executable src/Coverage/tests

This PR fixes the issue.

It is an alternative to https://github.com/bitcoin-core/secp256k1/pull/1251 and https://github.com/bitcoin-core/secp256k1/pull/1291.

The last commit aaditionally addresses that comment.

real-or-random commented 1 month ago

@hebasto Can you summarize what this PR does and why is it preferable to #1291? The approach in #1291 seemed natural to me.