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 60afa8e06SEd Masteadd_definitions(-D_FIDO_INTERNAL) 70afa8e06SEd Maste 80afa8e06SEd Mastelist(APPEND FIDO_SOURCES 90afa8e06SEd Maste aes256.c 100afa8e06SEd Maste assert.c 110afa8e06SEd Maste authkey.c 120afa8e06SEd Maste bio.c 130afa8e06SEd Maste blob.c 140afa8e06SEd Maste buf.c 150afa8e06SEd Maste cbor.c 160afa8e06SEd Maste compress.c 170afa8e06SEd Maste config.c 180afa8e06SEd Maste cred.c 190afa8e06SEd Maste credman.c 200afa8e06SEd Maste dev.c 210afa8e06SEd Maste ecdh.c 220afa8e06SEd Maste eddsa.c 230afa8e06SEd Maste err.c 240afa8e06SEd Maste es256.c 25*2ccfa855SEd Maste es384.c 260afa8e06SEd Maste hid.c 270afa8e06SEd Maste info.c 280afa8e06SEd Maste io.c 290afa8e06SEd Maste iso7816.c 300afa8e06SEd Maste largeblob.c 310afa8e06SEd Maste log.c 320afa8e06SEd Maste pin.c 330afa8e06SEd Maste random.c 340afa8e06SEd Maste reset.c 35f540a430SEd Maste rs1.c 360afa8e06SEd Maste rs256.c 37f540a430SEd Maste time.c 38*2ccfa855SEd Maste touch.c 39f540a430SEd Maste tpm.c 40f540a430SEd Maste types.c 410afa8e06SEd Maste u2f.c 42*2ccfa855SEd Maste util.c 430afa8e06SEd Maste) 440afa8e06SEd Maste 450afa8e06SEd Masteif(FUZZ) 46f540a430SEd Maste list(APPEND FIDO_SOURCES ../fuzz/clock.c) 47*2ccfa855SEd Maste list(APPEND FIDO_SOURCES ../fuzz/pcsc.c) 480afa8e06SEd Maste list(APPEND FIDO_SOURCES ../fuzz/prng.c) 490afa8e06SEd Maste list(APPEND FIDO_SOURCES ../fuzz/udev.c) 50*2ccfa855SEd Maste list(APPEND FIDO_SOURCES ../fuzz/uniform_random.c) 510afa8e06SEd Maste list(APPEND FIDO_SOURCES ../fuzz/wrap.c) 520afa8e06SEd Masteendif() 53*2ccfa855SEd Maste 540afa8e06SEd Masteif(NFC_LINUX) 55*2ccfa855SEd Maste list(APPEND FIDO_SOURCES netlink.c nfc.c nfc_linux.c) 56*2ccfa855SEd Masteendif() 57*2ccfa855SEd Maste 58*2ccfa855SEd Masteif(USE_PCSC) 59*2ccfa855SEd Maste list(APPEND FIDO_SOURCES nfc.c pcsc.c) 600afa8e06SEd Masteendif() 610afa8e06SEd Maste 620afa8e06SEd Masteif(USE_HIDAPI) 630afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_hidapi.c) 640afa8e06SEd Maste if(NOT WIN32 AND NOT APPLE) 650afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_unix.c) 660afa8e06SEd Maste endif() 670afa8e06SEd Masteelseif(WIN32) 680afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_win.c) 690afa8e06SEd Maste if(USE_WINHELLO) 700afa8e06SEd Maste list(APPEND FIDO_SOURCES winhello.c) 710afa8e06SEd Maste endif() 720afa8e06SEd Masteelseif(APPLE) 730afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_osx.c) 740afa8e06SEd Masteelseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 750afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_linux.c hid_unix.c) 760afa8e06SEd Masteelseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") 770afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_netbsd.c hid_unix.c) 780afa8e06SEd Masteelseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") 790afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_openbsd.c hid_unix.c) 80f540a430SEd Masteelseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR 81f540a430SEd Maste CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD") 820afa8e06SEd Maste list(APPEND FIDO_SOURCES hid_freebsd.c hid_unix.c) 830afa8e06SEd Masteelse() 840afa8e06SEd Maste message(FATAL_ERROR "please define a hid backend for your platform") 850afa8e06SEd Masteendif() 860afa8e06SEd Maste 870afa8e06SEd Masteif(NOT MSVC) 88*2ccfa855SEd Maste set_source_files_properties(${FIDO_SOURCES} 89*2ccfa855SEd Maste PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}") 900afa8e06SEd Masteendif() 910afa8e06SEd Maste 920afa8e06SEd Mastelist(APPEND COMPAT_SOURCES 93*2ccfa855SEd Maste ../openbsd-compat/bsd-asprintf.c 940afa8e06SEd Maste ../openbsd-compat/bsd-getpagesize.c 95f540a430SEd Maste ../openbsd-compat/clock_gettime.c 960afa8e06SEd Maste ../openbsd-compat/endian_win32.c 970afa8e06SEd Maste ../openbsd-compat/explicit_bzero.c 980afa8e06SEd Maste ../openbsd-compat/explicit_bzero_win32.c 990afa8e06SEd Maste ../openbsd-compat/freezero.c 1000afa8e06SEd Maste ../openbsd-compat/recallocarray.c 1010afa8e06SEd Maste ../openbsd-compat/strlcat.c 1020afa8e06SEd Maste ../openbsd-compat/timingsafe_bcmp.c 1030afa8e06SEd Maste) 1040afa8e06SEd Maste 1050afa8e06SEd Masteif(WIN32) 1060afa8e06SEd Maste list(APPEND BASE_LIBRARIES wsock32 ws2_32 bcrypt setupapi hid) 107*2ccfa855SEd Maste if(USE_PCSC) 108*2ccfa855SEd Maste list(APPEND BASE_LIBRARIES winscard) 109*2ccfa855SEd Maste endif() 1100afa8e06SEd Masteelseif(APPLE) 111*2ccfa855SEd Maste list(APPEND BASE_LIBRARIES "-framework CoreFoundation" 112*2ccfa855SEd Maste "-framework IOKit") 113*2ccfa855SEd Maste if(USE_PCSC) 114*2ccfa855SEd Maste list(APPEND BASE_LIBRARIES "-framework PCSC") 115*2ccfa855SEd Maste endif() 1160afa8e06SEd Masteendif() 1170afa8e06SEd Maste 1180afa8e06SEd Mastelist(APPEND TARGET_LIBRARIES 1190afa8e06SEd Maste ${CBOR_LIBRARIES} 1200afa8e06SEd Maste ${CRYPTO_LIBRARIES} 1210afa8e06SEd Maste ${UDEV_LIBRARIES} 1220afa8e06SEd Maste ${BASE_LIBRARIES} 1230afa8e06SEd Maste ${HIDAPI_LIBRARIES} 1240afa8e06SEd Maste ${ZLIB_LIBRARIES} 125*2ccfa855SEd Maste ${PCSC_LIBRARIES} 1260afa8e06SEd Maste) 1270afa8e06SEd Maste 1280afa8e06SEd Maste# static library 1290afa8e06SEd Masteif(BUILD_STATIC_LIBS) 1300afa8e06SEd Maste add_library(fido2 STATIC ${FIDO_SOURCES} ${COMPAT_SOURCES}) 1310afa8e06SEd Maste if(WIN32 AND NOT MINGW) 1320afa8e06SEd Maste set_target_properties(fido2 PROPERTIES OUTPUT_NAME fido2_static) 1330afa8e06SEd Maste endif() 1340afa8e06SEd Maste target_link_libraries(fido2 ${TARGET_LIBRARIES}) 1350afa8e06SEd Maste install(TARGETS fido2 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 1360afa8e06SEd Maste LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 1370afa8e06SEd Masteendif() 1380afa8e06SEd Maste 1390afa8e06SEd Maste# dynamic library 1400afa8e06SEd Masteif(BUILD_SHARED_LIBS) 1410afa8e06SEd Maste add_library(fido2_shared SHARED ${FIDO_SOURCES} ${COMPAT_SOURCES}) 1420afa8e06SEd Maste set_target_properties(fido2_shared PROPERTIES OUTPUT_NAME fido2 1430afa8e06SEd Maste VERSION ${FIDO_VERSION} SOVERSION ${FIDO_MAJOR}) 1440afa8e06SEd Maste target_link_libraries(fido2_shared ${TARGET_LIBRARIES}) 1450afa8e06SEd Maste install(TARGETS fido2_shared 1460afa8e06SEd Maste ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 1470afa8e06SEd Maste LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 1480afa8e06SEd Maste RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 1490afa8e06SEd Masteendif() 1500afa8e06SEd Maste 1510afa8e06SEd Masteinstall(FILES fido.h DESTINATION include) 1520afa8e06SEd Masteinstall(DIRECTORY fido DESTINATION include) 1530afa8e06SEd Maste 1543e696dfbSEd Masteif(NOT MSVC) 1550afa8e06SEd Maste configure_file(libfido2.pc.in libfido2.pc @ONLY) 1560afa8e06SEd Maste install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libfido2.pc" 1570afa8e06SEd Maste DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 1580afa8e06SEd Masteendif() 159