1*2ccfa855SEd Maste# Copyright (c) 2018-2022 Yubico AB. All rights reserved. 20afa8e06SEd Maste# Use of this source code is governed by a BSD-style 30afa8e06SEd Maste# license that can be found in the LICENSE file. 4*2ccfa855SEd Maste# SPDX-License-Identifier: BSD-2-Clause 50afa8e06SEd Maste 6*2ccfa855SEd Masteadd_custom_target(regress) 70afa8e06SEd Maste 8*2ccfa855SEd Mastemacro(add_regress_test NAME SOURCES LIB) 90afa8e06SEd Maste add_executable(${NAME} ${SOURCES}) 10f540a430SEd Maste add_test(${NAME} ${NAME}) 11f540a430SEd Maste add_dependencies(regress ${NAME}) 12*2ccfa855SEd Maste target_link_libraries(${NAME} ${LIB}) 130afa8e06SEd Masteendmacro() 140afa8e06SEd Maste 15*2ccfa855SEd Masteif(MSVC AND BUILD_SHARED_LIBS) 16f540a430SEd Maste add_custom_command(TARGET regress POST_BUILD 17*2ccfa855SEd Maste COMMAND "${CMAKE_COMMAND}" -E copy 18*2ccfa855SEd Maste "${CBOR_BIN_DIRS}/${CBOR_LIBRARIES}.dll" 19*2ccfa855SEd Maste "${CRYPTO_BIN_DIRS}/${CRYPTO_LIBRARIES}.dll" 20*2ccfa855SEd Maste "${ZLIB_BIN_DIRS}/${ZLIB_LIBRARIES}.dll" 21*2ccfa855SEd Maste "$<TARGET_FILE:${_FIDO2_LIBRARY}>" 22*2ccfa855SEd Maste "${CMAKE_CURRENT_BINARY_DIR}") 23*2ccfa855SEd Masteendif() 24f540a430SEd Maste 25*2ccfa855SEd Masteif(CYGWIN AND BUILD_SHARED_LIBS) 26*2ccfa855SEd Maste add_custom_command(TARGET regress POST_BUILD 27*2ccfa855SEd Maste COMMAND "${CMAKE_COMMAND}" -E copy 28*2ccfa855SEd Maste "$<TARGET_FILE:${_FIDO2_LIBRARY}>" 29*2ccfa855SEd Maste "${CMAKE_CURRENT_BINARY_DIR}") 30*2ccfa855SEd Masteendif() 31*2ccfa855SEd Maste 32*2ccfa855SEd Masteif(CMAKE_CROSSCOMPILING OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64" AND 33*2ccfa855SEd Maste CMAKE_GENERATOR_PLATFORM MATCHES "^ARM.*$")) 34*2ccfa855SEd Maste add_custom_command(TARGET regress POST_BUILD 35*2ccfa855SEd Maste COMMAND "${CMAKE_COMMAND}" -E echo 36*2ccfa855SEd Maste "Cross-compilation detected. Skipping regress tests.") 37*2ccfa855SEd Masteelse() 38*2ccfa855SEd Maste add_custom_command(TARGET regress POST_BUILD 39*2ccfa855SEd Maste COMMAND "${CMAKE_CTEST_COMMAND}" --output-on-failure 40*2ccfa855SEd Maste WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) 41*2ccfa855SEd Masteendif() 42*2ccfa855SEd Maste 43*2ccfa855SEd Masteadd_regress_test(regress_assert assert.c ${_FIDO2_LIBRARY}) 44*2ccfa855SEd Masteadd_regress_test(regress_cred cred.c ${_FIDO2_LIBRARY}) 45*2ccfa855SEd Masteadd_regress_test(regress_dev dev.c ${_FIDO2_LIBRARY}) 46*2ccfa855SEd Masteadd_regress_test(regress_eddsa eddsa.c ${_FIDO2_LIBRARY}) 47*2ccfa855SEd Masteadd_regress_test(regress_es256 es256.c ${_FIDO2_LIBRARY}) 48*2ccfa855SEd Masteadd_regress_test(regress_es384 es384.c ${_FIDO2_LIBRARY}) 49*2ccfa855SEd Masteadd_regress_test(regress_rs256 rs256.c ${_FIDO2_LIBRARY}) 50*2ccfa855SEd Masteif(BUILD_STATIC_LIBS) 51*2ccfa855SEd Maste add_regress_test(regress_compress compress.c fido2) 52*2ccfa855SEd Masteendif() 53*2ccfa855SEd Maste 54*2ccfa855SEd Masteif(MINGW) 55*2ccfa855SEd Maste # needed for nanosleep() in mingw 56*2ccfa855SEd Maste target_link_libraries(regress_dev winpthread) 57*2ccfa855SEd Masteendif() 58