Skip to content

[cpp] CMake ABI/SONAME versioning does not appear to work as expected #375

Open
@musicinmybrain

Description

@musicinmybrain

👓 What did you see?

Based on #320 (comment) and #328, I expected the SONAME version for both C and C++ shared libraries to be 32 for https://github.com/cucumber/gherkin/releases/tag/v32.0.0, using

32.0.0

and

32.0.0

Indeed, this was the case for the C++ library,

libgherkin.so -> libgherkin.so.32
libgherkin.so.32 -> libgherkin.so.32.0.0
libgherkin.so.32.0.0

but not for the C++ library,

libcucumber_gherkin.so -> libcucumber_gherkin.so.30
libcucumber_gherkin.so.30 -> libcucumber_gherkin.so.30.0.4
libcucumber_gherkin.so.30.0.4

✅ What did you expect to see?

I expected to see the C++ shared library versioned based on cpp/VERSION, just as the C shared library is now versioned based on c/VERSION, which would have resulted in:

libcucumber_gherkin.so -> libcucumber_gherkin.so.32
libcucumber_gherkin.so.32 -> libcucumber_gherkin.so.32.0.0
libcucumber_gherkin.so.32.0.0

📦 Which tool/library version are you using?

cucumber/gherkin 32.0.0; no other versions should be relevant

🔬 How could we reproduce it?

Build cpp/ with CMake in the usual way, setting -DBUILD_SHARED_LIBS:BOOL=ON. Observe that this produces:

${builddir}/src/lib/gherkin/libcucumber_gherkin.so.30.0.4
${builddir}/src/lib/gherkin/libcucumber_gherkin.so.30
${builddir}/src/lib/gherkin/libcucumber_gherkin.so

when the contents of VERSION are

32.0.0

📚 Any additional context?

It looks like cpp/CMakeLists.txt needs the same boilerplate as c/CMakeLists.txt:

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions