From d1981e04ae7e13f4a998483411542af32b129bff Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 28 Oct 2020 00:00:02 +0800 Subject: [PATCH] [cmake] no target_link_options in cmake 3.10 (#5706) --- examples/platforms/cc1352/CMakeLists.txt | 8 ++------ examples/platforms/cc2538/CMakeLists.txt | 10 +++++++--- examples/platforms/cc2650/CMakeLists.txt | 11 +++-------- examples/platforms/cc2652/CMakeLists.txt | 6 +----- examples/platforms/kw41z/CMakeLists.txt | 11 ++++++++--- examples/platforms/qpg6095/CMakeLists.txt | 3 --- examples/platforms/samr21/CMakeLists.txt | 8 ++------ script/check-arm-build-cmake | 22 +++++++++++++++------- script/cmake-build | 2 +- third_party/microchip/CMakeLists.txt | 6 +++--- third_party/ti/CMakeLists.txt | 8 -------- 11 files changed, 42 insertions(+), 53 deletions(-) diff --git a/examples/platforms/cc1352/CMakeLists.txt b/examples/platforms/cc1352/CMakeLists.txt index 6ab6c1364..9cbf5de6e 100644 --- a/examples/platforms/cc1352/CMakeLists.txt +++ b/examples/platforms/cc1352/CMakeLists.txt @@ -74,17 +74,13 @@ set_target_properties( target_link_libraries(openthread-cc1352 PUBLIC cc13x2-cc26x2-driver + -Wl,--gc-sections + -Wl,-Map=$.map PRIVATE ${OT_MBEDTLS} ot-config ) -target_link_options(openthread-cc1352 - PUBLIC - -Wl,--gc-sections - -Wl,-Map=$.map -) - target_compile_definitions(openthread-cc1352 PUBLIC ${OT_PLATFORM_DEFINES} diff --git a/examples/platforms/cc2538/CMakeLists.txt b/examples/platforms/cc2538/CMakeLists.txt index f33848a8d..341c5f134 100644 --- a/examples/platforms/cc2538/CMakeLists.txt +++ b/examples/platforms/cc2538/CMakeLists.txt @@ -62,9 +62,13 @@ set_target_properties( CXX_STANDARD 11 ) -target_link_libraries(openthread-cc2538 PRIVATE openthread-platform-utils ot-config) -target_link_options(openthread-cc2538 PUBLIC -T${PROJECT_SOURCE_DIR}/examples/platforms/cc2538/cc2538.ld) -target_link_options(openthread-cc2538 PUBLIC -Wl,--gc-sections -Wl,-Map=$.map) +target_link_libraries(openthread-cc2538 + PRIVATE + ot-config + PUBLIC + -T${PROJECT_SOURCE_DIR}/examples/platforms/cc2538/cc2538.ld + -Wl,--gc-sections -Wl,-Map=$.map +) target_compile_definitions(openthread-cc2538 PUBLIC diff --git a/examples/platforms/cc2650/CMakeLists.txt b/examples/platforms/cc2650/CMakeLists.txt index 84d7cf063..685e5b0ae 100644 --- a/examples/platforms/cc2650/CMakeLists.txt +++ b/examples/platforms/cc2650/CMakeLists.txt @@ -74,16 +74,11 @@ set_target_properties( target_link_libraries(openthread-cc2650 PUBLIC cc26x0-driver - PRIVATE - ${OT_MBEDTLS} - openthread-platform-utils - ot-config -) - -target_link_options(openthread-cc2650 - PUBLIC -Wl,--gc-sections -Wl,-Map=$.map + PRIVATE + ${OT_MBEDTLS} + ot-config ) target_compile_definitions(openthread-cc2650 diff --git a/examples/platforms/cc2652/CMakeLists.txt b/examples/platforms/cc2652/CMakeLists.txt index ddd4e24cf..d40f49c95 100644 --- a/examples/platforms/cc2652/CMakeLists.txt +++ b/examples/platforms/cc2652/CMakeLists.txt @@ -74,16 +74,12 @@ set_target_properties( target_link_libraries(openthread-cc2652 PUBLIC cc13x2-cc26x2-driver + -Wl,--gc-sections PRIVATE ${OT_MBEDTLS} ot-config ) -target_link_options(openthread-cc2652 - PUBLIC - -Wl,--gc-sections -) - target_compile_definitions(openthread-cc2652 PUBLIC ${OT_PLATFORM_DEFINES} diff --git a/examples/platforms/kw41z/CMakeLists.txt b/examples/platforms/kw41z/CMakeLists.txt index d76e8836a..12fb1c5fe 100644 --- a/examples/platforms/kw41z/CMakeLists.txt +++ b/examples/platforms/kw41z/CMakeLists.txt @@ -59,9 +59,14 @@ set_target_properties( CXX_STANDARD 11 ) -target_link_libraries(openthread-kw41z PRIVATE nxp-kw41z-driver ot-config) -target_link_options(openthread-kw41z PRIVATE -T${PROJECT_SOURCE_DIR}/examples/platforms/kw41z/MKW41Z512xxx4.ld) -target_link_options(openthread-kw41z PRIVATE -Wl,--gc-sections -Wl,-Map=$.map) +target_link_libraries(openthread-kw41z + PRIVATE + nxp-kw41z-driver + ot-config + PUBLIC + -T${PROJECT_SOURCE_DIR}/examples/platforms/kw41z/MKW41Z512xxx4.ld + -Wl,--gc-sections -Wl,-Map=$.map +) target_compile_definitions(openthread-kw41z PUBLIC diff --git a/examples/platforms/qpg6095/CMakeLists.txt b/examples/platforms/qpg6095/CMakeLists.txt index 2851208d6..b59202a25 100644 --- a/examples/platforms/qpg6095/CMakeLists.txt +++ b/examples/platforms/qpg6095/CMakeLists.txt @@ -79,9 +79,6 @@ target_link_libraries(openthread-qpg6095 qpg6095-driver ${OT_MBEDTLS} ot-config -) - -target_link_options(openthread-qpg6095 PUBLIC -T${CMAKE_CURRENT_SOURCE_DIR}/qpg6095.ld -Wl,--gc-sections diff --git a/examples/platforms/samr21/CMakeLists.txt b/examples/platforms/samr21/CMakeLists.txt index 48db69fa7..041c164c3 100644 --- a/examples/platforms/samr21/CMakeLists.txt +++ b/examples/platforms/samr21/CMakeLists.txt @@ -74,17 +74,13 @@ endif() target_link_libraries(openthread-samr21 PUBLIC samr21-driver + -Wl,--gc-sections + -Wl,-Map=$.map PRIVATE ${OT_MBEDTLS} ot-config ) -target_link_options(openthread-samr21 - PUBLIC - -Wl,--gc-sections - -Wl,-Map=$.map -) - target_compile_definitions(openthread-samr21 PUBLIC ${OT_PLATFORM_DEFINES} diff --git a/script/check-arm-build-cmake b/script/check-arm-build-cmake index 3c924fec7..0421e7721 100755 --- a/script/check-arm-build-cmake +++ b/script/check-arm-build-cmake @@ -98,13 +98,21 @@ build_samr21() main() { - build_cc1352 - build_cc2538 - build_cc2650 - build_cc2652 - build_kw41z - build_qpg6095 - build_samr21 + if [[ $# == 0 ]]; then + build_cc1352 + build_cc2538 + build_cc2650 + build_cc2652 + build_kw41z + build_qpg6095 + build_samr21 + return 0 + fi + + while [[ $# != 0 ]]; do + "build_$1" + shift + done } main "$@" diff --git a/script/cmake-build b/script/cmake-build index 20bc9fd91..2a500897e 100755 --- a/script/cmake-build +++ b/script/cmake-build @@ -154,7 +154,7 @@ main() OT_CMAKE_NINJA_TARGET=("ot-cli-mtd" "ot-ncp-mtd") options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel") ;; - cc1352 | cc2538 | cc2652 | qpg6095 | samr21) + cc1352 | cc2538 | cc2652 | kw41z | qpg6095 | samr21) options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel") ;; *) diff --git a/third_party/microchip/CMakeLists.txt b/third_party/microchip/CMakeLists.txt index 609184882..49d1d20a0 100644 --- a/third_party/microchip/CMakeLists.txt +++ b/third_party/microchip/CMakeLists.txt @@ -55,13 +55,13 @@ if(OT_CFLAGS MATCHES "-pedantic-errors") string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}") endif() -target_link_options(samr21-driver +target_link_libraries(samr21-driver PUBLIC -T${PROJECT_SOURCE_DIR}/third_party/microchip/include/samr21x18a.ld + PRIVATE + ot-config ) -target_link_libraries(samr21-driver PRIVATE ot-config) - target_compile_definitions(samr21-driver PUBLIC ${OT_PLATFORM_DEFINES} diff --git a/third_party/ti/CMakeLists.txt b/third_party/ti/CMakeLists.txt index b53b07198..6e74cac5b 100644 --- a/third_party/ti/CMakeLists.txt +++ b/third_party/ti/CMakeLists.txt @@ -32,10 +32,6 @@ if(OT_PLATFORM STREQUAL "cc2650") target_link_libraries(cc26x0-driver INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/devices/cc26x0/driverlib/bin/gcc/driverlib.a - ) - - target_link_options(cc26x0-driver - INTERFACE -T${CMAKE_CURRENT_SOURCE_DIR}/devices/cc26x0/linker_files/cc26x0f128.lds ) elseif(OT_PLATFORM STREQUAL "cc1352" OR OT_PLATFORM STREQUAL "cc2652") @@ -44,10 +40,6 @@ elseif(OT_PLATFORM STREQUAL "cc1352" OR OT_PLATFORM STREQUAL "cc2652") target_link_libraries(cc13x2-cc26x2-driver INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/devices/cc13x2_cc26x2/driverlib/bin/gcc/driverlib.a - ) - - target_link_options(cc13x2-cc26x2-driver - INTERFACE -T${CMAKE_CURRENT_SOURCE_DIR}/devices/cc13x2_cc26x2/linker_files/cc26x2r1f.lds ) endif()