This module determines the thread library of the system.

Imported Targets

New in version 3.1.

This module defines the following IMPORTED target:


The thread library, if found.

Result Variables

The following variables are set:


If a supported thread library was found.


The thread library to use. This may be empty if the thread functions are provided by the system libraries and no special flags are needed to use them.


If the found thread library is the win32 one.


If the found thread library is pthread compatible.


If the found thread library is the HP thread library.

Variables Affecting Behavior


New in version 3.1.

If the use of the -pthread compiler and linker flag is preferred then the caller can set this variable to TRUE. The compiler flag can only be used with the imported target. Use of both the imported target as well as this switch is highly recommended for new code.

This variable has no effect if the system libraries provide the thread functions, i.e. when CMAKE_THREAD_LIBS_INIT will be empty.