CheckSymbolExists: cmake should detect GNU stub declarations
Hello,
cmake doesn't seem to be detecting GNU stub declarations. In the attached testcase: cmake.tgz we have a CMakeLists.txt that uses check_function_exists
to check whether the BSD-ish revoke is available:
include(CheckFunctionExists)
check_function_exists(revoke HAVE_REVOKE)
The GNU libc happens to be providing a stub for revoke that always returns ENOSYS, so the symbol is there, but it is marked as a stub in gnu/stubs.h (actually gnu/stubs-{32,64}.h):
#define __stub_revoke
autoconf does detect that:
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$1 || defined __stub___$1
choke me
#endif
but cmake does not. The problem is that in projects which use the -Wl,--fatal-warnings
link option, such as KDE, this leads to a fatal error at link time:
/usr/bin/cc -rdynamic -Wall -Wl,--fatal-warnings CMakeFiles/test.dir/test.c.o -o test
/usr/bin/ld: CMakeFiles/test.dir/test.c.o: in function `main':
test.c:(.text+0xf): warning: revoke is not implemented and will always fail
collect2: error: ld returned 1 exit status
cmake should detect these stubs to avoid the issue.
Edited by Brad King