MantisBT - CMake
View Issue Details
0014905CMakeCMakepublic2014-05-05 13:572016-02-01 09:10
Robert Maynard 
Rolf Eike Beer 
normalminoralways
closedfixed 
CMake 3.0 
CMake 3.4CMake 3.4 
0014905: FindThreads doesn't clearly express it requires C language enabled.
The FindThread documentation doesn't express that is uses the try_run command and requires that C support has been enabled, when pthread isn't in a system include ( osx xcode 5+, cross compilation ).

I think the documentation should be extended to state that FindThread requires a project to have enabled the C language. It should also document how to properly setup FindThread for cross compilation.

Ee should also consider falling back to the C++ compiler for the try_run if the C compiler doesn't exist, and we don't have a toolchain.
run the minimal project at:
https://github.com/robertmaynard/Sandbox/tree/master/FindThreadCXX [^]
No tags attached.
related to 0015723closed Rolf Eike Beer Regression: FindCUDA fails for C++ only projects in CMake 3.3.1 due find_package(Threads), while it works well in CMake 3.2.3 
Issue History
2014-05-05 13:57Robert MaynardNew Issue
2015-09-10 14:18Brad KingRelationship addedrelated to 0015723
2015-09-10 16:45Brad KingNote Added: 0039403
2015-09-23 05:42Rolf Eike BeerNote Added: 0039474
2015-09-25 10:15Brad KingNote Added: 0039480
2015-09-25 10:15Brad KingAssigned To => Rolf Eike Beer
2015-09-25 10:15Brad KingStatusnew => resolved
2015-09-25 10:15Brad KingResolutionopen => fixed
2015-09-25 10:15Brad KingFixed in Version => CMake 3.4
2015-09-25 10:15Brad KingTarget Version => CMake 3.4
2016-02-01 09:10Robert MaynardNote Added: 0040419
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0039403)
Brad King   
2015-09-10 16:45   
FindThreads uses several checks that are all C-specific. Some of the checks have CXX versions available. Others do not. All this infrasturcture was originally built before we had a notion of enabling C and CXX separately.

I wonder if instead we should memorize in Modules/{Compiler,Platform}/*.cmake what flags/libraries are needed for threading on each system. We could even consider making threading a first-class CMake target property with flag mapping available on all generators. FindThreads could then just forward the information from the platform modules into its legacy variables.
(0039474)
Rolf Eike Beer   
2015-09-23 05:42   
The tread support is more something of the C library than of the compiler, at least for those platforms where it really makes a difference, e.g. you may not get any thread support at all if you have a minimal C library on embedded systems while still running gcc. It's indeed irrelevant for MSVC as you are basically coupled with a specific C runtime when using this compiler, but that's not the case for other platforms.

The limitation to C should be gone now, there are patches in next that should make FindThreads.cmake work in projects where only C++ is enabled.
(0039480)
Brad King   
2015-09-25 10:15   
Eike's topic to fix FindThreads with only CXX enabled has been merged to 'master' here:

 Merge topic 'Threads-CXX'
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=910ea210 [^]
(0040419)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.