Skip to content

Commit f8814c4

Browse files
fix(cpp): Actually use the VERSION file (cucumber#376)
* fix(cpp): Actually use the VERSION file Similar to what cucumber#328 added to the C library, actually use the `VERSION` file to set the project version for the C++ library, and use the resulting project version to set the shared library version and ABi version (CMake `SOVERSION`). Fixes cucumber#375. * Changelog entry for PR cucumber#376
1 parent 564fca6 commit f8814c4

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
88

99
## [Unreleased]
1010

11+
### Fixed
12+
- [cpp] Actually use the VERSION file ([#376](https://github.com/cucumber/gherkin/pull/376))
13+
1114
## [32.1.1] - 2025-04-11
1215
### Fixed
1316
- [Java] Avoid unnecessary unboxing to Character

cpp/CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
###
2-
#
3-
# Project
4-
# name and version
5-
#
6-
###
7-
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
1+
set(VERSION 30.0.4)
82

9-
project(cucumber_gherkin VERSION 30.0.4 LANGUAGES C CXX)
3+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
4+
file(STRINGS "VERSION" LINES)
5+
list(GET LINES 0 VERSION)
6+
endif()
7+
8+
# Crude Semver parsing
9+
if("${VERSION}" MATCHES "^([^\\.]+)\\.([^\\.]+)\\.([^\\.]+)$")
10+
set(VER_MAJOR ${CMAKE_MATCH_1})
11+
set(VER_MINOR ${CMAKE_MATCH_2})
12+
set(VER_PATCH ${CMAKE_MATCH_3})
13+
else()
14+
message(FATAL_ERROR "unable to parse version: ${VERSION}")
15+
endif()
16+
17+
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
18+
project(cucumber_gherkin VERSION ${VERSION} LANGUAGES C CXX)
1019

1120
###
1221
#

cpp/src/lib/gherkin/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ set_target_properties(
3535
cucumber_gherkin_lib
3636
PROPERTIES
3737
CXX_STANDARD 20
38-
VERSION 30.0.4
39-
SOVERSION 30
38+
VERSION ${VERSION}
39+
SOVERSION ${VER_MAJOR}
4040
EXPORT_NAME gherkin
4141
OUTPUT_NAME cucumber_gherkin
4242
)

0 commit comments

Comments
 (0)