1# Copyright (c) 2018 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
5list(APPEND COMPAT_SOURCES
6	../openbsd-compat/clock_gettime.c
7	../openbsd-compat/getopt_long.c
8	../openbsd-compat/strlcat.c
9	../openbsd-compat/strlcpy.c
10)
11
12if(WIN32 AND BUILD_SHARED_LIBS AND NOT CYGWIN AND NOT MSYS)
13	list(APPEND COMPAT_SOURCES ../openbsd-compat/posix_win.c)
14endif()
15
16# set the library to link against
17if(BUILD_STATIC_LIBS)
18	# drop -rdynamic
19	set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
20	set(_FIDO2_LIBRARY fido2)
21elseif(BUILD_SHARED_LIBS)
22	set(_FIDO2_LIBRARY fido2_shared)
23else()
24	set(_FIDO2_LIBRARY ${CRYPTO_LIBRARIES} fido2)
25endif()
26
27# enable -Wconversion -Wsign-conversion
28if(NOT MSVC)
29	set_source_files_properties(assert.c cred.c info.c manifest.c reset.c
30	    retries.c setpin.c util.c PROPERTIES COMPILE_FLAGS
31	    "-Wconversion -Wsign-conversion")
32endif()
33
34# manifest
35add_executable(manifest manifest.c ${COMPAT_SOURCES})
36target_link_libraries(manifest ${_FIDO2_LIBRARY})
37
38# info
39add_executable(info info.c ${COMPAT_SOURCES})
40target_link_libraries(info ${_FIDO2_LIBRARY})
41
42# reset
43add_executable(reset reset.c util.c ${COMPAT_SOURCES})
44target_link_libraries(reset ${_FIDO2_LIBRARY})
45
46# cred
47add_executable(cred cred.c util.c ${COMPAT_SOURCES})
48target_link_libraries(cred ${_FIDO2_LIBRARY})
49
50# assert
51add_executable(assert assert.c util.c ${COMPAT_SOURCES})
52target_link_libraries(assert ${_FIDO2_LIBRARY})
53
54# setpin
55add_executable(setpin setpin.c ${COMPAT_SOURCES})
56target_link_libraries(setpin ${_FIDO2_LIBRARY})
57
58# retries
59add_executable(retries retries.c ${COMPAT_SOURCES})
60target_link_libraries(retries ${_FIDO2_LIBRARY})
61
62# select
63add_executable(select select.c ${COMPAT_SOURCES})
64target_link_libraries(select ${_FIDO2_LIBRARY})
65
66if(MINGW)
67	# needed for nanosleep() in mingw
68	target_link_libraries(select winpthread)
69endif()
70