Skip to content

Commit

Permalink
[c, cpp]: support VERSION file for CMake ABI versioning (#328)
Browse files Browse the repository at this point in the history
* c: use VERSION file for CMake PROJECT and SOVERSION

* cpp: use VERSION file for ABI version and CMake SOVERSION

* cpp: add sample VERSION file

* chore(cpp): fix CHANGELOG.md
  • Loading branch information
chybz authored Nov 30, 2024
1 parent caf524d commit 13cc4b3
Show file tree
Hide file tree
Showing 12 changed files with 954 additions and 503 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt

### Changed
- [cpp] add generic support for ABI versioning with VERSION ([#328](https://github.com/cucumber/gherkin/pull/328))
- [cpp] namespace was changed to 'cucumber::gherkin' to better reflect project structure and prevent clashing

## [30.0.4] - 2024-11-15
### Fixed
Expand Down
30 changes: 28 additions & 2 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
cmake_minimum_required(VERSION 3.5)
project(gherkin C)
set(VERSION 27.0.2)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
file(STRINGS "VERSION" LINES)
list(GET LINES 0 VERSION)
endif()

# Crude Semver parsing
if("${VERSION}" MATCHES "^([^\\.]+)\\.([^\\.]+)\\.([^\\.]+)$")
set(VER_MAJOR ${CMAKE_MATCH_1})
set(VER_MINOR ${CMAKE_MATCH_2})
set(VER_PATCH ${CMAKE_MATCH_3})
else()
message(FATAL_ERROR "unable to parse version: ${VERSION}")
endif()

cmake_minimum_required(VERSION 3.0)
PROJECT(gherkin VERSION ${VERSION} LANGUAGES C)
enable_testing()

# Install library & headers in your directory
Expand Down Expand Up @@ -68,7 +84,17 @@ LIST(APPEND GHERKIN_CLI
)




add_library(gherkin ${GHERKIN_SRS})

set_target_properties(
gherkin
PROPERTIES
VERSION ${VERSION}
SOVERSION ${VER_MAJOR}
)

include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(m log10 "" HAVE_LIB_M)
if (HAVE_LIB_M)
Expand Down
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
###
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(cucumber_gherkin VERSION 0.1.0 LANGUAGES C CXX)
project(cucumber_gherkin VERSION 30.0.4 LANGUAGES C CXX)

###
#
Expand Down
15 changes: 5 additions & 10 deletions cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ clean: clean-deps ## Remove all build artifacts and files generated by the accep

acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference

.built: .configured $(SOURCE_FILES)
.built: $(SOURCE_FILES)
./cmake/cmate install
./cmake/cmate build
touch $@

.configured: .deps-installed
./cmake/cmate configure
./cmake/cmate stage
touch $@

define berp-generate-parser =
Expand Down Expand Up @@ -105,12 +103,9 @@ acceptance/testdata/%.errors.ndjson: ../testdata/% ../testdata/%.errors.ndjson
#
# External dependencies
#
install-deps: .deps-installed
.PHONY: install-deps

.deps-installed:
install-deps:
./cmake/cmate install
touch $@
.PHONY: install-deps

clean-deps:
./cmake/cmate clean --purge
Expand Down
1 change: 1 addition & 0 deletions cpp/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
30.0.4
Loading

0 comments on commit 13cc4b3

Please sign in to comment.