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

CMake: Add soversion to library files to generate proper symlinks #394

Merged
merged 2 commits into from
Jan 8, 2017

Conversation

cebe
Copy link
Member

@cebe cebe commented Jan 5, 2017

As mentioned in #359 (comment)
the current CMake build does not generate version symlinks for library .so files.
This is because the version is not specified for library targets.

See

I have used VERSION instead of SOVERSION as this seems to be
compatible with windows according to the docs linked above.
updated: changed this, see comments below.

I have compared installed files with autotools build vs. cmake:

autotools:

$ find . | sort
.
./bin
./include
./include/tox
./include/tox/toxav.h
./include/tox/toxdns.h
./include/tox/toxencryptsave.h
./include/tox/tox.h
./lib
./lib/libtoxav.a
./lib/libtoxav.la
./lib/libtoxav.so
./lib/libtoxav.so.0
./lib/libtoxav.so.0.0.0
./lib/libtoxcore.a
./lib/libtoxcore.la
./lib/libtoxcore.so
./lib/libtoxcore.so.0
./lib/libtoxcore.so.0.0.0
./lib/libtoxdns.a
./lib/libtoxdns.la
./lib/libtoxdns.so
./lib/libtoxdns.so.0
./lib/libtoxdns.so.0.0.0
./lib/libtoxencryptsave.a
./lib/libtoxencryptsave.la
./lib/libtoxencryptsave.so
./lib/libtoxencryptsave.so.0
./lib/libtoxencryptsave.so.0.0.0
./lib/pkgconfig
./lib/pkgconfig/libtoxav.pc
./lib/pkgconfig/libtoxcore.pc

cmake:

$ find . | sort
.
./include
./include/tox
./include/tox/toxav.h
./include/tox/toxdns.h
./include/tox/toxencryptsave.h
./include/tox/tox.h
./lib
./lib/libtoxav.a
./lib/libtoxav.so
./lib/libtoxav.so.0.1.2
./lib/libtoxcore.a
./lib/libtoxcore.so
./lib/libtoxcore.so.0.1.2
./lib/libtoxcrypto.a
./lib/libtoxcrypto.so
./lib/libtoxcrypto.so.0.1.2
./lib/libtoxdht.a
./lib/libtoxdht.so
./lib/libtoxdht.so.0.1.2
./lib/libtoxdns.a
./lib/libtoxdns.so
./lib/libtoxdns.so.0.1.2
./lib/libtoxencryptsave.a
./lib/libtoxencryptsave.so
./lib/libtoxencryptsave.so.0.1.2
./lib/libtoxfriends.a
./lib/libtoxfriends.so
./lib/libtoxfriends.so.0.1.2
./lib/libtoxgroup.a
./lib/libtoxgroup.so
./lib/libtoxgroup.so.0.1.2
./lib/libtoxmessenger.a
./lib/libtoxmessenger.so
./lib/libtoxmessenger.so.0.1.2
./lib/libtoxnetcrypto.a
./lib/libtoxnetcrypto.so
./lib/libtoxnetcrypto.so.0.1.2
./lib/libtoxnetwork.a
./lib/libtoxnetwork.so
./lib/libtoxnetwork.so.0.1.2
./lib/pkgconfig
./lib/pkgconfig/libtoxav.pc
./lib/pkgconfig/libtoxcore.pc
./lib/pkgconfig/toxav.pc
./lib/pkgconfig/toxcore.pc
./lib/pkgconfig/toxdns.pc
./lib/pkgconfig/toxencryptsave.pc

This change is Reviewable

@cebe cebe mentioned this pull request Jan 5, 2017
@iphydf iphydf added this to the v0.1.4 milestone Jan 5, 2017
@iphydf
Copy link
Member

iphydf commented Jan 5, 2017

0.1.2 is compatible with 0.1.3. Is this reflected by the sonames in this PR?

@cebe
Copy link
Member Author

cebe commented Jan 5, 2017

I just read a bit more about sonames and it seems what I have done is not correct. The soname version should only change when incompatible changes are made, so as far as I see, we should only provide the ${PROJECT_VERSION_MAJOR} there as that is the one that indicates incompatibility, right?

@jin-eld
Copy link

jin-eld commented Jan 5, 2017

Ideally the cmake variant should be in sync with the .so version in autoconf, have a look at:
https://github.com/TokTok/c-toxcore/blob/master/configure.ac#L15

Maybe we could even come up with a configuration file where this can be set for both build systems.

@cebe
Copy link
Member Author

cebe commented Jan 5, 2017

Using the MAJOR number will be in sync with the autotools:

$ objdump -p lib/libtoxcore.so |grep SONAME
  SONAME               libtoxcore.so.0

output above is the same for autotools and cmake now.

after last commit the following files are generated:

