baf4c69427d70d40c8f03dfe346b798a79fc6cbb
[vpp.git] / src / plugins / tlspicotls / CMakeLists.txt
1 include (CheckFunctionExists)
2
3 # We should rely on a picotls specific version, but as
4 # we expect dependancies to be built with vpp-ext-deps
5 # it's reasonable to make this check to avoid breaking
6 # existing builds when upgrading the quicly/picotls
7 # versions
8 set(EXPECTED_QUICLY_VERSION "0.1.3-vpp")
9
10
11 find_path(QUICLY_INCLUDE_DIR NAMES quicly.h)
12 find_path (PICOTLS_INCLUDE_DIR NAMES picotls.h)
13 find_library (PICOTLS_CORE_LIBRARY NAMES "libpicotls-core.a")
14 find_library (PICOTLS_OPENSSL_LIBRARY NAMES "libpicotls-openssl.a")
15
16 list (APPEND PICOTLS_LINK_LIBRARIES
17     ${PICOTLS_CORE_LIBRARY}
18     ${PICOTLS_OPENSSL_LIBRARY}
19 )
20
21 if(QUICLY_INCLUDE_DIR AND PICOTLS_INCLUDE_DIR AND PICOTLS_LINK_LIBRARIES)
22   if(EXISTS "${QUICLY_INCLUDE_DIR}/quicly/version.h")
23     file(STRINGS "${QUICLY_INCLUDE_DIR}/quicly/version.h" quicly_version_str REGEX "^#define[\t ]+LIBQUICLY_VERSION[\t ]+\".*\"")
24     string(REGEX REPLACE "^#define[\t ]+LIBQUICLY_VERSION[\t ]+\"([^\"]*)\".*" "\\1" QUICLY_VERSION_STRING "${quicly_version_str}")
25     unset(quicly_version_str)
26   endif()
27
28   if (${QUICLY_VERSION_STRING} MATCHES "${EXPECTED_QUICLY_VERSION}")
29     include_directories (${PICOTLS_INCLUDE_DIR})
30     add_vpp_plugin(tlspicotls
31         SOURCES
32         tls_picotls.c
33         pico_vpp_crypto.c
34         certs.c
35
36         LINK_LIBRARIES ${PICOTLS_LINK_LIBRARIES}
37     )
38     message (STATUS "Found picotls in ${PICOTLS_INCLUDE_DIR} and ${PICOTLS_CORE_LIBRARY}")
39   else()
40     message(STATUS "-- quicly ${EXPECTED_QUICLY_VERSION} not found - tlspicotls plugin disabled")
41   endif()
42 else ()
43     message (WARNING "-- picotls not found - tlspicotls plugin disabled")
44 endif ()