“执行测试 CMAKE_HAVE_LIBC_PTHREAD”失败实际上是什么意思?

Neo*_*Neo 21 pthreads cmake

cmake 部分输出如下所示:

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
Run Code Online (Sandbox Code Playgroud)

Tsy*_*rev 30

线条

-- 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
Run Code Online (Sandbox Code Playgroud)

是调用的输出,如

find_package(Threads)
Run Code Online (Sandbox Code Playgroud)

CMakeLists.txt许多想要使用线程相关功能(如pthread_create)的CMake 项目在脚本中使用此调用。

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

检查Looking for pthread.h是不言自明的:CMake 检查标头是否pthread.h存在和可用。

检查Performing Test CMAKE_HAVE_LIBC_PTHREAD是关于线程支持函数是直接编译到 libc 库中,还是需要链接其他库(如-lpthread)。

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

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


该特定输出可以解释为:

该平台通过提供头文件pthread.h和库来支持线程pthread

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