$ find .|sort
.
./include
./include/tox
./include/tox/toxav.h
./include/tox/toxdns.h
./include/tox/toxencryptsave.h
./include/tox/tox.h
./lib
./lib/libtoxav.a
./lib/libtoxav.so
./lib/libtoxav.so.0
./lib/libtoxav.so.0.1.2
./lib/libtoxcore.a
./lib/libtoxcore.so
./lib/libtoxcore.so.0
./lib/libtoxcore.so.0.1.2
./lib/libtoxcrypto.a
./lib/libtoxcrypto.so
./lib/libtoxcrypto.so.0
./lib/libtoxcrypto.so.0.1.2
./lib/libtoxdht.a
./lib/libtoxdht.so
./lib/libtoxdht.so.0
./lib/libtoxdht.so.0.1.2
./lib/libtoxdns.a
./lib/libtoxdns.so
./lib/libtoxdns.so.0
./lib/libtoxdns.so.0.1.2
./lib/libtoxencryptsave.a
./lib/libtoxencryptsave.so
./lib/libtoxencryptsave.so.0
./lib/libtoxencryptsave.so.0.1.2
./lib/libtoxfriends.a
./lib/libtoxfriends.so
./lib/libtoxfriends.so.0
./lib/libtoxfriends.so.0.1.2
./lib/libtoxgroup.a
./lib/libtoxgroup.so
./lib/libtoxgroup.so.0
./lib/libtoxgroup.so.0.1.2
./lib/libtoxmessenger.a
./lib/libtoxmessenger.so
./lib/libtoxmessenger.so.0
./lib/libtoxmessenger.so.0.1.2
./lib/libtoxnetcrypto.a
./lib/libtoxnetcrypto.so
./lib/libtoxnetcrypto.so.0
./lib/libtoxnetcrypto.so.0.1.2
./lib/libtoxnetwork.a
./lib/libtoxnetwork.so
./lib/libtoxnetwork.so.0
./lib/libtoxnetwork.so.0.1.2
./lib/pkgconfig
./lib/pkgconfig/libtoxav.pc
./lib/pkgconfig/libtoxcore.pc
./lib/pkgconfig/toxav.pc
./lib/pkgconfig/toxcore.pc
./lib/pkgconfig/toxdns.pc
./lib/pkgconfig/toxencryptsave.pc

To have everything in sync we only need to adjust the version in configure.ac as far as I see.

@iphydf
Copy link
Member

iphydf commented Jan 5, 2017

While we're on 0.x, the x behaves like the major version. 0.2 will be incompatible with 0.1.

@cebe
Copy link
Member Author

cebe commented Jan 5, 2017

okay, changed that, also removed the version from static library as these do not support a versioning concept.

@iphydf iphydf self-assigned this Jan 6, 2017
@@ -611,6 +611,10 @@ endif()
#
# :: Strict ABI
#
# Enabling the STRICT_ABI flag will generate and use an LD version script.
# It ensures that the dynamic libraries (libtoxcore.so, libtoxav.so) only
# export the symbols that are defined in their public API (tox.h and toxav.h, respectively).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Break the line at 80 columns.

set_target_properties(${lib}_shared PROPERTIES
OUTPUT_NAME ${lib}
VERSION ${PROJECT_VERSION}
# While on 0.x, the x behaves like the major version. 0.2 will be incompatible with 0.1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@iphydf
Copy link
Member

iphydf commented Jan 8, 2017

:lgtm_strong:


Reviewed 1 of 2 files at r1, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


Comments from Reviewable

@iphydf
Copy link
Member

iphydf commented Jan 8, 2017

Rebase and squash the commits, then I'll merge.

This part has been added in
TokTok@67ac913
Took the commit message to provide a comment in the file.
As mentioned in TokTok#359 (comment)
the current CMake build does not generate version symlinks for library .so files.
This is because the version is not specified for library targets.

See
- https://cmake.org/cmake/help/v3.0/prop_tgt/SOVERSION.html#prop_tgt:SOVERSION
- https://cmake.org/cmake/help/v3.0/prop_tgt/VERSION.html#prop_tgt:VERSION

Use PROJECT_VERSION_MAJOR and MINOR for SOVERSION because
api may break from 0.1 to 0.2 in the 0.x release cycle.
@cebe
Copy link
Member Author

cebe commented Jan 8, 2017

Rebase and squash the commits, then I'll merge.

done.

@iphydf
Copy link
Member

iphydf commented Jan 8, 2017

Reviewed 2 of 2 files at r5.
Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 8, 2017

Reviewed 2 of 2 files at r5.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


cmake/ModulePackage.cmake, line 59 at r5 (raw file):

    set_target_properties(${lib}_shared PROPERTIES
      OUTPUT_NAME ${lib}
      VERSION ${PROJECT_VERSION}

it sounds like CMake expects the VERSION to be MAJOR.MINOR too, just like the SOVERSION is, instead of MAJOR.MINOR.PATCH that we have here.

https://cmake.org/cmake/help/v2.8.6/cmake.html#prop_tgt:VERSION


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 8, 2017

Review status: all files reviewed at latest revision, 1 unresolved discussion.


cmake/ModulePackage.cmake, line 59 at r5 (raw file):

Previously, nurupo wrote…

it sounds like CMake expects the VERSION to be MAJOR.MINOR too, just like the SOVERSION is, instead of MAJOR.MINOR.PATCH that we have here.

https://cmake.org/cmake/help/v2.8.6/cmake.html#prop_tgt:VERSION

Nevermind, CeBe seems to know better what he is doing.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 8, 2017

:lgtm_strong:


Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@cebe
Copy link
Member Author

cebe commented Jan 8, 2017

Review status: all files reviewed at latest revision, 3 unresolved discussions.


CMakeLists.txt, line 616 at r4 (raw file):

Previously, iphydf wrote…

Break the line at 80 columns.

Done.


cmake/ModulePackage.cmake, line 60 at r4 (raw file):

Previously, iphydf wrote…

Same here.

Done.


cmake/ModulePackage.cmake, line 59 at r5 (raw file):

Previously, nurupo wrote…

Nevermind, CeBe seems to know better what he is doing.

Done.


Comments from Reviewable

@robinlinden
Copy link
Member

Reviewed 2 of 2 files at r5.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@iphydf iphydf merged commit 6ec23c9 into TokTok:master Jan 8, 2017
@cebe cebe deleted the cmake branch January 8, 2017 19:48
This pull request was closed.
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 this pull request may close these issues.

5 participants