import libfido2 in a cmake project using FetchContent
ncoder-1 opened this issue · 1 comments
ncoder-1 commented
Hi,
What is the proper way to import libfido2
in a cmake project using FetchContent
? I've tried the following way:
include(FetchContent)
FetchContent_Declare(
fido2
GIT_REPOSITORY https://github.com/Yubico/libfido2.git
GIT_TAG 1.10.0
GIT_SHALLOW TRUE
)
set(BUILD_EXAMPLES OFF CACHE INTERNAL "Turn off examples")
set(BUILD_MANPAGES OFF CACHE INTERNAL "Turn off manpages")
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Turn off shared libs")
set(BUILD_TOOLS OFF CACHE INTERNAL "Turn off tools")
FetchContent_MakeAvailable(fido2)
add_executable(fido2-test main.cpp)
target_include_directories(fido2-test PRIVATE ${libfido2_SOURCE_DIR}/src)
target_link_libraries(fido2-test PRIVATE fido2)
Which will fetch it fine but will give the following error at build time:
/usr/bin/gcc -DHAVE_CBOR_H -DHAVE_CLOCK_GETTIME -DHAVE_DEV_URANDOM -DHAVE_ENDIAN_H -DHAVE_ERR_H -DHAVE_EXPLICIT_BZERO -DHAVE_GETLINE -DHAVE_GETOPT -DHAVE_GETPAGESIZE -DHAVE_GETRANDOM -DHAVE_OPENSSLV_H -DHAVE_SIGNAL_H -DHAVE_STRSEP -DHAVE_SYSCONF -DHAVE_SYS_RANDOM_H -DHAVE_UNISTD_H -DNFC_LINUX -DTLS=__thread -D_FIDO_INTERNAL -D_FIDO_MAJOR=1 -D_FIDO_MINOR=10 -D_FIDO_PATCH=0 -I/home/hmi1/dev/fido2-msg/src -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -D_GNU_SOURCE -D_DEFAULT_SOURCE -std=c99 -Wall -Wextra -pedantic -fsanitize=address -g -g2 -fno-omit-frame-pointer -fPIC -Wall -Wextra -Werror -Wshadow -Wcast-qual -Wwrite-strings -Wmissing-prototypes -Wbad-function-cast -pedantic -pedantic-errors -fstack-protector-all -Wno-unused-result -Wconversion -Wsign-conversion -MD -MT _deps/fido2-build/src/CMakeFiles/fido2.dir/blob.c.o -MF _deps/fido2-build/src/CMakeFiles/fido2.dir/blob.c.o.d -o _deps/fido2-build/src/CMakeFiles/fido2.dir/blob.c.o -c /home/hmi1/dev/fido2-msg/cmake-build-debug-linux-gcc/_deps/fido2-src/src/blob.c
In file included from /home/hmi1/dev/fido2-msg/cmake-build-debug-linux-gcc/_deps/fido2-src/src/extern.h:20,
from /home/hmi1/dev/fido2-msg/cmake-build-debug-linux-gcc/_deps/fido2-src/src/fido.h:26,
from /home/hmi1/dev/fido2-msg/cmake-build-debug-linux-gcc/_deps/fido2-src/src/blob.c:7:
/home/hmi1/dev/fido2-msg/cmake-build-debug-linux-gcc/_deps/fido2-src/src/fido/types.h:58:10: fatal error: packed.h: No such file or directory
58 | #include "packed.h"
| ^~~~~~~~~~
compilation terminated.
If I manually copy both packed.h
and blob.h
into the fido
directory it will build succesfully which tells me there's an issue with include_directories
but I can't change the fetched CMakeList.txt
file.
martelletto commented
Fixed in 3ab79a9. Thank you for the report!