[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:
Ciaran Woodward
2019-11-26 00:53:35 +08:00
committed by Jonathan Hui
parent 6cfa2f9bec
commit 6a00ea0cdb
5 changed files with 19 additions and 13 deletions
+7 -5
View File
@@ -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()
+2
View File
@@ -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}
+4 -4
View File
@@ -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")
+2
View File
@@ -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}
+4 -4
View File
@@ -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")