Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(LIBCOAP_API_VERSION 3)
set(LIBCOAP_ABI_VERSION 3.2.2)

set(COAP_LIBRARY_NAME "coap-${LIBCOAP_API_VERSION}")
set(LIBCOAP_NAME_SUFFIX "${LIBCOAP_API_VERSION}")

if(NOT ZEPHYR_BASE)
option(
Expand Down Expand Up @@ -80,9 +81,13 @@ if(ENABLE_SANITIZER)
if(MSVC)
add_compile_options(/fsanitize=address,undefined)
add_link_options(/fsanitize=address,undefined)
set(SAN_CFLAGS "/fsanitize=address,undefined")
set(SAN_LIBS "/fsanitize=address,undefined")
else()
add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer -fsanitize-address-use-after-scope)
add_link_options(-fsanitize=address,undefined)
set(SAN_CFLAGS "-fsanitize=address,undefined -fno-omit-frame-pointer -fsanitize-address-use-after-scope")
set(SAN_LIBS "-fsanitize=address,undefined")
endif()
message(STATUS "AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan) enabled")
endif()
Expand Down Expand Up @@ -559,6 +564,7 @@ if(ENABLE_DTLS)
message(STATUS "compiling with gnutls support")
set(COAP_WITH_LIBGNUTLS 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${GNUTLS_LIBRARIES})
endif()
endif()

Expand All @@ -570,6 +576,7 @@ if(ENABLE_DTLS)
message(STATUS "compiling with openssl support")
set(COAP_WITH_LIBOPENSSL 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${OPENSSL_LIBRARIES})
endif()
endif()

Expand All @@ -581,6 +588,7 @@ if(ENABLE_DTLS)
message(STATUS "compiling with wolfssl support")
set(COAP_WITH_LIBWOLFSSL 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${WOLFSSL_LIBRARIES})
endif()
endif()

Expand All @@ -592,6 +600,7 @@ if(ENABLE_DTLS)
message(STATUS "compiling with mbedtls support")
set(COAP_WITH_LIBMBEDTLS 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${MBEDTLS_LIBRARIES})
endif()
endif()

Expand All @@ -617,6 +626,7 @@ if(ENABLE_DTLS)
message(STATUS "compiling with tinydtls support")
set(COAP_WITH_LIBTINYDTLS 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${TINYDTLS_LIBRARIES})
endif()
endif()

Expand All @@ -628,6 +638,7 @@ if(ENABLE_DTLS)
message(STATUS "compiling with openHiTLS support")
set(COAP_WITH_LIBOPENHITLS 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${OPENHITLS_LIBRARIES})
endif()
endif()

Expand All @@ -651,6 +662,7 @@ elseif(NOT ((OSCORE_BACKEND STREQUAL "none") OR (OSCORE_BACKEND STREQUAL "")))
message(STATUS "compiling with mbedtls OSCORE support")
set(COAP_WITH_LIBMBEDTLS_OSCORE 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${MBEDTLS_LIBRARIES})
endif()
endif()

Expand All @@ -662,6 +674,7 @@ elseif(NOT ((OSCORE_BACKEND STREQUAL "none") OR (OSCORE_BACKEND STREQUAL "")))
message(STATUS "compiling with openHiTLS OSCORE support")
set(COAP_WITH_LIBOPENHITLS_OSCORE 1)
set(DTLS_FOUND ON)
set(T_DTLS_LIBS ${OPENHITLS_LIBRARIES})
endif()
endif()

Expand Down Expand Up @@ -792,6 +805,16 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_coap_config.h.in
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_coap_defines.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/coap${LIBCOAP_API_VERSION}/coap_defines.h)

# Build the libcoap-3.pc file
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib")
set(includedir "\${prefix}/include")
string(REPLACE ";" " " DTLS_LIBS "${T_DTLS_LIBS}")

configure_file(${CMAKE_CURRENT_LIST_DIR}/libcoap-3.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libcoap-3.pc @ONLY)

#
# sources
#
Expand Down Expand Up @@ -1056,15 +1079,22 @@ configure_package_config_file(
${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION
${LIBCOAP_CONFIG_INSTALL_DIR})

write_basic_package_version_file(
${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY SameMajorVersion)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${LIBCOAP_CONFIG_INSTALL_DIR}
COMPONENT dev)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libcoap-3.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT dev)

install(
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
Expand All @@ -1073,17 +1103,20 @@ install(
PATTERN "*.h"
PATTERN "*_internal.h" EXCLUDE
PATTERN "oscore*" EXCLUDE)

install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT dev
FILES_MATCHING
PATTERN "*.h")

if(ENABLE_EXAMPLES)
install(
TARGETS coap-server coap-client coap-rd
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT dev)

if(NOT WIN32 AND NOT MINGW)
install(
TARGETS etsi_iot_01 tiny oscore-interop-server
Expand Down
17 changes: 12 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,6 @@ if test "x$build_dtls" = "xyes"; then
DTLS_LIBS="$OpenHiTLS_LIBS"
AC_DEFINE(COAP_WITH_LIBOPENHITLS, [1], [Define to 1 if the system has openHiTLS.])
fi
AC_SUBST(DTLS_CFLAGS)
AC_SUBST(DTLS_LIBS)
else
# The user can't select multiple crypto libraries.
TLSCOUNT=0
Expand Down Expand Up @@ -893,6 +891,8 @@ else
fi

fi
AC_SUBST(DTLS_CFLAGS)
AC_SUBST(DTLS_LIBS)

# Define the Library name extension for the TLS the library was linked against
if test "x$with_openssl" = "xyes" -o "x$with_openssl_auto" = "xyes"; then
Expand Down Expand Up @@ -1023,12 +1023,19 @@ AC_ARG_ENABLE([sanitize],
[build_sanitize="$enableval"],
[build_sanitize="no"])

SAN_CFLAGS=
SAN_LIBS=
if test "x$build_sanitize" = "xyes"; then
AX_CHECK_COMPILE_FLAG([-fsanitize=address,undefined], [CFLAGS="$CFLAGS -fsanitize=address,undefined"])
AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], [CFLAGS="$CFLAGS -fno-omit-frame-pointer"])
AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"])
AX_CHECK_COMPILE_FLAG([-fsanitize=address,undefined], [SAN_CFLAGS="-fsanitize=address,undefined"])
SAN_LIBS="$SAN_CFLAGS"
AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], [SAN_CFLAGS="$SAN_CFLAGS -fno-omit-frame-pointer"])
AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [SAN_CFLAGS="$SAN_CFLAGS -fsanitize-address-use-after-scope"])
CFLAGS="$CFLAGS $SAN_CFLAGS"
fi

AC_SUBST(SAN_CFLAGS)
AC_SUBST(SAN_LIBS)

# configure options
# __license-install__
AC_ARG_ENABLE([license-install],
Expand Down
4 changes: 2 additions & 2 deletions libcoap-3.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Name: @PACKAGE_NAME@
Description: C-Implementation of CoAP.
Version: @PACKAGE_VERSION@
URL: @PACKAGE_URL@
Libs: -L${libdir} -lcoap-@LIBCOAP_NAME_SUFFIX@
Libs: -L${libdir} -lcoap-@LIBCOAP_NAME_SUFFIX@ @SAN_LIBS@
Libs.private: @DTLS_LIBS@
Cflags: -I${includedir}
Cflags: -I${includedir} @DTLS_CFLAGS@ @SAN_CFLAGS@
Loading