From dce84a77fbe49a17e94f71feb1b8e63dc8914a79 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 10 Jun 2020 07:14:10 +0800 Subject: [PATCH] [cmake] add posix in platform list (#5071) - rename "none" to NO, which computes to false in if() - sort platform names - add "posix" into the platform list so that it can be selected from cmake-gui --- CMakeLists.txt | 16 +++++++--------- etc/cmake/functions.cmake | 4 +++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4d6a65ab..2ccd5ac25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,13 +90,11 @@ else() message(FATAL_ERROR "Thread version unknown: ${OT_THREAD_VERSION}") endif() -set(OT_PLATFORM "none" CACHE STRING "Target platform chosen by the user at configure time") -ot_get_platforms(OT_EXAMPLE_PLATFORMS) -set_property(CACHE OT_PLATFORM PROPERTY STRINGS ${OT_EXAMPLE_PLATFORMS}) -if(NOT OT_PLATFORM IN_LIST OT_EXAMPLE_PLATFORMS) - if(NOT OT_PLATFORM STREQUAL "posix") - message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}") - endif() +set(OT_PLATFORM "NO" CACHE STRING "Target platform chosen by the user at configure time") +ot_get_platforms(OT_PLATFORMS) +set_property(CACHE OT_PLATFORM PROPERTY STRINGS ${OT_PLATFORMS}) +if(NOT OT_PLATFORM IN_LIST OT_PLATFORMS) + message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}") endif() set(OT_LOG_OUTPUT_VALUES @@ -135,7 +133,7 @@ list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include) if(OT_PLATFORM STREQUAL "posix") list(APPEND OT_PRIVATE_INCLUDES ${PROJECT_SOURCE_DIR}/src/posix/platform) add_subdirectory("${PROJECT_SOURCE_DIR}/src/posix/platform") -elseif(NOT OT_PLATFORM MATCHES "none") +elseif(OT_PLATFORM) list(APPEND OT_PRIVATE_INCLUDES ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}) add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}") endif() @@ -153,7 +151,7 @@ if(OT_PLATFORM STREQUAL "posix") else() add_subdirectory(src/posix EXCLUDE_FROM_ALL) endif() -elseif(NOT OT_PLATFORM MATCHES "none") +elseif(OT_PLATFORM) add_subdirectory(examples) endif() diff --git a/etc/cmake/functions.cmake b/etc/cmake/functions.cmake index 9caf9e82c..ffafe48ad 100755 --- a/etc/cmake/functions.cmake +++ b/etc/cmake/functions.cmake @@ -28,7 +28,7 @@ # Get a list of the available platforms and output as a list to the 'arg_platforms' argument function(ot_get_platforms arg_platforms) - set(result "none") + list(APPEND result "NO" "posix") set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms") file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*") foreach(platform IN LISTS platforms) @@ -37,5 +37,7 @@ function(ot_get_platforms arg_platforms) endif() endforeach() + list(REMOVE_ITEM result utils) + list(SORT result) set(${arg_platforms} "${result}" PARENT_SCOPE) endfunction()