xref: /freebsd/contrib/libfido2/fuzz/CMakeLists.txt (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1# Copyright (c) 2019-2023 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
6list(APPEND COMPAT_SOURCES
7	../openbsd-compat/strlcpy.c
8	../openbsd-compat/strlcat.c
9)
10
11list(APPEND COMMON_SOURCES
12	libfuzzer.c
13	mutator_aux.c
14)
15
16# XXX: OSS-Fuzz require linking using CXX
17set(FUZZ_LINKER_LANGUAGE "C" CACHE STRING "Linker language for fuzz harnesses")
18mark_as_advanced(FUZZ_LINKER_LANGUAGE)
19enable_language(${FUZZ_LINKER_LANGUAGE})
20
21# fuzz_cred
22add_executable(fuzz_cred fuzz_cred.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
23set_target_properties(fuzz_cred PROPERTIES
24	LINK_FLAGS ${FUZZ_LDFLAGS}
25	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
26target_link_libraries(fuzz_cred fido2_shared)
27
28# fuzz_assert
29add_executable(fuzz_assert fuzz_assert.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
30set_target_properties(fuzz_assert PROPERTIES
31	LINK_FLAGS ${FUZZ_LDFLAGS}
32	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
33target_link_libraries(fuzz_assert fido2_shared)
34
35# fuzz_mgmt
36add_executable(fuzz_mgmt fuzz_mgmt.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
37set_target_properties(fuzz_mgmt PROPERTIES
38	LINK_FLAGS ${FUZZ_LDFLAGS}
39	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
40target_link_libraries(fuzz_mgmt fido2_shared)
41
42# fuzz_credman
43add_executable(fuzz_credman fuzz_credman.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
44set_target_properties(fuzz_credman PROPERTIES
45	LINK_FLAGS ${FUZZ_LDFLAGS}
46	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
47target_link_libraries(fuzz_credman fido2_shared)
48
49# fuzz_bio
50add_executable(fuzz_bio fuzz_bio.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
51set_target_properties(fuzz_bio PROPERTIES
52	LINK_FLAGS ${FUZZ_LDFLAGS}
53	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
54target_link_libraries(fuzz_bio fido2_shared)
55
56# fuzz_hid
57add_executable(fuzz_hid fuzz_hid.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
58set_target_properties(fuzz_hid PROPERTIES
59	LINK_FLAGS ${FUZZ_LDFLAGS}
60	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
61target_link_libraries(fuzz_hid fido2_shared)
62
63# fuzz_netlink
64add_executable(fuzz_netlink fuzz_netlink.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
65set_target_properties(fuzz_netlink PROPERTIES
66	LINK_FLAGS ${FUZZ_LDFLAGS}
67	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
68target_link_libraries(fuzz_netlink fido2_shared)
69
70# fuzz_largeblob
71add_executable(fuzz_largeblob fuzz_largeblob.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
72set_target_properties(fuzz_largeblob PROPERTIES
73	LINK_FLAGS ${FUZZ_LDFLAGS}
74	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
75target_link_libraries(fuzz_largeblob fido2_shared)
76
77# fuzz_pcsc
78add_executable(fuzz_pcsc fuzz_pcsc.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
79set_target_properties(fuzz_pcsc PROPERTIES
80	LINK_FLAGS ${FUZZ_LDFLAGS}
81	LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
82target_link_libraries(fuzz_pcsc fido2_shared)
83