[CMake] CheckFunctionExists.c on windows
nikita kozlov
nikita at mbdsys.com
Wed Dec 30 09:43:21 EST 2009
Hello,
On windows you need to add some #include to be able to link with some libs.
Example, if i want to check the existence of socket() function, i need
to link with ws2_32.lib, but i need to include winsock2.h too for some
defines purpose.
a small cmake example:
if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ws2_32.lib)
set(CMAKE_REQUIRED_FLAGS /FIwinsock2.h)
endif(WIN32)
CHECK_FUNCTION_EXISTS(socket)
A patch proposal :
diff -rU4 CMakeA/Modules/CheckFunctionExists.c
CMakeB/Modules/CheckFunctionExists.c
--- CMakeA/Modules/CheckFunctionExists.c 2004-04-15
14:22:19.000000000 +0200
+++ CMakeB/Modules/CheckFunctionExists.c 2009-12-30
15:29:07.000000000 +0100
@@ -1,15 +1,18 @@
#ifdef CHECK_FUNCTION_EXISTS
+#ifndef _MSC_VER
char CHECK_FUNCTION_EXISTS();
+#endif /* _MSC_VER */
+
#ifdef __CLASSIC_C__
int main(){
int ac;
char*av[];
#else
int main(int ac, char*av[]){
#endif
- CHECK_FUNCTION_EXISTS();
+ static void * p = (void*) CHECK_FUNCTION_EXISTS;
if(ac > 1000)
{
return *av[0];
}
--
nikita
-------------- next part --------------
A non-text attachment was scrubbed...
Name: checkFunctionExists.patch
Type: text/x-diff
Size: 598 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091230/b9da3d4d/attachment-0001.patch>
More information about the CMake
mailing list