Skip to content

Commit

Permalink
build: Tell cmake to set 'rpath' so the installed 'cmark' can find 'l…
Browse files Browse the repository at this point in the history
…ibcmark.so'

Before this commit, the 'cmark' executable didn't inform the
dynamic linker where to look for the 'libcmark' shared object;
this becomes an irritation when 'libcmark' is installed in an
unorthodox location:

  $ ldd /path/to/installed/files/bin/cmark
          linux-gate.so.1 (0xb7ed7000)
          libcmark.so.0.31.0 => not found
          libc.so.6 => /usr/lib/libc.so.6 (0xb7cf3000)
          /lib/ld-linux.so.2 => /usr/lib/ld-linux.so.2 (0xb7ed8000)

Because of this commit, the 'cmark' executable's 'rpath' setting
(or equivalent) is set upon installation, thereby providing the
required search directory:

  $ ldd /path/to/installed/files/bin/cmark
          linux-gate.so.1 (0xb7ef2000)
          libcmark.so.0.31.0 => /path/to/installed/files/lib/libcmark.so.0.31.0 (0xb7e95000)
          libc.so.6 => /usr/lib/libc.so.6 (0xb7cbc000)
          /lib/ld-linux.so.2 => /usr/lib/ld-linux.so.2 (0xb7ef3000)

In particular, 'rpath' is set to the following value:

  "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"

Of course, this will only help on a system that supports an
'rpath' feature known to CMake. Windows has no such feature
anyway, apparently.
  • Loading branch information
mfwitten committed Mar 1, 2024
1 parent 3337a30 commit d650a5c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")

# Check integrity of node structure when compiled as debug
add_compile_options($<$<CONFIG:Debug>:-DCMARK_DEBUG_NODES>)

Expand Down

0 comments on commit d650a5c

Please sign in to comment.