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

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

Open
musicinmybrain opened this issue Feb 25, 2025 · 1 comment · May be fixed by #376
Open

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

musicinmybrain opened this issue Feb 25, 2025 · 1 comment · May be fixed by #376

Comments

@musicinmybrain
Copy link
Contributor

👓 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)

musicinmybrain added a commit to musicinmybrain/gherkin that referenced this issue Feb 25, 2025
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.
@musicinmybrain musicinmybrain linked a pull request Feb 25, 2025 that will close this issue
3 tasks
@musicinmybrain
Copy link
Contributor Author

We also have this in the C library:

gherkin/c/CMakeLists.txt

Lines 91 to 96 in 275322f

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

and this in the C++ library:

set_target_properties(
cucumber_gherkin_lib
PROPERTIES
CXX_STANDARD 20
VERSION 30.0.4
SOVERSION 30
EXPORT_NAME gherkin
OUTPUT_NAME cucumber_gherkin
)

so it looks like those hard-coded version numbers need adjusting as well.

This seems to make things work as I expected them to: #376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant