1cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
2
3# Set up the project
4project(netxduo
5    LANGUAGES C ASM
6)
7
8option(NXD_ENABLE_FILE_SERVERS "Includes a dependency on FileX to support 'server' protocol handlers" ON)
9option(NXD_ENABLE_AZURE_IOT "Enable Azure IoT" OFF)
10option(NX_AZURE_DISABLE_IOT_SECURITY_MODULE "Disable Azure IoT Security Module" OFF)
11
12if(NOT DEFINED THREADX_ARCH)
13    message(FATAL_ERROR "Error: THREADX_ARCH not defined")
14endif()
15if(NOT DEFINED THREADX_TOOLCHAIN)
16    message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined")
17endif()
18
19# Define our target library and an alias for consumers
20add_library(${PROJECT_NAME})
21add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME})
22
23# Define any required dependencies between this library and others
24target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::threadx")
25
26if(NXD_ENABLE_FILE_SERVERS)
27    message(STATUS "NXD_ENABLE_FILE_SERVERS - defined")
28    target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::filex")
29endif()
30
31if(NXD_ENABLE_AZURE_IOT)
32    message(STATUS "NXD_ENABLE_AZURE_IOT - defined")
33    target_link_libraries(${PROJECT_NAME} PUBLIC az_iot_hub az_iot_provisioning)
34    if(NOT NX_AZURE_DISABLE_IOT_SECURITY_MODULE)
35        target_link_libraries(${PROJECT_NAME} PUBLIC iot_security_module)
36    endif()
37endif()
38
39# A place for generated/copied include files (no need to change)
40set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
41
42# Pick up the port specific stuff first
43if(DEFINED NETXDUO_CUSTOM_PORT)
44    add_subdirectory(${NETXDUO_CUSTOM_PORT} netxduo_port)
45else()
46    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN})
47endif()
48
49# Then the common files
50add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common)
51
52# Pick up the apps directory containing the protocol and app-layer components
53add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/addons)
54
55# Network security and crypto components
56add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/crypto_libraries)
57add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/nx_secure)
58
59# Utility components
60add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/utility)
61
62# If the user provided an override, copy it to the custom directory
63if (NOT NX_USER_FILE)
64    message(STATUS "Using default nx_user.h file")
65    set(NX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/nx_user_sample.h)
66else()
67    message(STATUS "Using custom nx_user.h file from ${NX_USER_FILE}")
68endif()
69configure_file(${NX_USER_FILE} ${CUSTOM_INC_DIR}/nx_user.h COPYONLY)
70target_include_directories(${PROJECT_NAME}
71    PUBLIC
72    ${CUSTOM_INC_DIR}
73)
74target_compile_definitions(${PROJECT_NAME} PUBLIC "NX_INCLUDE_USER_DEFINE_FILE" )
75
76# Enable a build target that produces a ZIP file of all sources
77set(CPACK_SOURCE_GENERATOR "ZIP")
78set(CPACK_SOURCE_IGNORE_FILES
79  \\.git/
80  \\.github/
81  _build/
82  \\.git
83  \\.gitattributes
84  \\.gitignore
85  ".*~$"
86)
87set(CPACK_VERBATIM_VARIABLES YES)
88include(CPack)