diff --git a/CMakeLists.txt b/CMakeLists.txt index 00ffb1409..e81b3fb75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/examples/platforms/cc2538/CMakeLists.txt b/examples/platforms/cc2538/CMakeLists.txt index f74b6b10c..13ecedb0d 100644 --- a/examples/platforms/cc2538/CMakeLists.txt +++ b/examples/platforms/cc2538/CMakeLists.txt @@ -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 diff --git a/examples/platforms/posix/CMakeLists.txt b/examples/platforms/posix/CMakeLists.txt index 1de46f514..b4d7229e6 100644 --- a/examples/platforms/posix/CMakeLists.txt +++ b/examples/platforms/posix/CMakeLists.txt @@ -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