[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
This commit is contained in:
Yakun Xu
2020-05-07 08:46:13 +08:00
committed by GitHub
parent eb4125c97d
commit f7a4d05219
5 changed files with 29 additions and 15 deletions
+10 -4
View File
@@ -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()
+7 -5
View File
@@ -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 <openthread-users@googlegroups.com")
set(CPACK_PACKAGE_CONTACT "OpenThread Authors <openthread-users@googlegroups.com")
include(CPack)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-simulation")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors <openthread-users@googlegroups.com")
set(CPACK_PACKAGE_CONTACT "OpenThread Authors <openthread-users@googlegroups.com")
include(CPack)
endif()
+6 -4
View File
@@ -47,7 +47,9 @@ else()
include(standalone.cmake)
endif()
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors <openthread-users@googlegroups.com")
set(CPACK_PACKAGE_CONTACT "OpenThread Authors <openthread-users@googlegroups.com")
include(CPack)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors <openthread-users@googlegroups.com")
set(CPACK_PACKAGE_CONTACT "OpenThread Authors <openthread-users@googlegroups.com")
include(CPack)
endif()
+3 -1
View File
@@ -89,4 +89,6 @@ install(TARGETS ot-daemon
install(TARGETS ot-ctl
DESTINATION bin)
set(CPACK_PACKAGE_NAME "openthread-daemon")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-daemon")
endif()
+3 -1
View File
@@ -94,4 +94,6 @@ target_link_libraries(ot-ncp
install(TARGETS ot-cli ot-ncp
DESTINATION bin)
set(CPACK_PACKAGE_NAME "openthread-standalone")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-standalone")
endif()