CMakeLists.txt (834B)
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 if(BUILD_SHARED_LIBS AND MSVC) 14 # The DLL must reside either in the same folder where the executable is 15 # or somewhere in PATH. Using the latter option. 16 set_tests_properties(${test_name} PROPERTIES 17 ENVIRONMENT "PATH=$<TARGET_FILE_DIR:secp256k1>;$ENV{PATH}" 18 ) 19 endif() 20 endfunction() 21 22 add_example(ecdsa) 23 24 if(SECP256K1_ENABLE_MODULE_ECDH) 25 add_example(ecdh) 26 endif() 27 28 if(SECP256K1_ENABLE_MODULE_SCHNORRSIG) 29 add_example(schnorr) 30 endif()