$ cat libexample.c
#include <math.h>
double c_nextafter(int argc, void* argv[]) {
  return nextafter(*(double*)argv[0], *(double*)argv[1]);
}

$ cat CMakeLists.txt
project(libexaple C)
cmake_minimum_required(VERSION 2.0)
add_library(example SHARED libexample.c) 
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES 
  "Makefile;CMakeCache.txt;cmake_install.cmake;CMakeFiles")

$ cmake .
-- The C compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deploy...
-- Checking whether C compiler supports OSX deploy...
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- w...
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/slayoo...

$ make
Scanning dependencies of target example
[100%] Building C object CMakeFiles/example.dir/libexample.o
Linking C shared library libexample.dylib
[100%] Built target example

% $MAIN$: 1d308 vs. a next representable double:
  1.0000000000000000E+308
  1.0000000000000002E+308
