mirror of
https://github.com/espressif/openthread.git
synced 2026-08-29 13:29:54 +00:00
[cmake] remove directory scoped add_definitions calls (#4112)
These won't work well if a parent project includes openthread as a subproject, and aren't as well abstracted as the target-based definitions.
This commit is contained in:
committed by
Jonathan Hui
parent
6cfa2f9bec
commit
6a00ea0cdb
+7
-5
@@ -43,9 +43,9 @@ execute_process(
|
||||
)
|
||||
set(OT_VERSION "${__version}")
|
||||
|
||||
add_definitions(
|
||||
-DPACKAGE_NAME="OPENTHREAD"
|
||||
-DPACKAGE_VERSION="${OT_VERSION}"
|
||||
list(APPEND OT_PRIVATE_DEFINES
|
||||
"PACKAGE_NAME=\"OPENTHREAD\""
|
||||
"PACKAGE_VERSION=\"${OT_VERSION}\""
|
||||
)
|
||||
|
||||
set(OT_PLATFORM "none" CACHE STRING "Target platform chosen by the user at configure time")
|
||||
@@ -77,12 +77,14 @@ if(NOT OT_PLATFORM MATCHES "none")
|
||||
include("${OT_ROOT_DIR}/examples/platforms/${OT_PLATFORM}/platform.cmake")
|
||||
endif()
|
||||
|
||||
list(APPEND OT_PRIVATE_DEFINES ${OT_PLATFORM_DEFINES})
|
||||
|
||||
if(OT_BUILTIN_MBEDTLS)
|
||||
list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/third_party/mbedtls)
|
||||
list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/third_party/mbedtls/repo/include)
|
||||
|
||||
add_definitions(
|
||||
-DMBEDTLS_CONFIG_FILE="mbedtls-config.h"
|
||||
list(APPEND OT_PRIVATE_DEFINES
|
||||
"MBEDTLS_CONFIG_FILE=\"mbedtls-config.h\""
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ add_library(openthread-cc2538
|
||||
|
||||
target_link_libraries(openthread-cc2538 PRIVATE openthread-platform-utils)
|
||||
|
||||
target_compile_definitions(openthread-cc2538 PUBLIC ${OT_PLATFORM_DEFINES})
|
||||
|
||||
target_include_directories(openthread-cc2538 PRIVATE
|
||||
${OT_PUBLIC_INCLUDES}
|
||||
${OT_PRIVATE_INCLUDES}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
add_definitions(
|
||||
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-cc2538-config.h"
|
||||
-DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE="openthread-core-cc2538-config-check.h"
|
||||
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
|
||||
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(common_c_flags "-mcpu=cortex-m3 -mfloat-abi=soft")
|
||||
|
||||
@@ -50,6 +50,8 @@ endif()
|
||||
|
||||
target_link_libraries(openthread-posix PRIVATE openthread-platform-utils)
|
||||
|
||||
target_compile_definitions(openthread-posix PUBLIC ${OT_PLATFORM_DEFINES})
|
||||
|
||||
target_include_directories(openthread-posix PRIVATE
|
||||
${OT_PUBLIC_INCLUDES}
|
||||
${OT_PRIVATE_INCLUDES}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
add_definitions(
|
||||
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-posix-config.h"
|
||||
-DOPENTHREAD_EXAMPLES_POSIX=1
|
||||
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
|
||||
list(APPEND OT_PLATFORM_DEFINES
|
||||
"OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\""
|
||||
"OPENTHREAD_EXAMPLES_POSIX=1"
|
||||
"OPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENTHREAD_POSIX=1")
|
||||
|
||||
Reference in New Issue
Block a user