From 07fce00de25e30ccce92d7922bce8eb110a2afe5 Mon Sep 17 00:00:00 2001 From: ohh Date: Tue, 16 Jun 2026 12:03:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=89=88=E6=9C=AC=E5=8F=B7=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=BB=A5=20CMake=20project(VERSION)=20=E4=B8=BA?= =?UTF-8?q?=E5=94=AF=E4=B8=80=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main.cpp 原先硬编码 VERSION = "0.0.2",与 release tag 脱钩,导致发布 v0.0.x 的二进制 --version 仍可能自报旧版本。改由 cli/CMakeLists.txt 用 target_compile_definitions 注入 CDDSCTL_VERSION=${PROJECT_VERSION}, main.cpp 引用该宏。 顺带把 project 版本与 CHANGELOG 升到 0.0.3。 --- CHANGELOG.md | 14 ++++++++++++++ CMakeLists.txt | 2 +- cli/CMakeLists.txt | 4 ++++ cli/main.cpp | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39fb69b..95aa55d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.3] - 2026-06-16 + +### Changed + +- 发布二进制体积缩小约 44%(~4.0MB → ~2.25MB):链接启用 `--gc-sections` + 丢弃静态链入 iceoryx/CycloneDDS 中未引用的代码,Release 默认 `-Os`。 +- 发布时分离调试符号:发布的 bin 经 strip 并通过 `--add-gnu-debuglink` + 关联符号档,符号包仅作为 CI artifact 上传,不挂公开 Release。 + +### Fixed + +- `--version` 不再硬编码:版本号统一以 CMake `project(VERSION)` 为唯一来源, + 注入给 CLI,避免发布版本与二进制自报版本不一致。 + ## [0.0.2] - 2025-03-09 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index 869b27e..39e898a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(cddsctl VERSION 0.0.2 LANGUAGES C CXX) +project(cddsctl VERSION 0.0.3 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 94e9828..6483264 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -13,6 +13,10 @@ target_include_directories(cddsctl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) +# Single source of truth for the CLI version: project(VERSION) in the top-level +# CMakeLists, injected so main.cpp doesn't carry its own copy. +target_compile_definitions(cddsctl PRIVATE CDDSCTL_VERSION="${PROJECT_VERSION}") + target_link_libraries(cddsctl PRIVATE cddsctl_recorder optionparser diff --git a/cli/main.cpp b/cli/main.cpp index ce43a62..6f3d4c3 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -14,7 +14,7 @@ namespace { -constexpr const char* VERSION = "0.0.2"; +constexpr const char* VERSION = CDDSCTL_VERSION; constexpr const char* SHM_STATUS = "with SHM";