From 173bfbf7886608a4a7abbfac6a42ac4bf4a3432d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 20 Sep 2020 16:14:20 +0100 Subject: New upstream version 1.5.0 --- CMakeLists.txt | 111 ++++++++++++++++++++++++++------------------------------- 1 file changed, 51 insertions(+), 60 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb2e87..dbd5fa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ cmake_minimum_required(VERSION 3.0) include(CheckCCompilerFlag) include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckSymbolExists) include(CheckIncludeFiles) include(CheckTypeSize) include(GNUInstallDirs) @@ -19,7 +21,7 @@ set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(FIDO_MAJOR "1") -set(FIDO_MINOR "4") +set(FIDO_MINOR "5") set(FIDO_PATCH "0") set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH}) @@ -33,21 +35,12 @@ if(CYGWIN OR MSYS) endif() if(WIN32) - add_definitions(-DWIN32_LEAN_AND_MEAN) + add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) endif() if(APPLE) set(CMAKE_INSTALL_NAME_DIR - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -endif() - -# Observe OpenBSD's library versioning scheme. -if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - set(LIB_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}) - set(LIB_SOVERSION ${LIB_VERSION}) -else() - set(LIB_VERSION ${FIDO_VERSION}) - set(LIB_SOVERSION ${FIDO_MAJOR}) + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") endif() if(MSVC) @@ -58,7 +51,7 @@ if(MSVC) "under msvc") endif() set(CBOR_LIBRARIES cbor) - set(CRYPTO_LIBRARIES crypto-45) + set(CRYPTO_LIBRARIES crypto-46) set(MSVC_DISABLED_WARNINGS_LIST "C4200" # nonstandard extension used: zero-sized array in # struct/union; @@ -71,9 +64,9 @@ if(MSVC) # The construction in the following 3 lines was taken from LibreSSL's # CMakeLists.txt. string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR - ${MSVC_DISABLED_WARNINGS_LIST}) + ${MSVC_DISABLED_WARNINGS_LIST}) string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 ${MSVC_DISABLED_WARNINGS_STR}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi") else() @@ -102,13 +95,18 @@ else() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") pkg_search_module(UDEV libudev REQUIRED) set(UDEV_NAME "udev") + include_directories(${UDEV_INCLUDE_DIRS}) + link_directories(${UDEV_LIBRARY_DIRS}) # Define be32toh(). add_definitions(-D_GNU_SOURCE) # If using hidapi, use hidapi-hidraw. set(HIDAPI_SUFFIX -hidraw) - elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - set(BASE_LIBRARIES usbhid) + # Look for clock_gettime in librt. + check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) + if(HAVE_CLOCK_GETTIME) + set(BASE_LIBRARIES ${BASE_LIBRARIES} rt) + add_definitions(-DHAVE_CLOCK_GETTIME) + endif() endif() if(MINGW) @@ -122,6 +120,8 @@ else() add_definitions(-DUSE_HIDAPI) pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED) if(HIDAPI_FOUND) + include_directories(${HIDAPI_INCLUDE_DIRS}) + link_directories(${HIDAPI_LIBRARY_DIRS}) set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX}) endif() endif() @@ -153,24 +153,6 @@ else() endif() add_definitions(-DFIDO_FUZZ) endif() - - if(ASAN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,leak") - endif() - - if(MSAN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-track-origins") - endif() - - if(UBSAN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-trap=undefined") - endif() - - if(COVERAGE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping") - endif() endif() # Use -Wshorten-64-to-32 if available. @@ -333,6 +315,20 @@ if(UNIX) add_definitions(-DHAVE_DEV_URANDOM) endif() +# clock_gettime +if(NOT HAVE_CLOCK_GETTIME) + check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) + if(HAVE_CLOCK_GETTIME) + add_definitions(-DHAVE_CLOCK_GETTIME) + endif() +endif() + +# timespecsub +check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB) +if(HAVE_TIMESPECSUB) + add_definitions(-DHAVE_TIMESPECSUB) +endif() + # export list if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")) @@ -366,7 +362,7 @@ elseif(NOT MSVC) endif() else() string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} - " /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"") + " /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"") endif() include_directories(${CMAKE_SOURCE_DIR}/src) @@ -376,38 +372,33 @@ include_directories(${CRYPTO_INCLUDE_DIRS}) link_directories(${CBOR_LIBRARY_DIRS}) link_directories(${CRYPTO_LIBRARY_DIRS}) +message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}") +message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}") +message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}") +message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}") +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}") -message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") -message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}") -message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}") -message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}") +message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}") -message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}") message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}") -message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}") -message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}") -message(STATUS "VERSION: ${FIDO_VERSION}") -message(STATUS "LIB_VERSION: ${LIB_VERSION}") -message(STATUS "LIB_SOVERSION: ${LIB_SOVERSION}") +message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}") +message(STATUS "FIDO_VERSION: ${FIDO_VERSION}") message(STATUS "FUZZ: ${FUZZ}") -message(STATUS "AFL: ${AFL}") +if(USE_HIDAPI) + message(STATUS "HIDAPI_INCLUDE_DIRS: ${HIDAPI_INCLUDE_DIRS}") + message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}") + message(STATUS "HIDAPI_LIBRARY_DIRS: ${HIDAPI_LIBRARY_DIRS}") +endif() message(STATUS "LIBFUZZER: ${LIBFUZZER}") -message(STATUS "ASAN: ${ASAN}") -message(STATUS "MSAN: ${MSAN}") -message(STATUS "COVERAGE: ${COVERAGE}") message(STATUS "TLS: ${TLS}") +message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}") +message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}") +message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}") +message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}") message(STATUS "USE_HIDAPI: ${USE_HIDAPI}") -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}") - message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}") - message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}") - message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}") -endif() - subdirs(src) subdirs(examples) subdirs(tools) @@ -415,7 +406,7 @@ subdirs(man) if(NOT WIN32) if(CMAKE_BUILD_TYPE STREQUAL "Debug") - if(NOT MSAN AND NOT LIBFUZZER) + if(NOT LIBFUZZER AND NOT FUZZ) subdirs(regress) endif() endif() -- cgit v1.2.3