"Performing Test CMAKE_HAVE_LIBC_PTHREAD" 失败到底是什么意思?

What does "Performing Test CMAKE_HAVE_LIBC_PTHREAD" failed actually mean?

cmake 的部分输出如下所示:

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed

线条

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found

是像

这样的调用的输出
find_package(Threads)

此调用在脚本 CMakeLists.txt 中被许多想要使用 threads-related 功能(如 pthread_create)的 CMake 项目使用。

处理此调用时,CMake(通过 FindThreads.cmake 脚本)尝试确定当前平台支持的线程 种类

检查Looking for pthread.h是self-explanatory:CMake检查header pthread.h是否存在和可用。

检查Performing Test CMAKE_HAVE_LIBC_PTHREAD是关于线程支持函数是否直接编译成libc库,还是需要link额外的库(如-lpthread)。

检查 Looking for pthread_create in pthreads 试图在其中找到 pthreads 库和函数 pthread_create

检查 Looking for pthread_create in pthread 试图在其中找到 pthread 库和函数 pthread_create


该特定输出可以解释为:

The platform supports threads by providing the header pthread.h and the library pthread.

此输出对于 Unix-like 系统很常见。 尽管有“失败”和“未找到”字样,但这是非常好的输出。