forked from ros-o/catkin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix -pthread handling in Debian buster (ros#1021)
* 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 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> * 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>
- Loading branch information
1 parent
77822d3
commit c3c645b
Showing
10 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/mock_resources/src/linker_options/src/leaf_pkg/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
project(leaf_pkg) | ||
|
||
find_package(catkin REQUIRED COMPONENTS root_pkg) | ||
|
||
add_executable(leaf leaf.cpp) | ||
target_link_libraries(leaf ${catkin_LIBRARIES}) | ||
target_include_directories(leaf PUBLIC ${catkin_INCLUDE_DIRS}) | ||
|
||
catkin_package() | ||
|
||
list(LENGTH catkin_LIBRARIES size) | ||
math(EXPR size_is_not_3 "${size} - 3") | ||
if (size_is_not_3) | ||
message(FATAL_ERROR "Wrong size for catkin_LIBRARIES: ${catkin_LIBRARIES} : ${size}") | ||
else() | ||
message(STATUS "All is OK: ${catkin_LIBRARIES}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <iostream> | ||
#include <root_pkg/root.hpp> | ||
|
||
int main() | ||
{ | ||
std::cout << "leaf_pkg calling "; | ||
root_pkg::func(); | ||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
test/mock_resources/src/linker_options/src/leaf_pkg/package.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<package format="2"> | ||
<name>leaf_pkg</name> | ||
<version>3.4.5</version> | ||
<description>Checks library and linker options</description> | ||
<author>Somebody</author> | ||
<maintainer email="Somebody@somewhere.org">Somebody</maintainer> | ||
<license>Unknown</license> | ||
<url/> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
|
||
<depend>root_pkg</depend> | ||
</package> |
20 changes: 20 additions & 0 deletions
20
test/mock_resources/src/linker_options/src/root_pkg/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
project(root_pkg) | ||
|
||
find_package(catkin REQUIRED) | ||
|
||
add_library(rootlib SHARED root.cpp) | ||
target_include_directories(rootlib PUBLIC include) | ||
|
||
catkin_package( | ||
INCLUDE_DIRS include | ||
LIBRARIES -pthread -lpthread rootlib | ||
) | ||
|
||
install(TARGETS rootlib | ||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) | ||
|
||
install(DIRECTORY include/${PROJECT_NAME}/ | ||
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}) |
4 changes: 4 additions & 0 deletions
4
test/mock_resources/src/linker_options/src/root_pkg/include/root_pkg/root.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace root_pkg | ||
{ | ||
void func(); | ||
} |
11 changes: 11 additions & 0 deletions
11
test/mock_resources/src/linker_options/src/root_pkg/package.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<package format="2"> | ||
<name>root_pkg</name> | ||
<version>3.4.5</version> | ||
<description>Exports library and linker options in ${root_pkg_LIBRARIES}</description> | ||
<author>Somebody</author> | ||
<maintainer email="Somebody@somewhere.org">Somebody</maintainer> | ||
<license>Unknown</license> | ||
<url/> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
</package> |
11 changes: 11 additions & 0 deletions
11
test/mock_resources/src/linker_options/src/root_pkg/root.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <iostream> | ||
|
||
#include "root_pkg/root.hpp" | ||
|
||
namespace root_pkg | ||
{ | ||
void func() | ||
{ | ||
std::cout << "root_pkg::func()\n"; | ||
} | ||
} |