Skip to content

Commit

Permalink
CMakeLists.txt: Handle Proxy configurations and existing built coap.h
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Sep 11, 2024
1 parent da539d8 commit e234aca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
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

0 comments on commit e234aca

Please sign in to comment.