Path: blob/main/contrib/libfido2/src/CMakeLists.txt
39482 views
# Copyright (c) 2018-2022 Yubico AB. All rights reserved.1# Use of this source code is governed by a BSD-style2# license that can be found in the LICENSE file.3# SPDX-License-Identifier: BSD-2-Clause45add_definitions(-D_FIDO_INTERNAL)67list(APPEND FIDO_SOURCES8aes256.c9assert.c10authkey.c11bio.c12blob.c13buf.c14cbor.c15compress.c16config.c17cred.c18credman.c19dev.c20ecdh.c21eddsa.c22err.c23es256.c24es384.c25hid.c26info.c27io.c28iso7816.c29largeblob.c30log.c31pin.c32random.c33reset.c34rs1.c35rs256.c36time.c37touch.c38tpm.c39types.c40u2f.c41util.c42)4344if(FUZZ)45list(APPEND FIDO_SOURCES ../fuzz/clock.c)46list(APPEND FIDO_SOURCES ../fuzz/pcsc.c)47list(APPEND FIDO_SOURCES ../fuzz/prng.c)48list(APPEND FIDO_SOURCES ../fuzz/udev.c)49list(APPEND FIDO_SOURCES ../fuzz/uniform_random.c)50list(APPEND FIDO_SOURCES ../fuzz/wrap.c)51endif()5253if(NFC_LINUX)54list(APPEND FIDO_SOURCES netlink.c nfc.c nfc_linux.c)55endif()5657if(USE_PCSC)58list(APPEND FIDO_SOURCES nfc.c pcsc.c)59endif()6061if(USE_HIDAPI)62list(APPEND FIDO_SOURCES hid_hidapi.c)63if(NOT WIN32 AND NOT APPLE)64list(APPEND FIDO_SOURCES hid_unix.c)65endif()66elseif(WIN32)67list(APPEND FIDO_SOURCES hid_win.c)68if(USE_WINHELLO)69list(APPEND FIDO_SOURCES winhello.c)70endif()71elseif(APPLE)72list(APPEND FIDO_SOURCES hid_osx.c)73elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")74list(APPEND FIDO_SOURCES hid_linux.c hid_unix.c)75elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")76list(APPEND FIDO_SOURCES hid_netbsd.c hid_unix.c)77elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")78list(APPEND FIDO_SOURCES hid_openbsd.c hid_unix.c)79elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR80CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")81list(APPEND FIDO_SOURCES hid_freebsd.c hid_unix.c)82else()83message(FATAL_ERROR "please define a hid backend for your platform")84endif()8586if(NOT MSVC)87set_source_files_properties(${FIDO_SOURCES}88PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")89endif()9091list(APPEND COMPAT_SOURCES92../openbsd-compat/bsd-asprintf.c93../openbsd-compat/bsd-getpagesize.c94../openbsd-compat/clock_gettime.c95../openbsd-compat/endian_win32.c96../openbsd-compat/explicit_bzero.c97../openbsd-compat/explicit_bzero_win32.c98../openbsd-compat/freezero.c99../openbsd-compat/recallocarray.c100../openbsd-compat/strlcat.c101../openbsd-compat/timingsafe_bcmp.c102)103104if(WIN32)105list(APPEND BASE_LIBRARIES wsock32 ws2_32 bcrypt setupapi hid)106if(USE_PCSC)107list(APPEND BASE_LIBRARIES winscard)108endif()109elseif(APPLE)110list(APPEND BASE_LIBRARIES "-framework CoreFoundation"111"-framework IOKit")112if(USE_PCSC)113list(APPEND BASE_LIBRARIES "-framework PCSC")114endif()115endif()116117list(APPEND TARGET_LIBRARIES118${CBOR_LIBRARIES}119${CRYPTO_LIBRARIES}120${UDEV_LIBRARIES}121${BASE_LIBRARIES}122${HIDAPI_LIBRARIES}123${ZLIB_LIBRARIES}124${PCSC_LIBRARIES}125)126127# static library128if(BUILD_STATIC_LIBS)129add_library(fido2 STATIC ${FIDO_SOURCES} ${COMPAT_SOURCES})130if(WIN32 AND NOT MINGW)131set_target_properties(fido2 PROPERTIES OUTPUT_NAME fido2_static)132endif()133target_link_libraries(fido2 ${TARGET_LIBRARIES})134install(TARGETS fido2 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}135LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})136endif()137138# dynamic library139if(BUILD_SHARED_LIBS)140add_library(fido2_shared SHARED ${FIDO_SOURCES} ${COMPAT_SOURCES})141set_target_properties(fido2_shared PROPERTIES OUTPUT_NAME fido2142VERSION ${FIDO_VERSION} SOVERSION ${FIDO_MAJOR})143target_link_libraries(fido2_shared ${TARGET_LIBRARIES})144install(TARGETS fido2_shared145ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}146LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}147RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})148endif()149150install(FILES fido.h DESTINATION include)151install(DIRECTORY fido DESTINATION include)152153if(NOT MSVC)154configure_file(libfido2.pc.in libfido2.pc @ONLY)155install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libfido2.pc"156DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")157endif()158159160