Target properties and RPATH handling

Let us have a closer look at the properties set on the shared library target. We had to set the following:

  • POSITION_INDEPENDENT_CODE 1: This sets the compiler flags needed for generating position-independent code. For more details, please consult https://en.wikipedia.org/wiki/Position-independent_code.
  • SOVERSION ${PROJECT_VERSION_MAJOR}: This is the version of the application programming interface (API) offered by our shared library. Following semantic version, we have decided to set it to be the same as the major version of the project. CMake targets also have a VERSION property. This can be used to specify the build version of the target. Note that SOVERSION and VERSION might differ: we might want to ...

Get CMake Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.