diff --git a/cmake/deps/coap.cmake b/cmake/deps/coap.cmake index 04cb6bb88af..cb5ea9d853e 100644 --- a/cmake/deps/coap.cmake +++ b/cmake/deps/coap.cmake @@ -1,10 +1,13 @@ if(OSSIA_USE_SYSTEM_LIBRARIES) find_path(LIBCOAP_INCLUDEDIR coap3/libcoap.h) find_library(LIBCOAP_LIBRARIES coap-3) - add_library(coap-3 IMPORTED SHARED GLOBAL) - add_library(libcoap::coap-3 ALIAS coap-3) - target_include_directories(coap-3 INTERFACE "${LIBCOAP_INCLUDEDIR}") - set_target_properties(coap-3 PROPERTIES IMPORTED_LOCATION "${LIBCOAP_LIBRARIES}") + + if(LIBCOAP_INCLUDEDIR AND LIBCOAP_LIBRARIES) + add_library(coap-3 IMPORTED SHARED GLOBAL) + add_library(libcoap::coap-3 ALIAS coap-3) + target_include_directories(coap-3 INTERFACE "${LIBCOAP_INCLUDEDIR}") + set_target_properties(coap-3 PROPERTIES IMPORTED_LOCATION "${LIBCOAP_LIBRARIES}") + endif() endif() if(NOT TARGET libcoap::coap-3)