diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 111 |
1 files changed, 51 insertions, 60 deletions
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) | |||
10 | 10 | ||
11 | include(CheckCCompilerFlag) | 11 | include(CheckCCompilerFlag) |
12 | include(CheckFunctionExists) | 12 | include(CheckFunctionExists) |
13 | include(CheckLibraryExists) | ||
14 | include(CheckSymbolExists) | ||
13 | include(CheckIncludeFiles) | 15 | include(CheckIncludeFiles) |
14 | include(CheckTypeSize) | 16 | include(CheckTypeSize) |
15 | include(GNUInstallDirs) | 17 | include(GNUInstallDirs) |
@@ -19,7 +21,7 @@ set(CMAKE_VERBOSE_MAKEFILE on) | |||
19 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) | 21 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
20 | 22 | ||
21 | set(FIDO_MAJOR "1") | 23 | set(FIDO_MAJOR "1") |
22 | set(FIDO_MINOR "4") | 24 | set(FIDO_MINOR "5") |
23 | set(FIDO_PATCH "0") | 25 | set(FIDO_PATCH "0") |
24 | set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH}) | 26 | set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH}) |
25 | 27 | ||
@@ -33,21 +35,12 @@ if(CYGWIN OR MSYS) | |||
33 | endif() | 35 | endif() |
34 | 36 | ||
35 | if(WIN32) | 37 | if(WIN32) |
36 | add_definitions(-DWIN32_LEAN_AND_MEAN) | 38 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) |
37 | endif() | 39 | endif() |
38 | 40 | ||
39 | if(APPLE) | 41 | if(APPLE) |
40 | set(CMAKE_INSTALL_NAME_DIR | 42 | set(CMAKE_INSTALL_NAME_DIR |
41 | "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | 43 | "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
42 | endif() | ||
43 | |||
44 | # Observe OpenBSD's library versioning scheme. | ||
45 | if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") | ||
46 | set(LIB_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}) | ||
47 | set(LIB_SOVERSION ${LIB_VERSION}) | ||
48 | else() | ||
49 | set(LIB_VERSION ${FIDO_VERSION}) | ||
50 | set(LIB_SOVERSION ${FIDO_MAJOR}) | ||
51 | endif() | 44 | endif() |
52 | 45 | ||
53 | if(MSVC) | 46 | if(MSVC) |
@@ -58,7 +51,7 @@ if(MSVC) | |||
58 | "under msvc") | 51 | "under msvc") |
59 | endif() | 52 | endif() |
60 | set(CBOR_LIBRARIES cbor) | 53 | set(CBOR_LIBRARIES cbor) |
61 | set(CRYPTO_LIBRARIES crypto-45) | 54 | set(CRYPTO_LIBRARIES crypto-46) |
62 | set(MSVC_DISABLED_WARNINGS_LIST | 55 | set(MSVC_DISABLED_WARNINGS_LIST |
63 | "C4200" # nonstandard extension used: zero-sized array in | 56 | "C4200" # nonstandard extension used: zero-sized array in |
64 | # struct/union; | 57 | # struct/union; |
@@ -71,9 +64,9 @@ if(MSVC) | |||
71 | # The construction in the following 3 lines was taken from LibreSSL's | 64 | # The construction in the following 3 lines was taken from LibreSSL's |
72 | # CMakeLists.txt. | 65 | # CMakeLists.txt. |
73 | string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR | 66 | string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR |
74 | ${MSVC_DISABLED_WARNINGS_LIST}) | 67 | ${MSVC_DISABLED_WARNINGS_LIST}) |
75 | string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) | 68 | string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) |
76 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 ${MSVC_DISABLED_WARNINGS_STR}") | 69 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}") |
77 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7") | 70 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7") |
78 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi") | 71 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi") |
79 | else() | 72 | else() |
@@ -102,13 +95,18 @@ else() | |||
102 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") | 95 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
103 | pkg_search_module(UDEV libudev REQUIRED) | 96 | pkg_search_module(UDEV libudev REQUIRED) |
104 | set(UDEV_NAME "udev") | 97 | set(UDEV_NAME "udev") |
98 | include_directories(${UDEV_INCLUDE_DIRS}) | ||
99 | link_directories(${UDEV_LIBRARY_DIRS}) | ||
105 | # Define be32toh(). | 100 | # Define be32toh(). |
106 | add_definitions(-D_GNU_SOURCE) | 101 | add_definitions(-D_GNU_SOURCE) |
107 | # If using hidapi, use hidapi-hidraw. | 102 | # If using hidapi, use hidapi-hidraw. |
108 | set(HIDAPI_SUFFIX -hidraw) | 103 | set(HIDAPI_SUFFIX -hidraw) |
109 | elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR | 104 | # Look for clock_gettime in librt. |
110 | CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") | 105 | check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) |
111 | set(BASE_LIBRARIES usbhid) | 106 | if(HAVE_CLOCK_GETTIME) |
107 | set(BASE_LIBRARIES ${BASE_LIBRARIES} rt) | ||
108 | add_definitions(-DHAVE_CLOCK_GETTIME) | ||
109 | endif() | ||
112 | endif() | 110 | endif() |
113 | 111 | ||
114 | if(MINGW) | 112 | if(MINGW) |
@@ -122,6 +120,8 @@ else() | |||
122 | add_definitions(-DUSE_HIDAPI) | 120 | add_definitions(-DUSE_HIDAPI) |
123 | pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED) | 121 | pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED) |
124 | if(HIDAPI_FOUND) | 122 | if(HIDAPI_FOUND) |
123 | include_directories(${HIDAPI_INCLUDE_DIRS}) | ||
124 | link_directories(${HIDAPI_LIBRARY_DIRS}) | ||
125 | set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX}) | 125 | set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX}) |
126 | endif() | 126 | endif() |
127 | endif() | 127 | endif() |
@@ -153,24 +153,6 @@ else() | |||
153 | endif() | 153 | endif() |
154 | add_definitions(-DFIDO_FUZZ) | 154 | add_definitions(-DFIDO_FUZZ) |
155 | endif() | 155 | endif() |
156 | |||
157 | if(ASAN) | ||
158 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,leak") | ||
159 | endif() | ||
160 | |||
161 | if(MSAN) | ||
162 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") | ||
163 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-track-origins") | ||
164 | endif() | ||
165 | |||
166 | if(UBSAN) | ||
167 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") | ||
168 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-trap=undefined") | ||
169 | endif() | ||
170 | |||
171 | if(COVERAGE) | ||
172 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping") | ||
173 | endif() | ||
174 | endif() | 156 | endif() |
175 | 157 | ||
176 | # Use -Wshorten-64-to-32 if available. | 158 | # Use -Wshorten-64-to-32 if available. |
@@ -333,6 +315,20 @@ if(UNIX) | |||
333 | add_definitions(-DHAVE_DEV_URANDOM) | 315 | add_definitions(-DHAVE_DEV_URANDOM) |
334 | endif() | 316 | endif() |
335 | 317 | ||
318 | # clock_gettime | ||
319 | if(NOT HAVE_CLOCK_GETTIME) | ||
320 | check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) | ||
321 | if(HAVE_CLOCK_GETTIME) | ||
322 | add_definitions(-DHAVE_CLOCK_GETTIME) | ||
323 | endif() | ||
324 | endif() | ||
325 | |||
326 | # timespecsub | ||
327 | check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB) | ||
328 | if(HAVE_TIMESPECSUB) | ||
329 | add_definitions(-DHAVE_TIMESPECSUB) | ||
330 | endif() | ||
331 | |||
336 | # export list | 332 | # export list |
337 | if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR | 333 | if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR |
338 | CMAKE_C_COMPILER_ID STREQUAL "AppleClang")) | 334 | CMAKE_C_COMPILER_ID STREQUAL "AppleClang")) |
@@ -366,7 +362,7 @@ elseif(NOT MSVC) | |||
366 | endif() | 362 | endif() |
367 | else() | 363 | else() |
368 | string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} | 364 | string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} |
369 | " /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"") | 365 | " /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"") |
370 | endif() | 366 | endif() |
371 | 367 | ||
372 | include_directories(${CMAKE_SOURCE_DIR}/src) | 368 | include_directories(${CMAKE_SOURCE_DIR}/src) |
@@ -376,38 +372,33 @@ include_directories(${CRYPTO_INCLUDE_DIRS}) | |||
376 | link_directories(${CBOR_LIBRARY_DIRS}) | 372 | link_directories(${CBOR_LIBRARY_DIRS}) |
377 | link_directories(${CRYPTO_LIBRARY_DIRS}) | 373 | link_directories(${CRYPTO_LIBRARY_DIRS}) |
378 | 374 | ||
375 | message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}") | ||
376 | message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}") | ||
377 | message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}") | ||
378 | message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}") | ||
379 | message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") | ||
379 | message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") | 380 | message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") |
380 | message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}") | 381 | message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}") |
381 | message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") | ||
382 | message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") | 382 | message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") |
383 | message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") | 383 | message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") |
384 | message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}") | ||
385 | message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}") | ||
386 | message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}") | ||
387 | message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}") | 384 | message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}") |
388 | message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}") | ||
389 | message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}") | 385 | message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}") |
390 | message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}") | 386 | message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}") |
391 | message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}") | 387 | message(STATUS "FIDO_VERSION: ${FIDO_VERSION}") |
392 | message(STATUS "VERSION: ${FIDO_VERSION}") | ||
393 | message(STATUS "LIB_VERSION: ${LIB_VERSION}") | ||
394 | message(STATUS "LIB_SOVERSION: ${LIB_SOVERSION}") | ||
395 | message(STATUS "FUZZ: ${FUZZ}") | 388 | message(STATUS "FUZZ: ${FUZZ}") |
396 | message(STATUS "AFL: ${AFL}") | 389 | if(USE_HIDAPI) |
390 | message(STATUS "HIDAPI_INCLUDE_DIRS: ${HIDAPI_INCLUDE_DIRS}") | ||
391 | message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}") | ||
392 | message(STATUS "HIDAPI_LIBRARY_DIRS: ${HIDAPI_LIBRARY_DIRS}") | ||
393 | endif() | ||
397 | message(STATUS "LIBFUZZER: ${LIBFUZZER}") | 394 | message(STATUS "LIBFUZZER: ${LIBFUZZER}") |
398 | message(STATUS "ASAN: ${ASAN}") | ||
399 | message(STATUS "MSAN: ${MSAN}") | ||
400 | message(STATUS "COVERAGE: ${COVERAGE}") | ||
401 | message(STATUS "TLS: ${TLS}") | 395 | message(STATUS "TLS: ${TLS}") |
396 | message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}") | ||
397 | message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}") | ||
398 | message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}") | ||
399 | message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}") | ||
402 | message(STATUS "USE_HIDAPI: ${USE_HIDAPI}") | 400 | message(STATUS "USE_HIDAPI: ${USE_HIDAPI}") |
403 | 401 | ||
404 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
405 | message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}") | ||
406 | message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}") | ||
407 | message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}") | ||
408 | message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}") | ||
409 | endif() | ||
410 | |||
411 | subdirs(src) | 402 | subdirs(src) |
412 | subdirs(examples) | 403 | subdirs(examples) |
413 | subdirs(tools) | 404 | subdirs(tools) |
@@ -415,7 +406,7 @@ subdirs(man) | |||
415 | 406 | ||
416 | if(NOT WIN32) | 407 | if(NOT WIN32) |
417 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") | 408 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
418 | if(NOT MSAN AND NOT LIBFUZZER) | 409 | if(NOT LIBFUZZER AND NOT FUZZ) |
419 | subdirs(regress) | 410 | subdirs(regress) |
420 | endif() | 411 | endif() |
421 | endif() | 412 | endif() |