| 1 |
# Copyright (c) 2018-2022 Yubico AB. All rights reserved. |
| 2 |
# Use of this source code is governed by a BSD-style |
| 3 |
# license that can be found in the LICENSE file. |
| 4 |
# SPDX-License-Identifier: BSD-2-Clause |
| 5 |
# cmake_minimum_required(VERSION 3.7) |
| 6 |
|
| 7 |
# detect AppleClang; needs to come before project() |
| 8 |
# cmake_policy(SET CMP0025 NEW) |
| 9 |
|
| 10 |
project(libfido2 C) |
| 11 |
# Set PIE flags for POSITION_INDEPENDENT_CODE targets, added in CMake 3.14. |
| 12 |
if(POLICY CMP0083) |
| 13 |
# cmake_policy(SET CMP0083 NEW) |
| 14 |
endif() |
| 15 |
|
| 16 |
include(CheckCCompilerFlag) |
| 17 |
include(CheckFunctionExists) |
| 18 |
include(CheckLibraryExists) |
| 19 |
include(CheckSymbolExists) |
| 20 |
include(CheckIncludeFiles) |
| 21 |
include(CheckTypeSize) |
| 22 |
include(GNUInstallDirs) |
| 23 |
# include(CheckPIESupported OPTIONAL RESULT_VARIABLE CHECK_PIE_SUPPORTED) |
| 24 |
if(CHECK_PIE_SUPPORTED) |
| 25 |
check_pie_supported(LANGUAGES C) |
| 26 |
endif() |
| 27 |
|
| 28 |
#set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 29 |
#set(CMAKE_COLOR_MAKEFILE OFF) |
| 30 |
#set(CMAKE_VERBOSE_MAKEFILE ON) |
| 31 |
set(FIDO_MAJOR "1") |
| 32 |
set(FIDO_MINOR "15") |
| 33 |
set(FIDO_PATCH "0") |
| 34 |
set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH}) |
| 35 |
|
| 36 |
# Rename some options, to avoid conflicts with other projects/packages. |
| 37 |
# Do not rename everything, we want to minimize our diff. |
| 38 |
# BUILD_TESTS is OFF elsewhere also. |
| 39 |
# BUILD_EXAMPLES is OFF elsewhere also. |
| 40 |
# BUILD_STATIC_LIBS conflicts with with extra/curl. |
| 41 |
# BUILD_SHARED_LIBS conflicts with several 3rd party packages. |
| 42 |
|
| 43 |
option(BUILD_TESTS "Build the regress tests" OFF) |
| 44 |
option(BUILD_EXAMPLES "Build example programs" OFF) |
| 45 |
option(BUILD_MANPAGES "Build man pages" ON) |
| 46 |
option(FIDO_BUILD_SHARED_LIBS "Build a shared library" ON) |
| 47 |
option(FIDO_BUILD_STATIC_LIBS "Build a static library" ON) |
| 48 |
option(BUILD_TOOLS "Build tool programs" ON) |
| 49 |
option(FUZZ "Enable fuzzing instrumentation" OFF) |
| 50 |
option(USE_HIDAPI "Use hidapi as the HID backend" OFF) |
| 51 |
option(USE_PCSC "Enable experimental PCSC support" OFF) |
| 52 |
option(USE_WINHELLO "Abstract Windows Hello as a FIDO device" ON) |
| 53 |
option(NFC_LINUX "Enable NFC support on Linux" ON) |
| 54 |
|
| 55 |
add_definitions(-D_FIDO_MAJOR=${FIDO_MAJOR}) |
| 56 |
add_definitions(-D_FIDO_MINOR=${FIDO_MINOR}) |
| 57 |
add_definitions(-D_FIDO_PATCH=${FIDO_PATCH}) |
| 58 |
|
| 59 |
if(BUILD_SHARED_LIBS) |
| 60 |
set(_FIDO2_LIBRARY fido2_shared) |
| 61 |
elseif(BUILD_STATIC_LIBS) |
| 62 |
set(_FIDO2_LIBRARY fido2) |
| 63 |
else() |
| 64 |
# message(FATAL_ERROR "Nothing to build (BUILD_*_LIBS=OFF)") |
| 65 |
endif() |
| 66 |
|
| 67 |
if(CYGWIN OR MSYS OR MINGW) |
| 68 |
set(WIN32 1) |
| 69 |
endif() |
| 70 |
|
| 71 |
if(WIN32) |
| 72 |
IF(WIN32_CLANG) |
| 73 |
add_definitions(-DWIN32_LEAN_AND_MEAN) |
| 74 |
STRING_APPEND(CMAKE_C_FLAGS |
| 75 |
" -Wno-tautological-constant-out-of-range-compare") |
| 76 |
ELSE() |
| 77 |
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) |
| 78 |
ENDIF() |
| 79 |
endif() |
| 80 |
|
| 81 |
if(APPLE) |
| 82 |
set(CMAKE_INSTALL_NAME_DIR |
| 83 |
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
| 84 |
endif() |
| 85 |
|
| 86 |
if(NOT MSVC) |
| 87 |
if(NOT APPLE) |
| 88 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_POSIX_C_SOURCE=200809L") |
| 89 |
endif() |
| 90 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_BSD_SOURCE") |
| 91 |
if(APPLE) |
| 92 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DARWIN_C_SOURCE") |
| 93 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D__STDC_WANT_LIB_EXT1__=1") |
| 94 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -Wno-deprecated-declarations") |
| 95 |
elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR MINGW OR CYGWIN) |
| 96 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_GNU_SOURCE") |
| 97 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DEFAULT_SOURCE") |
| 98 |
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR |
| 99 |
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD") |
| 100 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D__BSD_VISIBLE=1") |
| 101 |
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") |
| 102 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_NETBSD_SOURCE") |
| 103 |
endif() |
| 104 |
set(FIDO_CFLAGS "${FIDO_CFLAGS} -std=c99") |
| 105 |
set(CMAKE_C_FLAGS "${FIDO_CFLAGS} ${CMAKE_C_FLAGS}") |
| 106 |
endif() |
| 107 |
|
| 108 |
check_c_compiler_flag("-Wshorten-64-to-32" HAVE_SHORTEN_64_TO_32) |
| 109 |
check_c_compiler_flag("-Werror -fstack-protector-all" HAVE_STACK_PROTECTOR_ALL) |
| 110 |
|
| 111 |
check_include_files(cbor.h HAVE_CBOR_H) |
| 112 |
check_include_files(endian.h HAVE_ENDIAN_H) |
| 113 |
check_include_files(err.h HAVE_ERR_H) |
| 114 |
check_include_files(openssl/opensslv.h HAVE_OPENSSLV_H) |
| 115 |
check_include_files(signal.h HAVE_SIGNAL_H) |
| 116 |
check_include_files(sys/random.h HAVE_SYS_RANDOM_H) |
| 117 |
check_include_files(unistd.h HAVE_UNISTD_H) |
| 118 |
|
| 119 |
check_symbol_exists(arc4random_buf stdlib.h HAVE_ARC4RANDOM_BUF) |
| 120 |
check_symbol_exists(asprintf stdio.h HAVE_ASPRINTF) |
| 121 |
check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME) |
| 122 |
check_symbol_exists(explicit_bzero string.h HAVE_EXPLICIT_BZERO) |
| 123 |
check_symbol_exists(freezero stdlib.h HAVE_FREEZERO) |
| 124 |
check_symbol_exists(getline stdio.h HAVE_GETLINE) |
| 125 |
check_symbol_exists(getopt unistd.h HAVE_GETOPT) |
| 126 |
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE) |
| 127 |
check_symbol_exists(getrandom sys/random.h HAVE_GETRANDOM) |
| 128 |
check_symbol_exists(memset_s string.h HAVE_MEMSET_S) |
| 129 |
check_symbol_exists(readpassphrase readpassphrase.h HAVE_READPASSPHRASE) |
| 130 |
check_symbol_exists(recallocarray stdlib.h HAVE_RECALLOCARRAY) |
| 131 |
check_symbol_exists(strlcat string.h HAVE_STRLCAT) |
| 132 |
check_symbol_exists(strlcpy string.h HAVE_STRLCPY) |
| 133 |
check_symbol_exists(strsep string.h HAVE_STRSEP) |
| 134 |
check_symbol_exists(sysconf unistd.h HAVE_SYSCONF) |
| 135 |
check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB) |
| 136 |
check_symbol_exists(timingsafe_bcmp string.h HAVE_TIMINGSAFE_BCMP) |
| 137 |
|
| 138 |
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) |
| 139 |
try_compile(HAVE_POSIX_IOCTL |
| 140 |
"${CMAKE_CURRENT_BINARY_DIR}/posix_ioctl_check.o" |
| 141 |
"${CMAKE_CURRENT_SOURCE_DIR}/openbsd-compat/posix_ioctl_check.c" |
| 142 |
COMPILE_DEFINITIONS "-Werror -Woverflow -Wsign-conversion") |
| 143 |
|
| 144 |
list(APPEND CHECK_VARIABLES |
| 145 |
HAVE_ARC4RANDOM_BUF |
| 146 |
HAVE_ASPRINTF |
| 147 |
HAVE_CBOR_H |
| 148 |
HAVE_CLOCK_GETTIME |
| 149 |
HAVE_ENDIAN_H |
| 150 |
HAVE_ERR_H |
| 151 |
HAVE_FREEZERO |
| 152 |
HAVE_GETLINE |
| 153 |
HAVE_GETOPT |
| 154 |
HAVE_GETPAGESIZE |
| 155 |
HAVE_GETRANDOM |
| 156 |
HAVE_MEMSET_S |
| 157 |
HAVE_OPENSSLV_H |
| 158 |
HAVE_POSIX_IOCTL |
| 159 |
HAVE_READPASSPHRASE |
| 160 |
HAVE_RECALLOCARRAY |
| 161 |
HAVE_SIGNAL_H |
| 162 |
HAVE_STRLCAT |
| 163 |
HAVE_STRLCPY |
| 164 |
HAVE_STRSEP |
| 165 |
HAVE_SYSCONF |
| 166 |
HAVE_SYS_RANDOM_H |
| 167 |
HAVE_TIMESPECSUB |
| 168 |
HAVE_TIMINGSAFE_BCMP |
| 169 |
HAVE_UNISTD_H |
| 170 |
) |
| 171 |
|
| 172 |
foreach(v ${CHECK_VARIABLES}) |
| 173 |
if (${v}) |
| 174 |
add_definitions(-D${v}) |
| 175 |
endif() |
| 176 |
endforeach() |
| 177 |
|
| 178 |
if(HAVE_EXPLICIT_BZERO AND NOT FUZZ) |
| 179 |
add_definitions(-DHAVE_EXPLICIT_BZERO) |
| 180 |
endif() |
| 181 |
|
| 182 |
if(UNIX) |
| 183 |
add_definitions(-DHAVE_DEV_URANDOM) |
| 184 |
endif() |
| 185 |
|
| 186 |
|
| 187 |
if(MSVC) |
| 188 |
IF(DISABLE_THESE_LINES) |
| 189 |
if((NOT CBOR_INCLUDE_DIRS) OR (NOT CBOR_LIBRARY_DIRS) OR |
| 190 |
(NOT CRYPTO_INCLUDE_DIRS) OR (NOT CRYPTO_LIBRARY_DIRS) OR |
| 191 |
(NOT ZLIB_INCLUDE_DIRS) OR (NOT ZLIB_LIBRARY_DIRS)) |
| 192 |
message(FATAL_ERROR "please define " |
| 193 |
"{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY}_DIRS when " |
| 194 |
"building under msvc") |
| 195 |
endif() |
| 196 |
ENDIF(DISABLE_THESE_LINES) |
| 197 |
if(BUILD_TESTS AND BUILD_SHARED_LIBS AND |
| 198 |
((NOT CBOR_BIN_DIRS) OR (NOT ZLIB_BIN_DIRS) OR (NOT CRYPTO_BIN_DIRS))) |
| 199 |
message(FATAL_ERROR "please define {CBOR,CRYPTO,ZLIB}_BIN_DIRS " |
| 200 |
"when building tests") |
| 201 |
endif() |
| 202 |
if(NOT CBOR_LIBRARIES) |
| 203 |
set(CBOR_LIBRARIES cbor) |
| 204 |
endif() |
| 205 |
if(NOT ZLIB_LIBRARIES) |
| 206 |
set(ZLIB_LIBRARIES zlib1) |
| 207 |
endif() |
| 208 |
if(NOT CRYPTO_LIBRARIES) |
| 209 |
set(CRYPTO_LIBRARIES crypto) |
| 210 |
endif() |
| 211 |
|
| 212 |
set(MSVC_DISABLED_WARNINGS_LIST |
| 213 |
"C4152" # nonstandard extension used: function/data pointer |
| 214 |
# conversion in expression; |
| 215 |
"C4200" # nonstandard extension used: zero-sized array in |
| 216 |
# struct/union; |
| 217 |
"C4201" # nonstandard extension used: nameless struct/union; |
| 218 |
"C4204" # nonstandard extension used: non-constant aggregate |
| 219 |
# initializer; |
| 220 |
"C4706" # assignment within conditional expression; |
| 221 |
"C4996" # The POSIX name for this item is deprecated. Instead, |
| 222 |
# use the ISO C and C++ conformant name; |
| 223 |
"C6287" # redundant code: the left and right subexpressions are identical |
| 224 |
) |
| 225 |
# The construction in the following 3 lines was taken from LibreSSL's |
| 226 |
# CMakeLists.txt. |
| 227 |
string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR |
| 228 |
${MSVC_DISABLED_WARNINGS_LIST}) |
| 229 |
string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) |
| 230 |
IF(NOT WIN32_CLANG) |
| 231 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}") |
| 232 |
ENDIF() |
| 233 |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od /Z7 /guard:cf /sdl /RTCcsu") |
| 234 |
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi /guard:cf /sdl") |
| 235 |
if(USE_WINHELLO) |
| 236 |
add_definitions(-DUSE_WINHELLO) |
| 237 |
endif() |
| 238 |
set(NFC_LINUX OFF) |
| 239 |
else() |
| 240 |
IF(DISABLE_THESE_LINES) |
| 241 |
include(FindPkgConfig) |
| 242 |
pkg_search_module(CBOR libcbor) |
| 243 |
pkg_search_module(CRYPTO libcrypto) |
| 244 |
pkg_search_module(ZLIB zlib) |
| 245 |
|
| 246 |
if(NOT CBOR_FOUND AND NOT HAVE_CBOR_H) |
| 247 |
message(FATAL_ERROR "could not find libcbor") |
| 248 |
endif() |
| 249 |
if(NOT CRYPTO_FOUND AND NOT HAVE_OPENSSLV_H) |
| 250 |
message(FATAL_ERROR "could not find libcrypto") |
| 251 |
endif() |
| 252 |
if(NOT ZLIB_FOUND) |
| 253 |
message(FATAL_ERROR "could not find zlib") |
| 254 |
endif() |
| 255 |
ENDIF(DISABLE_THESE_LINES) |
| 256 |
|
| 257 |
if(NOT CBOR_LIBRARIES) |
| 258 |
set(CBOR_LIBRARIES "cbor") |
| 259 |
endif() |
| 260 |
if(NOT CRYPTO_LIBRARIES) |
| 261 |
set(CRYPTO_LIBRARIES "crypto") |
| 262 |
endif() |
| 263 |
|
| 264 |
IF(DISABLE_THESE_LINES) |
| 265 |
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 266 |
pkg_search_module(UDEV libudev REQUIRED) |
| 267 |
set(UDEV_NAME "udev") |
| 268 |
# If using hidapi, use hidapi-hidraw. |
| 269 |
set(HIDAPI_SUFFIX -hidraw) |
| 270 |
if(NOT HAVE_CLOCK_GETTIME) |
| 271 |
# Look for clock_gettime in librt. |
| 272 |
check_library_exists(rt clock_gettime "time.h" |
| 273 |
HAVE_CLOCK_GETTIME) |
| 274 |
if (HAVE_CLOCK_GETTIME) |
| 275 |
add_definitions(-DHAVE_CLOCK_GETTIME) |
| 276 |
set(BASE_LIBRARIES ${BASE_LIBRARIES} rt) |
| 277 |
endif() |
| 278 |
endif() |
| 279 |
else() |
| 280 |
set(NFC_LINUX OFF) |
| 281 |
endif() |
| 282 |
|
| 283 |
if(MINGW) |
| 284 |
# MinGW is stuck with a flavour of C89. |
| 285 |
add_definitions(-DFIDO_NO_DIAGNOSTIC) |
| 286 |
add_definitions(-DWC_ERR_INVALID_CHARS=0x80) |
| 287 |
add_compile_options(-Wno-unused-parameter) |
| 288 |
endif() |
| 289 |
|
| 290 |
if(FUZZ) |
| 291 |
set(USE_PCSC ON) |
| 292 |
add_definitions(-DFIDO_FUZZ) |
| 293 |
endif() |
| 294 |
|
| 295 |
# If building with PCSC, look for pcsc-lite. |
| 296 |
if(USE_PCSC AND NOT (APPLE OR CYGWIN OR MSYS OR MINGW)) |
| 297 |
pkg_search_module(PCSC libpcsclite REQUIRED) |
| 298 |
set(PCSC_LIBRARIES pcsclite) |
| 299 |
endif() |
| 300 |
|
| 301 |
if(USE_HIDAPI) |
| 302 |
add_definitions(-DUSE_HIDAPI) |
| 303 |
pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED) |
| 304 |
set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX}) |
| 305 |
endif() |
| 306 |
|
| 307 |
if(NFC_LINUX) |
| 308 |
add_definitions(-DUSE_NFC) |
| 309 |
endif() |
| 310 |
|
| 311 |
if(WIN32) |
| 312 |
if(USE_WINHELLO) |
| 313 |
add_definitions(-DUSE_WINHELLO) |
| 314 |
endif() |
| 315 |
else() |
| 316 |
set(USE_WINHELLO OFF) |
| 317 |
endif() |
| 318 |
ENDIF(DISABLE_THESE_LINES) |
| 319 |
|
| 320 |
add_compile_options(-Wall) |
| 321 |
add_compile_options(-Wextra) |
| 322 |
add_compile_options(-Werror) |
| 323 |
add_compile_options(-Wshadow) |
| 324 |
add_compile_options(-Wcast-qual) |
| 325 |
add_compile_options(-Wwrite-strings) |
| 326 |
add_compile_options(-Wmissing-prototypes) |
| 327 |
add_compile_options(-Wbad-function-cast) |
| 328 |
add_compile_options(-Wimplicit-fallthrough) |
| 329 |
add_compile_options(-pedantic) |
| 330 |
add_compile_options(-pedantic-errors) |
| 331 |
|
| 332 |
set(EXTRA_CFLAGS "-Wconversion -Wsign-conversion") |
| 333 |
|
| 334 |
if(WIN32) |
| 335 |
add_compile_options(-Wno-type-limits) |
| 336 |
add_compile_options(-Wno-cast-function-type) |
| 337 |
endif() |
| 338 |
|
| 339 |
if(HAVE_SHORTEN_64_TO_32) |
| 340 |
add_compile_options(-Wshorten-64-to-32) |
| 341 |
endif() |
| 342 |
|
| 343 |
if(HAVE_STACK_PROTECTOR_ALL) |
| 344 |
add_compile_options(-fstack-protector-all) |
| 345 |
endif() |
| 346 |
|
| 347 |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g2") |
| 348 |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer") |
| 349 |
# set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2") |
| 350 |
|
| 351 |
if(CRYPTO_VERSION VERSION_GREATER_EQUAL 3.0) |
| 352 |
add_definitions(-DOPENSSL_API_COMPAT=0x10100000L) |
| 353 |
endif() |
| 354 |
|
| 355 |
if(NOT FUZZ) |
| 356 |
set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wframe-larger-than=2047") |
| 357 |
endif() |
| 358 |
endif() |
| 359 |
|
| 360 |
# Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 |
| 361 |
if(CMAKE_COMPILER_IS_GNUCC) |
| 362 |
add_compile_options(-Wno-unused-result) |
| 363 |
endif() |
| 364 |
|
| 365 |
# Decide which keyword to use for thread-local storage. |
| 366 |
if(CMAKE_COMPILER_IS_GNUCC OR |
| 367 |
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR |
| 368 |
CMAKE_C_COMPILER_ID STREQUAL "AppleClang") |
| 369 |
set(TLS "__thread") |
| 370 |
elseif(WIN32) |
| 371 |
set(TLS "__declspec(thread)") |
| 372 |
endif() |
| 373 |
add_definitions(-DTLS=${TLS}) |
| 374 |
|
| 375 |
if(USE_PCSC) |
| 376 |
add_definitions(-DUSE_PCSC) |
| 377 |
endif() |
| 378 |
|
| 379 |
# export list |
| 380 |
if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR |
| 381 |
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")) |
| 382 |
# clang + lld |
| 383 |
string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} |
| 384 |
" -exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/src/export.llvm") |
| 385 |
elseif(NOT MSVC) |
| 386 |
# clang/gcc + gnu ld |
| 387 |
if(FUZZ) |
| 388 |
string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} |
| 389 |
" -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/fuzz/export.gnu") |
| 390 |
else() |
| 391 |
string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} |
| 392 |
" -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/export.gnu") |
| 393 |
endif() |
| 394 |
if(NOT WIN32) |
| 395 |
string(CONCAT CMAKE_SHARED_LINKER_FLAGS |
| 396 |
${CMAKE_SHARED_LINKER_FLAGS} |
| 397 |
" -Wl,-z,noexecstack -Wl,-z,relro,-z,now") |
| 398 |
string(CONCAT CMAKE_EXE_LINKER_FLAGS |
| 399 |
${CMAKE_EXE_LINKER_FLAGS} |
| 400 |
" -Wl,-z,noexecstack -Wl,-z,relro,-z,now") |
| 401 |
if(FUZZ) |
| 402 |
file(STRINGS fuzz/wrapped.sym WRAPPED_SYMBOLS) |
| 403 |
foreach(s ${WRAPPED_SYMBOLS}) |
| 404 |
string(CONCAT CMAKE_SHARED_LINKER_FLAGS |
| 405 |
${CMAKE_SHARED_LINKER_FLAGS} |
| 406 |
" -Wl,--wrap=${s}") |
| 407 |
endforeach() |
| 408 |
endif() |
| 409 |
endif() |
| 410 |
else() |
| 411 |
string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} |
| 412 |
" /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"") |
| 413 |
endif() |
| 414 |
|
| 415 |
include_directories(${PROJECT_SOURCE_DIR}/src) |
| 416 |
IF(DISABLE_THESE_LINES) |
| 417 |
include_directories(${CBOR_INCLUDE_DIRS}) |
| 418 |
include_directories(${CRYPTO_INCLUDE_DIRS}) |
| 419 |
include_directories(${HIDAPI_INCLUDE_DIRS}) |
| 420 |
include_directories(${PCSC_INCLUDE_DIRS}) |
| 421 |
include_directories(${UDEV_INCLUDE_DIRS}) |
| 422 |
include_directories(${ZLIB_INCLUDE_DIRS}) |
| 423 |
|
| 424 |
link_directories(${CBOR_LIBRARY_DIRS}) |
| 425 |
link_directories(${CRYPTO_LIBRARY_DIRS}) |
| 426 |
link_directories(${HIDAPI_LIBRARY_DIRS}) |
| 427 |
link_directories(${PCSC_LIBRARY_DIRS}) |
| 428 |
link_directories(${UDEV_LIBRARY_DIRS}) |
| 429 |
link_directories(${ZLIB_LIBRARY_DIRS}) |
| 430 |
|
| 431 |
message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}") |
| 432 |
message(STATUS "BUILD_EXAMPLES: ${BUILD_EXAMPLES}") |
| 433 |
message(STATUS "BUILD_MANPAGES: ${BUILD_MANPAGES}") |
| 434 |
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") |
| 435 |
message(STATUS "BUILD_STATIC_LIBS: ${BUILD_STATIC_LIBS}") |
| 436 |
message(STATUS "BUILD_TOOLS: ${BUILD_TOOLS}") |
| 437 |
message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}") |
| 438 |
message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}") |
| 439 |
message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}") |
| 440 |
if(BUILD_TESTS) |
| 441 |
message(STATUS "CBOR_BIN_DIRS: ${CBOR_BIN_DIRS}") |
| 442 |
endif() |
| 443 |
message(STATUS "CBOR_VERSION: ${CBOR_VERSION}") |
| 444 |
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") |
| 445 |
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") |
| 446 |
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}") |
| 447 |
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") |
| 448 |
message(STATUS "CMAKE_CROSSCOMPILING: ${CMAKE_CROSSCOMPILING}") |
| 449 |
message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}") |
| 450 |
message(STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}") |
| 451 |
message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}") |
| 452 |
message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") |
| 453 |
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") |
| 454 |
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") |
| 455 |
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") |
| 456 |
message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}") |
| 457 |
message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}") |
| 458 |
message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}") |
| 459 |
message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}") |
| 460 |
if(BUILD_TESTS) |
| 461 |
message(STATUS "CRYPTO_BIN_DIRS: ${CRYPTO_BIN_DIRS}") |
| 462 |
endif() |
| 463 |
message(STATUS "CRYPTO_VERSION: ${CRYPTO_VERSION}") |
| 464 |
message(STATUS "FIDO_VERSION: ${FIDO_VERSION}") |
| 465 |
message(STATUS "FUZZ: ${FUZZ}") |
| 466 |
if(FUZZ) |
| 467 |
message(STATUS "FUZZ_LDFLAGS: ${FUZZ_LDFLAGS}") |
| 468 |
endif() |
| 469 |
message(STATUS "ZLIB_INCLUDE_DIRS: ${ZLIB_INCLUDE_DIRS}") |
| 470 |
message(STATUS "ZLIB_LIBRARIES: ${ZLIB_LIBRARIES}") |
| 471 |
message(STATUS "ZLIB_LIBRARY_DIRS: ${ZLIB_LIBRARY_DIRS}") |
| 472 |
if(BUILD_TESTS) |
| 473 |
message(STATUS "ZLIB_BIN_DIRS: ${ZLIB_BIN_DIRS}") |
| 474 |
endif() |
| 475 |
message(STATUS "ZLIB_VERSION: ${ZLIB_VERSION}") |
| 476 |
if(USE_HIDAPI) |
| 477 |
message(STATUS "HIDAPI_INCLUDE_DIRS: ${HIDAPI_INCLUDE_DIRS}") |
| 478 |
message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}") |
| 479 |
message(STATUS "HIDAPI_LIBRARY_DIRS: ${HIDAPI_LIBRARY_DIRS}") |
| 480 |
message(STATUS "HIDAPI_VERSION: ${HIDAPI_VERSION}") |
| 481 |
endif() |
| 482 |
message(STATUS "PCSC_INCLUDE_DIRS: ${PCSC_INCLUDE_DIRS}") |
| 483 |
message(STATUS "PCSC_LIBRARIES: ${PCSC_LIBRARIES}") |
| 484 |
message(STATUS "PCSC_LIBRARY_DIRS: ${PCSC_LIBRARY_DIRS}") |
| 485 |
message(STATUS "PCSC_VERSION: ${PCSC_VERSION}") |
| 486 |
message(STATUS "TLS: ${TLS}") |
| 487 |
message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}") |
| 488 |
message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}") |
| 489 |
message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}") |
| 490 |
message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}") |
| 491 |
message(STATUS "UDEV_VERSION: ${UDEV_VERSION}") |
| 492 |
message(STATUS "USE_HIDAPI: ${USE_HIDAPI}") |
| 493 |
message(STATUS "USE_PCSC: ${USE_PCSC}") |
| 494 |
message(STATUS "USE_WINHELLO: ${USE_WINHELLO}") |
| 495 |
message(STATUS "NFC_LINUX: ${NFC_LINUX}") |
| 496 |
ENDIF(DISABLE_THESE_LINES) |
| 497 |
|
| 498 |
if(BUILD_TESTS) |
| 499 |
enable_testing() |
| 500 |
endif() |
| 501 |
|
| 502 |
add_subdirectory(src) |
| 503 |
|
| 504 |
if(BUILD_TESTS) |
| 505 |
add_subdirectory(regress) |
| 506 |
endif() |
| 507 |
if(BUILD_EXAMPLES) |
| 508 |
add_subdirectory(examples) |
| 509 |
endif() |
| 510 |
if(BUILD_TOOLS) |
| 511 |
add_subdirectory(tools) |
| 512 |
endif() |
| 513 |
if(BUILD_MANPAGES AND NOT MSVC) |
| 514 |
add_subdirectory(man) |
| 515 |
endif() |
| 516 |
|
| 517 |
if(NOT WIN32) |
| 518 |
if(FUZZ) |
| 519 |
add_subdirectory(fuzz) |
| 520 |
endif() |
| 521 |
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 522 |
add_subdirectory(udev) |
| 523 |
endif() |
| 524 |
endif() |