FS#61111 - [cmake] FindBoost with Boost thread generates wrong Boost_LIBRARIES (added -lpthread)
Attached to Project:
Arch Linux
Opened by Major (majorx234) - Monday, 17 December 2018, 17:00 GMT
Last edited by Antonio Rojas (arojas) - Tuesday, 10 December 2019, 17:24 GMT
Opened by Major (majorx234) - Monday, 17 December 2018, 17:00 GMT
Last edited by Antonio Rojas (arojas) - Tuesday, 10 December 2019, 17:24 GMT
|
Details
Description:
Problem appear with cmake-3.13.1-1 in old version cmake-3.12.4-1 everything works fine. If I use boost in a cmake project and use FindBoost.cmake provided by this cmake package with find_package(Boost REQUIRED COMPONENTS thread) I get output in cmake with : MESSAGE(${Boost_LIBRARIES}) Outputstring: /usr/lib/libboost_thread.so-lpthread/usr/lib/libboost_chrono.so/usr/lib/libboost_system.so/usr/lib/libboost_date_time.so/usr/lib/libboost_atomic.so so there is a "-lpthread" inside the string of ${Boost_LIBRARIES} wich leads to errors when cmake generates make files and and gcc try to link against -l-lpthread I have this problem on 2 pcs even with plain new installed Archlinux just with newest boost package boost 1.68.0-2 boost-libs 1.68.0-2 in old version cmake-3.12.4-1 the Outputstring of MESSAGE(${Boost_LIBRARIES}) is: /usr/lib/libboost_date_time.so/usr/lib/libboost_system.so/usr/lib/libboost_thread.so/usr/lib/libboost_chrono.so/usr/lib/libboost_atomic.so as expected Steps to reproduce: small cmake project with find_package(Boost REQUIRED COMPONENTS thread) MESSAGE(${Boost_LIBRARIES}) |
This task depends upon
-- Boost_LIBRARIES=/usr/lib/libboost_thread.so;-lpthread;/usr/lib/libboost_chrono.so;/usr/lib/libboost_date_time.so;/usr/lib/libboost_atomic.so
But cmake links fine to it, at least when using target_link_libraries:
target_link_libraries(hello ${Boost_LIBRARIES})
Please close
it is not standard
for target_link_libraries there are several conventions (paths,names...) but not "-l..."
look at documentation of cmake (https://cmake.org/cmake/help/v3.15/command/target_link_libraries.html)
"Each <item> may be:
..."
for an "<itme>" "-l..." is not mentioned and in point "A link flag: "
it is explicitly excluded "but not -l "