View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010692CMakeModulespublic2010-05-09 11:352016-06-10 14:31
ReporterModestas Vainius 
Assigned ToPhilip Lowman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
Platformamd64OSDebian GNU/LinuxOS Versionsid
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0010692: FindBoost fails to add -lpthread
DescriptionWhen using
   find_package(Boost COMPONENTS thread REQUIRED)
-lpthread is not added to the link command, causing the link to fail if
binutils-gold (which has --no-add-needed behavior as default) is used.

More informations can be found at
 http://wiki.debian.org/qa.debian.org/FTBFS#A2009-11-02Packagesfailingbecausebinutils-gold.2BAC8-indirectlinking [^]
Additional InformationSmall testcase is attached to Debian bug report.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=563479 [^]

I tried to fix the bug myself but apparently FindBoost.cmake is not every easy to grasp :/
TagsNo tags attached.
Attached Filesdiff file icon FindBoost_add_-lpthread_#563479.diff [^] (898 bytes) 2011-01-16 12:34 [Show Content]
? file icon FindBoost.cmake [^] (52,930 bytes) 2011-06-10 01:06
diff file icon FindBoost+add_pthread_if_boost_threads_is_in_use.diff [^] (2,099 bytes) 2011-06-10 01:06 [Show Content]
? file icon BoostPthreadWorkaround.cmake [^] (783 bytes) 2012-08-02 17:15
diff file icon FindBoost+add_pthread_if_boost_threads_is_in_use_2.8.11-rc1.diff [^] (1,669 bytes) 2013-03-16 14:58 [Show Content]

 Relationships
has duplicate 0011238closed FindBoost.cmake should add thread library to Boost_LIBRARIES 
related to 0014720closed FindBoost handles pthread different on first and second run 
related to 0015510closedNils Gladitz After 15.04 upgrade, cannot link against against pthread using C++11 <thread> 

  Notes
(0022230)
Philip Lowman (developer)
2010-09-15 15:01

See also
http://public.kitware.com/Bug/view.php?id=11121, [^] http://www.cmake.org/pipermail/cmake/2010-September/039510.html [^]
(0024730)
Curan (reporter)
2011-01-16 12:41

I've created a patch for Debian, the current version is now attached to this bug report, the latest version can be found at [0]. Testing shows it working, though I'm not sure you want to take this verbatim, while it is ok for Debian until there is a upstream sanctioned solution, it might not be fit for direct inclusion.

As a side note: maybe the whole file (FindBoost.cmake) can be drastically simplified if Boost includes that auto-generated pkg-config file from [1].

[0] http://git.debian.org/?p=collab-maint/cmake.git;a=blob;f=debian/patches/FindBoost_add_-lpthread_%23563479.diff;hb=HEAD [^]
[1] https://svn.boost.org/trac/boost/ticket/1094 [^]
(0026815)
Philip Lowman (developer)
2011-06-10 01:06

The patch for Debian will not survive after the initial configure (due to how FindBoost is written). Also it causes pthread to be added on Cygwin where Windows threads is being used.

I've attached a (beta) FindBoost here for additional testing by others (and also a patch).
(0030159)
Michael Tänzer (reporter)
2012-08-02 17:14

I guess I have a system with the described debian patch here (Ubuntu 12.04) and can confirm that it is buggy. It only adds pthread on the first CMake run (which is probably enough for automatic package generation but not for anyone else) and also because pthread is only added as library basename not as full path static linking fails.

Looking through the patch provided by Philip Lowman his solution does not seem to have these problems. But I would suggest to rename the BOOST_THREAD_LIBRARY variable because it is easy to be confused with Boost_THREAD_LIBRARY which is set to the path to the libboost_thread.so and to mark it as advanced.

Until this is fixed in CMake I have done a BoostPthreadWorkaround.cmake file which I will attach to this bug.
(0032648)
Modestas Vainius (reporter)
2013-03-16 14:58

Hereby I attach an updated version of FindBoost+add_pthread_if_boost_threads_is_in_use.diff patch which applies and works with cmake 2.8.11-rc1. I intend to ship it with Debian cmake package replacing the old buggy patch.
(0041693)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2010-05-09 11:35 Modestas Vainius New Issue
2010-09-10 23:48 Philip Lowman Status new => assigned
2010-09-10 23:48 Philip Lowman Assigned To => Philip Lowman
2010-09-15 15:01 Philip Lowman Note Added: 0022230
2010-09-15 15:02 Philip Lowman Relationship added has duplicate 0011238
2011-01-16 12:34 Curan File Added: FindBoost_add_-lpthread_#563479.diff
2011-01-16 12:41 Curan Note Added: 0024730
2011-06-10 01:06 Philip Lowman Note Added: 0026815
2011-06-10 01:06 Philip Lowman File Added: FindBoost.cmake
2011-06-10 01:06 Philip Lowman File Added: FindBoost+add_pthread_if_boost_threads_is_in_use.diff
2012-08-02 17:14 Michael Tänzer Note Added: 0030159
2012-08-02 17:15 Michael Tänzer File Added: BoostPthreadWorkaround.cmake
2013-03-16 14:58 Modestas Vainius File Added: FindBoost+add_pthread_if_boost_threads_is_in_use_2.8.11-rc1.diff
2013-03-16 14:58 Modestas Vainius Note Added: 0032648
2014-01-27 10:46 Nils Gladitz Relationship added related to 0014720
2015-04-13 03:15 Nils Gladitz Relationship added related to 0015510
2016-06-10 14:27 Kitware Robot Note Added: 0041693
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team