I get an error when making a project with CMake:
-- Could NOT find Threads (missing: Threads_FOUND)
The error log shows that CMake tripped up over something truly banal:
/usr/bin/cc -std=c11 -D_GNU_SOURCE -Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wlogical-op -Wno-error=maybe-uninitialized -Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes -march=native -o CMakeFiles/cmTryCompileExec2533162744.dir/CheckIncludeFiles.c.o -c /mnt/shared/fooproj/build/release/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
/mnt/shared/fooproj/build/release/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:5:5:
error: function declaration isn’t a prototype [-Werror=strict-prototypes]
int main(){return 0;}
^
/mnt/shared/fooproj/build/release/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:
In function ‘main’:
/mnt/shared/fooproj/build/release/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:5:5:
error: old-style function definition [-Werror=old-style-definition]
cc1: all warnings being treated as errors
[...]
Source:
/* */
#include <pthread.h>
int main(){return 0;}
This really should be no reason for CMake to think Threads doesn't exist. How do I go about fixing this?
Issue seems to be still there. I try to compile the lates nominatim. seems i got the same error.
Edit:
cmake -lpthread ..
seems to fix thisI believe this is CMake bug 15058 which I just reported.
The test that CMake is using to check the include file uses an old-style C function definition. If
-Wold-style-definition -Werror
is in effect, gcc will barf on this.I included a patch in the bug report linked above, but for a quick fix, find the file
Modules/CheckIncludeFiles.cmake
in your CMake installation (possibly in/usr/share/cmake
or similar), find the lineand change
int main()
toint main(void)
.