[CMake] CHECK_FUNCTION_EXISTS

David Cole david.cole at kitware.com
Sat Apr 12 16:25:16 EDT 2008


Try setting CMAKE_REQUIRED_LIBRARIES to kernel32 (or maybe kernel32.lib?)
before checking for Sleep.

SET(CMAKE_REQUIRED_LIBRARIES "kernel32")
CHECK_FUNCTION_EXISTS(Sleep HAVE_SLEEP)

Does that work?


On Sat, Apr 12, 2008 at 6:21 AM, George Neill <georgen at neillnet.com> wrote:

> Hi CMakers,
>
> I feel rather stupid asking this question, but here I go.   I have the
> following simple CMakeLists.txt file (on the windows platform, default
> MSVC compiler install).
>
>
> C:\Documents and Settings\gneill\Desktop\tmp>type CMakeLists.txt
>
> PROJECT(GEORGE C)
>
> include(CheckFunctionExists)
>
> CHECK_FUNCTION_EXISTS(Sleep HAVE_SLEEP)
> CHECK_FUNCTION_EXISTS(strtod HAVE_STRTOD)
>
>
> Here's the result,
>
> C:\Documents and Settings\gneill\Desktop\tmp>cmake .
>
> -- Check for working C compiler: C:/Program Files/Microsoft Visual
> Studio .NET 2003/Vc7/bin/cl.exe
> -- Check for working C compiler: C:/Program Files/Microsoft Visual
> Studio .NET 2003/Vc7/bin/cl.exe -- works
> -- Check size of void*
> -- Check size of void* - done
> -- Looking for Sleep
> -- Looking for Sleep - not found
> -- Looking for strtod
> -- Looking for strtod - found
> -- Configuring done
> -- Generating done
> -- Build files have been written to: C:/Documents and
> Settings/gneill/Desktop/tmp
>
>
> Is there some trick to making it find Sleep()  (which is located in
> windows.h/kernel32.lib)?  It's appears to be able to find strtod which
> is in the CRT.
>
> I have also tried adding (below) with no luck,
>
> SET(CMAKE_REQUIRED_LIBRARIES kernel32 user32)
>
> Here's what I am seeing in CMakeFiles\CMakeError.log
>
> Determining if the function Sleep exists failed with the following output:
>
> Microsoft (R) Development Environment  Version 7.10.6030.
> Copyright (C) Microsoft Corp 1984-2001. All rights reserved.
>
> ------ Build started: Project: cmTryCompileExec, Configuration: Debug
> Win32 ------
>
> Compiling...
>
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for
> 80x86
>
> Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
> cl /Od /D "WIN32" /D "_WINDOWS" /D "CHECK_FUNCTION_EXISTS=Sleep" /D
> "_DEBUG" /D
> "CMAKE_INTDIR=\"Debug\"" /D "_MBCS" /FD /RTCs /MDd /GS
> /Fo"cmTryCompileExec.dir\
> Debug\\" /Fd"C:/Documents and
> Settings/gneill/Desktop/tmp/CMakeFiles/CMakeTmp/De
> bug/cmTryCompileExec.pdb" /W3 /c /Zi /TC   /Zm1000
>   "\Program Files\CMake 2.4\share\cmake-2.4\Modules\CheckFunctionExists.c"
> CheckFunctionExists.c
> Linking...
> CheckFunctionExists.obj : error LNK2019: unresolved external symbol
> _Sleep referenced in function _main
>
> Debug\cmTryCompileExec.exe : fatal error LNK1120: 1 unresolved externals
>
> Build log was saved at "file://c:\Documents and
>
> Settings\gneill\Desktop\tmp\CMakeFiles\CMakeTmp\cmTryCompileExec.dir\Debug\BuildLog.htm"
>
> cmTryCompileExec - 2 error(s), 0 warning(s)
>
> ---------------------- Done ----------------------
>
>    Build: 0 succeeded, 1 failed, 0 skipped
>
>
> Maybe I just have something misconfigured (or missing something
> simple) .. any suggestions?
>
>
> TIA,
> George.
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080412/1fdbb228/attachment.htm>


More information about the CMake mailing list