FindThreads: Add missing static keyword in pthread test code
When CMAKE_C_FLAGS
contains -Werror -Wmissing-prototypes
the pthread test code check fails with error:
src.c:3:7: error: no previous prototype for 'test_func' [-Werror=missing-prototypes]
.
Adding static
keyword to test_func
fixes it.
The simple code to trigger the error:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wmissing-prototypes")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
After that the CMakeError.log
contains:
src.c:3:7: error: no previous prototype for 'test_func' [-Werror=missing-prototypes]
3 | void* test_func(void* data)
| ^~~~~~~~~
cc1: all warnings being treated as errors
The console output was:
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- 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
-- Found Threads: TRUE