MantisBT - CMake
View Issue Details
0014049CMakeModulespublic2013-03-29 12:372015-04-06 09:07
Nico Schlömer 
Rolf Eike Beer 
normalminoralways
closedfixed 
 
CMake 3.1CMake 3.1 
0014049: FindThreads.cmake: several small bugs
I just browsed through FindThreads.cmake and found that it probably needs to be looked through more carefully.
Two things that I noticed:

* The variable THREADS_HAVE_PTHREAD_ARG is referenced before it is first assigned, meaning that the test if(THREADS_HAVE_PTHREAD_ARG) is unconditionally false.
* When going through the library search (-lpthreads, -lpthread, -lthread), each of those blocks should probably be encapsulated in

  if(NOT CMAKE_HAVE_THREADS_LIBRARY)
  [...]
  endif()
 
  Otherwise the keeps testing even though a library has already been found.

The question remains what the priorities should be if -lpthreads is present, -pthread is a valid compiler flag, and threads are already built into the standard library.

I'm thinking 3-2-1 would be a reasonable choice, in which case the order of the checking would have to be slightly adapted.
No tags attached.
parent of 0014767closed Rolf Eike Beer FindThreads.cmake prefers -lpthread over -pthread with GCC 
Issue History
2013-03-29 12:37Nico SchlömerNew Issue
2013-04-01 10:05Brad KingAssigned To => Rolf Eike Beer
2013-04-01 10:05Brad KingStatusnew => assigned
2014-03-25 18:58Rolf Eike BeerNote Added: 0035513
2014-08-01 14:55Nico SchlömerNote Added: 0036540
2014-10-06 15:46Rolf Eike BeerRelationship addedparent of 0014767
2014-10-06 15:47Rolf Eike BeerStatusassigned => resolved
2014-10-06 15:47Rolf Eike BeerResolutionopen => fixed
2014-10-06 15:47Rolf Eike BeerFixed in Version => CMake 3.1
2014-10-06 15:47Rolf Eike BeerTarget Version => CMake 3.1
2015-04-06 09:07Robert MaynardNote Added: 0038418
2015-04-06 09:07Robert MaynardStatusresolved => closed

Notes
(0035513)
Rolf Eike Beer   
2014-03-25 18:58   
The reading of THREADS_HAVE_PTHREAD_ARG is to prevent the check code running again when CMake reruns.

I have pushed a branch "threads-cleanup" to stage, that is not merged to next right now because CMake 3.0 is so close.

The reordering of the -pthread/-lphtreads stuff is still to be done.
(0036540)
Nico Schlömer   
2014-08-01 14:55   
Fixed by commit 858ce31f4cd8d247a6dd7b8ae70ab9a38f71e7a2 [1].

Feel free to close.

[1] https://github.com/Kitware/CMake/commit/858ce31f4cd8d247a6dd7b8ae70ab9a38f71e7a2 [^]
(0038418)
Robert Maynard   
2015-04-06 09:07   
Closing resolved issues that have not been updated in more than 4 months.