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

Convert cmake targets to plain libraries to fix linker error #68

Merged

Conversation

@sloretz
Copy link
Contributor

sloretz commented Aug 3, 2019

When ${PROJECT_NAME}_LIBRARIES contains an imported cmake target, this command will blindly add it to the Makefile with a -l option in front. This PR uses a catkin function to extract the library path from imported cmake targets before passing it to the command.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
sloretz added a commit to sloretz/catkin that referenced this pull request Aug 3, 2019
FindBoost.cmake blindly adds `${CMAKE_THREAD_LIBS_INIT}` to
`${Boost_LIBRARIES}` when the component `thread` is found.
On Debian buster the `FindThreads.cmake` sets that to `-pthread`.
This breaks a bunch of stuff becakse `-pthread` is a linker flag, not a
library.

There were earlier fixes for `-lpthread`.
This PR expands upon them.
First this PR modifies the fix from ros#998 to not add `-l` to any linker flag.
Second it adds to the fix in ros#975 to make sure `-pthread` is passed to
downstream users.
There's no standard cmake variable for linker flags, so this PR opts to
create an interface target with just the flag, and add that to
`${PROJECT_NAME}_LIBRARIES` instead.

Both this PR and ros-visualization/python_qt_binding#68 are required to strip or `qt_gui_cpp` will fail at link time.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@dirk-thomas

This comment has been minimized.

Copy link
Member

dirk-thomas commented Sep 30, 2019

Thanks for the fix.

@dirk-thomas dirk-thomas merged commit afde80e into ros-visualization:kinetic-devel Sep 30, 2019
dirk-thomas added a commit to ros/catkin that referenced this pull request Oct 7, 2019
* Fix -pthread handling in Debian buster

FindBoost.cmake blindly adds `${CMAKE_THREAD_LIBS_INIT}` to
`${Boost_LIBRARIES}` when the component `thread` is found.
On Debian buster the `FindThreads.cmake` sets that to `-pthread`.
This breaks a bunch of stuff becakse `-pthread` is a linker flag, not a
library.

There were earlier fixes for `-lpthread`.
This PR expands upon them.
First this PR modifies the fix from #998 to not add `-l` to any linker flag.
Second it adds to the fix in #975 to make sure `-pthread` is passed to
downstream users.
There's no standard cmake variable for linker flags, so this PR opts to
create an interface target with just the flag, and add that to
`${PROJECT_NAME}_LIBRARIES` instead.

Both this PR and ros-visualization/python_qt_binding#68 are required to strip or `qt_gui_cpp` will fail at link time.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* math() output actually used

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* dummyN -> wrapped-linker-optionsN

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Fix pre-3.13.0 target property setting

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Add test for propagation of linker options

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Force add CMakeLists.txt

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Indent using 2 spaces

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Increment until target is unique

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.