diff options
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..926e7f2 --- /dev/null +++ b/src/CMakeLists.txt | |||
@@ -0,0 +1,104 @@ | |||
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 | |||
5 | add_definitions(-D_FIDO_INTERNAL) | ||
6 | |||
7 | list(APPEND FIDO_SOURCES | ||
8 | aes256.c | ||
9 | assert.c | ||
10 | authkey.c | ||
11 | bio.c | ||
12 | blob.c | ||
13 | buf.c | ||
14 | cbor.c | ||
15 | cred.c | ||
16 | credman.c | ||
17 | dev.c | ||
18 | ecdh.c | ||
19 | eddsa.c | ||
20 | err.c | ||
21 | es256.c | ||
22 | hid.c | ||
23 | info.c | ||
24 | io.c | ||
25 | iso7816.c | ||
26 | log.c | ||
27 | pin.c | ||
28 | reset.c | ||
29 | rs256.c | ||
30 | u2f.c | ||
31 | ) | ||
32 | |||
33 | if(FUZZ) | ||
34 | list(APPEND FIDO_SOURCES ../fuzz/uniform_random.c) | ||
35 | list(APPEND FIDO_SOURCES ../fuzz/wrap.c) | ||
36 | endif() | ||
37 | |||
38 | if(WIN32) | ||
39 | list(APPEND COMPAT_SOURCES hid_win.c) | ||
40 | elseif(APPLE) | ||
41 | list(APPEND COMPAT_SOURCES hid_osx.c) | ||
42 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
43 | list(APPEND COMPAT_SOURCES hid_linux.c) | ||
44 | elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") | ||
45 | list(APPEND COMPAT_SOURCES hid_openbsd.c) | ||
46 | endif() | ||
47 | |||
48 | list(APPEND COMPAT_SOURCES | ||
49 | ../openbsd-compat/bsd-getpagesize.c | ||
50 | ../openbsd-compat/explicit_bzero.c | ||
51 | ../openbsd-compat/explicit_bzero_win32.c | ||
52 | ../openbsd-compat/recallocarray.c | ||
53 | ../openbsd-compat/timingsafe_bcmp.c | ||
54 | ) | ||
55 | |||
56 | # static library | ||
57 | add_library(fido2 STATIC ${FIDO_SOURCES} ${COMPAT_SOURCES}) | ||
58 | target_link_libraries(fido2 ${CBOR_LIBRARIES} ${CRYPTO_LIBRARIES} | ||
59 | ${UDEV_LIBRARIES} ${BASE_LIBRARIES}) | ||
60 | if(WIN32) | ||
61 | if (MINGW) | ||
62 | target_link_libraries(fido2 wsock32 ws2_32 bcrypt setupapi hid) | ||
63 | else() | ||
64 | target_link_libraries(fido2 wsock32 ws2_32 bcrypt SetupAPI hid) | ||
65 | set_target_properties(fido2 PROPERTIES OUTPUT_NAME fido2_static) | ||
66 | endif() | ||
67 | elseif(APPLE) | ||
68 | target_link_libraries(fido2 "-framework CoreFoundation" | ||
69 | "-framework IOKit") | ||
70 | endif() | ||
71 | install(TARGETS fido2 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
72 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
73 | |||
74 | # dynamic library | ||
75 | add_library(fido2_shared SHARED ${FIDO_SOURCES} ${COMPAT_SOURCES}) | ||
76 | target_link_libraries(fido2_shared ${CBOR_LIBRARIES} ${CRYPTO_LIBRARIES} | ||
77 | ${UDEV_LIBRARIES} ${BASE_LIBRARIES}) | ||
78 | if(WIN32) | ||
79 | if (MINGW) | ||
80 | target_link_libraries(fido2_shared wsock32 ws2_32 bcrypt | ||
81 | setupapi hid) | ||
82 | else() | ||
83 | target_link_libraries(fido2_shared wsock32 ws2_32 bcrypt | ||
84 | SetupAPI hid) | ||
85 | endif() | ||
86 | elseif(APPLE) | ||
87 | target_link_libraries(fido2_shared "-framework CoreFoundation" | ||
88 | "-framework IOKit") | ||
89 | endif() | ||
90 | set_target_properties(fido2_shared PROPERTIES OUTPUT_NAME fido2 | ||
91 | VERSION ${LIB_VERSION} SOVERSION ${LIB_SOVERSION}) | ||
92 | install(TARGETS fido2_shared | ||
93 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
94 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
95 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
96 | |||
97 | install(FILES fido.h DESTINATION include) | ||
98 | install(DIRECTORY fido DESTINATION include) | ||
99 | |||
100 | if(NOT WIN32) | ||
101 | configure_file(libfido2.pc.in libfido2.pc @ONLY) | ||
102 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libfido2.pc" | ||
103 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") | ||
104 | endif() | ||