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

Fix cmake and linking errors for CMake 3.3 and above #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented Oct 25, 2019

This fixes a linker error with CMake 3.5.1, which as a result of

target_link_libraries(orocos-rtt-${OROCOS_TARGET}_dynamic /full/path/to/orocos_ws/install/liblog4cpp.so)

adds

-llog4cpp

to the linker command line because the library path is considered as an implicit link directory.

It is not, and that's why the linker fails to find log4cpp on my Xenial system:

/usr/bin/ld: cannot find -llog4cpp

Not sure why the catkin install-space inside the home directory is considered as an implicit link directory by CMake 3.5.1. Might be a bug.

Solution:

  • Set cmake policy CMP0060 to NEW, if available. This will make sure that CMake adds the full path to liblog4cpp.so to the linker command line. It is basically a follow-up of CMP0003 for implicit link directories, which we set to NEW since 8f6d7ff.

@meyerj meyerj added the bug label Oct 25, 2019
@meyerj meyerj added this to the 2.10 milestone Oct 25, 2019
@meyerj meyerj force-pushed the master-fix-linker-error-cmake-3.5 branch from 0157afa to f3a9ed5 Compare October 25, 2019 02:07
Link libraries by full path even in implicit directories:
https://cmake.org/cmake/help/v3.5/policy/CMP0060.html

This fixes a linker error with CMake 3.5, which as a result of

    target_link_libraries(orocos-rtt-${OROCOS_TARGET}_dynamic /full/path/to/liblog4cpp.so)

adds

    -llog4cpp

to the linker command line, which results in a linker error:

/usr/bin/ld: cannot find -llog4cpp

Not sure why the install-space is considered as an implicit link directory by CMake.

Signed-off-by: Johannes Meyer <[email protected]>
@meyerj meyerj force-pushed the master-fix-linker-error-cmake-3.5 branch from f3a9ed5 to 9cff84e Compare October 25, 2019 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant