How to properly check for a function using CMake

Viewed 3136

In converting from automake to cmake, I have to carry over some tests for function existence. I didn't write the configure.ac script, but I do have to reproduce the functionality as closely as follows, so please don't berate me about these checks. I have to make them.

So, I'm trying to use the CheckFunctionExists module to check for the existence of the time function (among others). Here's the cmake code

include(CheckIncludeFiles)

CHECK_FUNCTION_EXISTS(time, HAVE_TIME_FUNCTION)

if(NOT HAVE_TIME_FUNCTION)
    message(FATAL_ERROR "ERROR: required time function not found")
endif(NOT HAVE_TIME_FUNCTION)

This fails every time, even though I know for a fact that I have the time funcion (duh). I tried replacing time with printf and it still fails. Is there some setup I have to do to make this check work correctly?

2 Answers
Related