Skip to content
Open
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
53 changes: 39 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ endif()

option(NXD_ENABLE_FILE_SERVERS "Includes a dependency on FileX to support 'server' protocol handlers" ON)
option(NXD_ENABLE_AZURE_IOT "Enable Azure IoT" OFF)
option(NXD_ENABLE_ADDONS "Build NetX Duo add-on modules" ON)
option(NXD_ENABLE_NX_SECURE "Build NetX Secure when packet chaining is enabled" ON)
option(NXD_DISABLE_PACKET_CHAIN "Build without packet chaining" OFF)

set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
if(NOT NX_USER_FILE)
message(STATUS "Using default nx_user.h file")
set(NX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/nx_user_sample.h)
else()
message(STATUS "Using custom nx_user.h file from ${NX_USER_FILE}")
endif()
configure_file(${NX_USER_FILE} ${CUSTOM_INC_DIR}/nx_user.h COPYONLY)

include(CheckCSourceCompiles)
set(NXD_SAVED_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${CUSTOM_INC_DIR})
unset(NXD_USER_DISABLE_PACKET_CHAIN CACHE)
check_c_source_compiles("#include \"nx_user.h\"
#ifndef NX_DISABLE_PACKET_CHAIN
#error Packet chaining is enabled
#endif
int main(void) { return 0; }" NXD_USER_DISABLE_PACKET_CHAIN)
set(CMAKE_REQUIRED_INCLUDES ${NXD_SAVED_REQUIRED_INCLUDES})

if(NXD_DISABLE_PACKET_CHAIN OR NXD_USER_DISABLE_PACKET_CHAIN)
set(NXD_NO_PACKET_CHAIN ON)
endif()

if(NOT DEFINED THREADX_ARCH)
message(FATAL_ERROR "Error: THREADX_ARCH not defined")
Expand All @@ -26,22 +53,26 @@ endif()
add_library(${PROJECT_NAME})
add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME})

if(NXD_NO_PACKET_CHAIN)
target_compile_definitions(${PROJECT_NAME} PUBLIC NX_DISABLE_FRAGMENTATION)
if(NXD_DISABLE_PACKET_CHAIN AND NOT NXD_USER_DISABLE_PACKET_CHAIN)
target_compile_definitions(${PROJECT_NAME} PUBLIC NX_DISABLE_PACKET_CHAIN)
endif()
endif()

# Define any required dependencies between this library and others
target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::threadx")

if(NXD_ENABLE_FILE_SERVERS)
if(NXD_ENABLE_ADDONS AND NXD_ENABLE_FILE_SERVERS)
message(STATUS "NXD_ENABLE_FILE_SERVERS - defined")
target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::filex")
endif()

if(NXD_ENABLE_AZURE_IOT)
if(NXD_ENABLE_ADDONS AND NXD_ENABLE_AZURE_IOT)
message(STATUS "NXD_ENABLE_AZURE_IOT - defined")
target_link_libraries(${PROJECT_NAME} PUBLIC az_iot_hub az_iot_provisioning)
endif()

# A place for generated/copied include files (no need to change)
set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)

# Pick up the port specific stuff first
if(DEFINED NETXDUO_CUSTOM_PORT)
add_subdirectory(${NETXDUO_CUSTOM_PORT} netxduo_port)
Expand All @@ -53,7 +84,9 @@ endif()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common)

# Pick up the apps directory containing the protocol and app-layer components
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/addons)
if(NXD_ENABLE_ADDONS)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/addons)
endif()

# Network security and crypto components
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/crypto_libraries)
Expand All @@ -65,14 +98,6 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/utility)
# Link layer
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tsn)

# If the user provided an override, copy it to the custom directory
if (NOT NX_USER_FILE)
message(STATUS "Using default nx_user.h file")
set(NX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/nx_user_sample.h)
else()
message(STATUS "Using custom nx_user.h file from ${NX_USER_FILE}")
endif()
configure_file(${NX_USER_FILE} ${CUSTOM_INC_DIR}/nx_user.h COPYONLY)
target_include_directories(${PROJECT_NAME}
PUBLIC
${CUSTOM_INC_DIR}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Instruction for building the NetX Duo as static library using Arm GNU Toolchain
$ cmake --build ./build
```

Defining `NX_DISABLE_PACKET_CHAIN` in `nx_user.h` makes CMake omit MQTT, WebSocket, RTP, and NetX Secure, which require packet chaining. CMake also disables IP fragmentation. Set `NXD_DISABLE_PACKET_CHAIN=ON` to select the same configuration without editing `nx_user.h`. Set `NXD_ENABLE_ADDONS=OFF` to omit all add-ons, or `NXD_ENABLE_NX_SECURE=OFF` to omit NetX Secure independently.

## Licensing

License terms for using Eclipse ThreadX are defined in the LICENSE.txt file of this repo. Please refer to this file for all definitive licensing information for all content, incl. the history of this repo.
Expand Down
8 changes: 8 additions & 0 deletions addons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ if(NOT NXD_ENABLE_FILE_SERVERS)
)
endif()

if(NXD_NO_PACKET_CHAIN)
list(REMOVE_ITEM SOURCES
"${CMAKE_CURRENT_LIST_DIR}/mqtt/nxd_mqtt_client.c"
"${CMAKE_CURRENT_LIST_DIR}/websocket/nx_websocket_client.c"
"${CMAKE_CURRENT_LIST_DIR}/rtp/nx_rtp_sender.c"
)
endif()

target_sources(${PROJECT_NAME} PRIVATE ${SOURCES})

target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down
2 changes: 2 additions & 0 deletions nx_secure/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if(NXD_ENABLE_NX_SECURE AND NOT NXD_NO_PACKET_CHAIN)
target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
Expand Down Expand Up @@ -309,6 +310,7 @@ target_sources(${PROJECT_NAME}

# {{END_TARGET_SOURCES}}
)
endif()

target_include_directories(${PROJECT_NAME}
PUBLIC
Expand Down
8 changes: 5 additions & 3 deletions test/cmake/netxduo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,15 @@ if(MSVC)
add_subdirectory(${FILEX_SOURCE_DIR} filex_build)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "v4_no_chain_build" OR
CMAKE_BUILD_TYPE STREQUAL "v6_no_chain_build")
set(NXD_DISABLE_PACKET_CHAIN ON)
endif()

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../.. ${PRODUCT})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/regression regression)
if(NOT MSVC AND NOT "$ENV{ENABLE_64}")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/samples samples)
if(PRODUCT STREQUAL netxduo)
include(additionals.cmake)
endif()
endif()

# Coverage instrumentation (GCC/Clang only — not supported by MSVC)
Expand Down
22 changes: 0 additions & 22 deletions test/cmake/netxduo/additionals.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions utility/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Each protocol handler is listed below. If you want
# to disable some / all of these, comment out the block(s) in question

if(NXD_ENABLE_FILE_SERVERS)
if(NXD_ENABLE_FILE_SERVERS AND NXD_ENABLE_ADDONS)
target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
Expand All @@ -13,4 +13,4 @@ if(NXD_ENABLE_FILE_SERVERS)
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/iperf
)
endif()
endif()
Loading