Skip to content

Commit 19ead5e

Browse files
committed
cmake: Use "coverage" preset instead of "Coverage" build type
1 parent 4b84f4b commit 19ead5e

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ endif()
134134

135135
option(SECP256K1_BUILD_BENCHMARK "Build benchmarks." ON)
136136
option(SECP256K1_BUILD_TESTS "Build tests." ON)
137+
option(SECP256K1_BUILD_VERIFY_TESTS "Build tests with -DVERIFY." ${SECP256K1_BUILD_TESTS})
138+
mark_as_advanced(SECP256K1_BUILD_VERIFY_TESTS)
137139
option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
138140
option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND})
139141
option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF)
@@ -258,11 +260,7 @@ endif()
258260
message("Optional binaries:")
259261
message(" benchmark ........................... ${SECP256K1_BUILD_BENCHMARK}")
260262
message(" noverify_tests ...................... ${SECP256K1_BUILD_TESTS}")
261-
set(tests_status "${SECP256K1_BUILD_TESTS}")
262-
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
263-
set(tests_status OFF)
264-
endif()
265-
message(" tests ............................... ${tests_status}")
263+
message(" tests ............................... ${SECP256K1_BUILD_VERIFY_TESTS}")
266264
message(" exhaustive tests .................... ${SECP256K1_BUILD_EXHAUSTIVE_TESTS}")
267265
message(" ctime_tests ......................... ${SECP256K1_BUILD_CTIME_TESTS}")
268266
message(" examples ............................ ${SECP256K1_BUILD_EXAMPLES}")

CMakePresets.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
2+
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
33
"version": 3,
44
"configurePresets": [
55
{
@@ -14,6 +14,17 @@
1414
"dev": true,
1515
"uninitialized": true
1616
}
17+
},
18+
{
19+
"name": "coverage",
20+
"displayName": "Build for coverage analysis",
21+
"generator": "Unix Makefiles",
22+
"cacheVariables": {
23+
"CMAKE_C_COMPILER": "gcc",
24+
"CMAKE_C_FLAGS": "-DCOVERAGE=1 -g -O0 --coverage",
25+
"CMAKE_BUILD_TYPE": "None",
26+
"SECP256K1_BUILD_VERIFY_TESTS": "OFF"
27+
}
1728
}
1829
]
1930
}

src/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ if(SECP256K1_BUILD_TESTS)
5252
add_executable(noverify_tests tests.c)
5353
target_link_libraries(noverify_tests secp256k1_precomputed secp256k1_asm)
5454
add_test(noverify_tests noverify_tests)
55-
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
56-
add_executable(tests tests.c)
55+
if(SECP256K1_BUILD_VERIFY_TESTS)
56+
add_executable(tests tests.c ${internal_obj})
5757
target_compile_definitions(tests PRIVATE VERIFY)
5858
target_link_libraries(tests secp256k1_precomputed secp256k1_asm)
5959
add_test(tests tests)
@@ -62,9 +62,9 @@ endif()
6262

6363
if(SECP256K1_BUILD_EXHAUSTIVE_TESTS)
6464
# Note: do not include secp256k1_precomputed in exhaustive_tests (it uses runtime-generated tables).
65-
add_executable(exhaustive_tests tests_exhaustive.c)
66-
target_link_libraries(exhaustive_tests secp256k1_asm)
67-
target_compile_definitions(exhaustive_tests PRIVATE $<$<NOT:$<CONFIG:Coverage>>:VERIFY>)
65+
add_executable(exhaustive_tests tests_exhaustive.c ${common_obj})
66+
target_compile_definitions(exhaustive_tests PRIVATE $<$<NOT:$<CONFIG:None>>:VERIFY>)
67+
target_link_libraries(exhaustive_tests binary_interface)
6868
add_test(exhaustive_tests exhaustive_tests)
6969
endif()
7070

0 commit comments

Comments
 (0)