mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 10:47:46 +00:00
[cmake] add OT_CONFIG to specify project core config header file (#4374)
This commit adds new parameter `OT_CONFIG` to main `CMakeLists.txt` file. This parameter allows users to specify a project-specific core config header file (mapped to `OPENTHREAD_PROJECT_CORE_CONFIG_FILE`) during build configuration. The default value for this parameter is "none". When not specified (value is "none"), a platform cmake file may choose to change `OT_COFNIG` variable to provide its own core config header file. This commit updates platform 'posix' and 'cc2548' cmake files to provide platform specific header files when `OT_CONFIG` is not specified by user.
This commit is contained in:
committed by
Jonathan Hui
parent
6c159e7de2
commit
c75533fd15
@@ -59,6 +59,14 @@ if(NOT OT_PLATFORM IN_LIST OT_EXAMPLE_PLATFORMS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# OT_CONFIG allows users to specify the path to OpenThread project core
|
||||
# config header file. The default value of this parameter is empty string.
|
||||
# When not specified by user (value is ""), a platform cmake file may
|
||||
# choose to change this variable to provide its own core config header
|
||||
# file instead.
|
||||
|
||||
set(OT_CONFIG "" CACHE STRING "OpenThread project-specific config header file chosen by user at configure time")
|
||||
|
||||
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_BINARY_DIR}/etc/cmake)
|
||||
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/etc/cmake)
|
||||
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include)
|
||||
@@ -71,6 +79,11 @@ elseif(NOT OT_PLATFORM MATCHES "none")
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}")
|
||||
endif()
|
||||
|
||||
if(OT_CONFIG)
|
||||
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
|
||||
message(STATUS "Project core config: \"${OT_CONFIG}\"")
|
||||
endif()
|
||||
|
||||
list(APPEND OT_PRIVATE_DEFINES ${OT_PLATFORM_DEFINES})
|
||||
|
||||
if(OT_BUILTIN_MBEDTLS)
|
||||
|
||||
@@ -28,13 +28,19 @@
|
||||
|
||||
set(OT_PLATFORM_LIB "openthread-cc2538" PARENT_SCOPE)
|
||||
|
||||
if(NOT OT_CONFIG)
|
||||
set(OT_CONFIG "openthread-core-cc2538-config.h")
|
||||
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES
|
||||
"OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-cc2538-config.h\""
|
||||
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-cc2538-config-check.h\""
|
||||
"OPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
|
||||
)
|
||||
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
|
||||
|
||||
add_library(openthread-cc2538
|
||||
alarm.c
|
||||
diag.c
|
||||
|
||||
@@ -28,14 +28,20 @@
|
||||
|
||||
set(OT_PLATFORM_LIB "openthread-posix" PARENT_SCOPE)
|
||||
|
||||
if(NOT OT_CONFIG)
|
||||
set(OT_CONFIG "openthread-core-posix-config.h")
|
||||
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES
|
||||
"OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\""
|
||||
"OPENTHREAD_EXAMPLES_POSIX=1"
|
||||
"OPENTHREAD_POSIX=1"
|
||||
"OPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
|
||||
)
|
||||
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
|
||||
|
||||
add_library(openthread-posix
|
||||
alarm.c
|
||||
diag.c
|
||||
|
||||
Reference in New Issue
Block a user