1

I am trying to build I-Simpa on the Mac.

When I try and build at the spps stage, I get errors about clock_gettime not found. I tried altering the CMakelists.txt in the spps directory as in this question:

check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)

if (NOT HAVE_CLOCK_GETTIME)
    set(CMAKE_EXTRA_INCLUDE_FILES time.h)
    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
    SET(CMAKE_EXTRA_INCLUDE_FILES)
endif()

But I then get the error:

Unknown CMake command "CHECK_FUNCTION_EXISTS"

Community
  • 1
  • 1
Keith Sloan
  • 125
  • 1
  • 12

1 Answers1

0

I guess you altered this part of the CMakeLists.txt:

if (UNIX)
  include(CheckLibraryExists)
  check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME )
  if(NOT HAVE_CLOCK_GETTIME)
    message(FATAL_ERROR "clock_gettime not found")
  endif(NOT HAVE_CLOCK_GETTIME)
endif(UNIX)

As you can see, check_library_exists is known by CMake because the corresponding module has been previously included using include(CheckLibraryExists).

Again, that is just a guess, but I am pretty sure you didn't included the module for CHECK_FUNCTION_EXISTS. Try:

check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)

if (NOT HAVE_CLOCK_GETTIME)
    #**************************#
    include(CheckFunctionExists)
    #**************************#
    set(CMAKE_EXTRA_INCLUDE_FILES time.h)
    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
    SET(CMAKE_EXTRA_INCLUDE_FILES)
endif()

This removes the "Unknown CMake command" error, but clock_gettime is not available on Mac OS. See this question for alternatives.

Community
  • 1
  • 1
rocambille
  • 15,398
  • 12
  • 50
  • 68
  • Thanks Adding include(CheckFunctionExists) stopped the unknown Cmake function error but I still get CMake Error at src/spps/CMakeLists.txt:68 (message): clock_gettime not found I am trying to do this on a Mac and ideas what the Cmake file should look like? – Keith Sloan Oct 31 '16 at 11:49
  • Looks like `clock_gettime` isn't available in Mac OS. See [this question](http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x) for alternatives – rocambille Oct 31 '16 at 12:00
  • Many Thanks saved me a lot of time – Keith Sloan Oct 31 '16 at 15:34