Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakeLists.txt: Handle Proxy configurations and existing built coap.h #1518

Merged
merged 1 commit into from
Sep 11, 2024
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
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,14 @@ else()
endif()

if(${ENABLE_PROXY_CODE})
set(COAP_PROXY_SUPPORT "1")
message(STATUS "compiling with proxy support")
if(${ENABLE_CLIENT_MODE} AND ${ENABLE_SERVER_MODE})
set(COAP_PROXY_SUPPORT "1")
message(STATUS "compiling with proxy support")
else()
message(
FATAL_ERROR
"Both ENABLE_CLIENT_MODE and ENABLE_SERVER_MODE need to be set for ENABLE_PROXY_CODE")
endif()
else()
message(STATUS "compiling without proxy support")
endif()
Expand Down Expand Up @@ -716,6 +722,15 @@ else(ENABLE_TCP)
set(COAP_DISABLE_TCP 1)
endif(ENABLE_TCP)

# Get rid of any previously built coap.h now that it is provided
if(NOT "${CMAKE_CURRENT_LIST_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/include/coap${LIBCOAP_API_VERSION}/coap.h)
message(
FATAL_ERROR
"${CMAKE_CURRENT_BINARY_DIR}/include/coap${LIBCOAP_API_VERSION}/coap.h exists and needs to be deleted")
endif()
endif()

# creates config header file in build directory
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_coap_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/coap_config.h)
Expand Down
7 changes: 7 additions & 0 deletions src/coap_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
#if COAP_PROXY_SUPPORT
#include <stdio.h>

#if COAP_CLIENT_SUPPORT == 0
#error For Proxy support, COAP_CLIENT_SUPPORT must be set
#endif
#if COAP_SERVER_SUPPORT == 0
#error For Proxy support, COAP_SERVER_SUPPORT must be set
#endif

#ifdef _WIN32
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
Expand Down