Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c, cpp]: support VERSION file for CMake ABI versioning #328

Merged
merged 4 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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