From f7a4d052197eda9844c6a94eae81af88f7a7e381 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Thu, 7 May 2020 08:46:13 +0800 Subject: [PATCH] [cmake] add project version (#4929) * use an older version for better compatibility * add version to project * only use cpack when OpenThread is the top-level project * exclude posix apps when BUILD_EXECUTABLES is OFF * exclude all third_party --- CMakeLists.txt | 14 ++++++++++---- examples/platforms/simulation/CMakeLists.txt | 12 +++++++----- src/posix/CMakeLists.txt | 10 ++++++---- src/posix/daemon.cmake | 4 +++- src/posix/standalone.cmake | 4 +++- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b92a1bac..d304fc398 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,13 @@ # POSSIBILITY OF SUCH DAMAGE. # -cmake_minimum_required(VERSION 3.13.1) -project(openthread) +cmake_policy(SET CMP0048 NEW) +cmake_minimum_required(VERSION 3.11.4) + +file(READ .default-version OT_DEFAULT_VERSION) +string(STRIP ${OT_DEFAULT_VERSION} OT_DEFAULT_VERSION) + +project(openthread VERSION ${OT_DEFAULT_VERSION}) option(OT_BUILD_EXECUTABLES "Build executables" ON) option(OT_COVERAGE "enable coverage" OFF) @@ -61,7 +66,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang") ) endif() -file(READ .default-version OT_DEFAULT_VERSION) execute_process( COMMAND bash "-c" "third_party/nlbuild-autotools/repo/scripts/mkversion -b ${OT_DEFAULT_VERSION}" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -144,13 +148,15 @@ list(APPEND OT_PRIVATE_DEFINES ${OT_PLATFORM_DEFINES}) if(OT_PLATFORM STREQUAL "posix") if(OT_BUILD_EXECUTABLES) add_subdirectory(src/posix) + else() + add_subdirectory(src/posix EXCLUDE_FROM_ALL) endif() elseif(NOT OT_PLATFORM MATCHES "none") add_subdirectory(examples) endif() add_subdirectory(src) -add_subdirectory(third_party) +add_subdirectory(third_party EXCLUDE_FROM_ALL) if(OT_PLATFORM STREQUAL "simulation") enable_testing() diff --git a/examples/platforms/simulation/CMakeLists.txt b/examples/platforms/simulation/CMakeLists.txt index 1fe76dde3..01d306ba6 100644 --- a/examples/platforms/simulation/CMakeLists.txt +++ b/examples/platforms/simulation/CMakeLists.txt @@ -98,8 +98,10 @@ target_include_directories(openthread-simulation PRIVATE ${PROJECT_SOURCE_DIR}/src/core ) -set(CPACK_PACKAGE_NAME "openthread-simulation") -set(CPACK_GENERATOR "DEB") -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors