Skip to content

Commit

Permalink
cmake: Use "coverage" preset instead of "Coverage" build type
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 27, 2023
1 parent 4b84f4b commit 19ead5e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ endif()

option(SECP256K1_BUILD_BENCHMARK "Build benchmarks." ON)
option(SECP256K1_BUILD_TESTS "Build tests." ON)
option(SECP256K1_BUILD_VERIFY_TESTS "Build tests with -DVERIFY." ${SECP256K1_BUILD_TESTS})
mark_as_advanced(SECP256K1_BUILD_VERIFY_TESTS)
option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND})
option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF)
Expand Down Expand Up @@ -258,11 +260,7 @@ endif()
message("Optional binaries:")
message(" benchmark ........................... ${SECP256K1_BUILD_BENCHMARK}")
message(" noverify_tests ...................... ${SECP256K1_BUILD_TESTS}")
set(tests_status "${SECP256K1_BUILD_TESTS}")
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
set(tests_status OFF)
endif()
message(" tests ............................... ${tests_status}")
message(" tests ............................... ${SECP256K1_BUILD_VERIFY_TESTS}")
message(" exhaustive tests .................... ${SECP256K1_BUILD_EXHAUSTIVE_TESTS}")
message(" ctime_tests ......................... ${SECP256K1_BUILD_CTIME_TESTS}")
message(" examples ............................ ${SECP256K1_BUILD_EXAMPLES}")
Expand Down
13 changes: 12 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
"version": 3,
"configurePresets": [
{
Expand All @@ -14,6 +14,17 @@
"dev": true,
"uninitialized": true
}
},
{
"name": "coverage",
"displayName": "Build for coverage analysis",
"generator": "Unix Makefiles",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_C_FLAGS": "-DCOVERAGE=1 -g -O0 --coverage",
"CMAKE_BUILD_TYPE": "None",
"SECP256K1_BUILD_VERIFY_TESTS": "OFF"
}
}
]
}
10 changes: 5 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ if(SECP256K1_BUILD_TESTS)
add_executable(noverify_tests tests.c)
target_link_libraries(noverify_tests secp256k1_precomputed secp256k1_asm)
add_test(noverify_tests noverify_tests)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
add_executable(tests tests.c)
if(SECP256K1_BUILD_VERIFY_TESTS)
add_executable(tests tests.c ${internal_obj})
target_compile_definitions(tests PRIVATE VERIFY)
target_link_libraries(tests secp256k1_precomputed secp256k1_asm)
add_test(tests tests)
Expand All @@ -62,9 +62,9 @@ endif()

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

Expand Down

0 comments on commit 19ead5e

Please sign in to comment.