Skip to content

Commit cef3739

Browse files
committed
cmake, refactor: Use helper function instead of interface library
This change aims to simplify the following commit.
1 parent 907a672 commit cef3739

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

examples/CMakeLists.txt

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
add_library(example INTERFACE)
2-
target_include_directories(example INTERFACE
3-
${PROJECT_SOURCE_DIR}/include
4-
)
5-
target_link_libraries(example INTERFACE
6-
secp256k1
7-
$<$<PLATFORM_ID:Windows>:bcrypt>
8-
)
1+
function(add_example name)
2+
set(target_name ${name}_example)
3+
add_executable(${target_name} ${name}.c)
4+
target_include_directories(${target_name} PRIVATE
5+
${PROJECT_SOURCE_DIR}/include
6+
)
7+
target_link_libraries(${target_name}
8+
secp256k1
9+
$<$<PLATFORM_ID:Windows>:bcrypt>
10+
)
11+
set(test_name ${name}_example)
12+
add_test(NAME ${test_name} COMMAND ${target_name})
13+
endfunction()
914

10-
add_executable(ecdsa_example ecdsa.c)
11-
target_link_libraries(ecdsa_example example)
12-
add_test(NAME ecdsa_example COMMAND ecdsa_example)
15+
add_example(ecdsa)
1316

1417
if(SECP256K1_ENABLE_MODULE_ECDH)
15-
add_executable(ecdh_example ecdh.c)
16-
target_link_libraries(ecdh_example example)
17-
add_test(NAME ecdh_example COMMAND ecdh_example)
18+
add_example(ecdh)
1819
endif()
1920

2021
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
21-
add_executable(schnorr_example schnorr.c)
22-
target_link_libraries(schnorr_example example)
23-
add_test(NAME schnorr_example COMMAND schnorr_example)
22+
add_example(schnorr)
2423
endif()

0 commit comments

Comments
 (0)