From 12a9ca19a7e51b3fc68ac3f0935348030d7c3098 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Fri, 20 Aug 2021 03:20:30 +0800 Subject: [PATCH] [cmake] avoid unnecessary rebuild when git commit id changes (#6881) This commit removes the PACKAGE_VERSION definition from the global config target so that when the git commit id is changed, only a few sources will be re-compiled. --- CMakeLists.txt | 1 - src/cli/CMakeLists.txt | 4 ++++ src/core/CMakeLists.txt | 4 ++++ src/ncp/CMakeLists.txt | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 119395785..540550e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,6 @@ if(OT_PACKAGE_VERSION STREQUAL "") ot_git_version(OT_PACKAGE_VERSION) message(STATUS "Setting default package version: ${OT_PACKAGE_VERSION}") endif() -target_compile_definitions(ot-config INTERFACE "PACKAGE_VERSION=\"${OT_PACKAGE_VERSION}\"") message(STATUS "Package Version: ${OT_PACKAGE_VERSION}") set(OT_THREAD_VERSION "1.2" CACHE STRING "Thread version chosen by the user at configure time") diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index aacef8e97..9cae98ab4 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -53,3 +53,7 @@ endif() if(OT_MTD) include(mtd.cmake) endif() + +set_property(SOURCE cli_joiner.cpp + APPEND PROPERTY COMPILE_DEFINITIONS "PACKAGE_VERSION=\"${OT_PACKAGE_VERSION}\"" +) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b6929fd18..60204d07f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -243,3 +243,7 @@ endif() if(OT_RCP) include(radio.cmake) endif() + +set_property(SOURCE api/instance_api.cpp + APPEND PROPERTY COMPILE_DEFINITIONS "PACKAGE_VERSION=\"${OT_PACKAGE_VERSION}\"" +) diff --git a/src/ncp/CMakeLists.txt b/src/ncp/CMakeLists.txt index 76bf8d3f0..84062470b 100644 --- a/src/ncp/CMakeLists.txt +++ b/src/ncp/CMakeLists.txt @@ -69,3 +69,7 @@ endif() if(OT_RCP) include(radio.cmake) endif() + +set_property(SOURCE ncp_base_mtd.cpp + APPEND PROPERTY COMPILE_DEFINITIONS "PACKAGE_VERSION=\"${OT_PACKAGE_VERSION}\"" +)