a helpful template for cmake if you are trying to upgrade a project which uses autoconf

in #programminglast year

I just wish to share part of a large cmake file im working on to handle the process of converting an an old project (this is kind of part of the protomuck thing) to a newer cmake backed format.

INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckStructHasMember.cmake)
CHECK_INCLUDE_FILE("dirent.h" HAVE_DIRENT_H)
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE("malloc.h" HAVE_MALLOC_H)
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
CHECK_INCLUDE_FILE("mysql/mysql.h" HAVE_MYSQL_MYSQL_H)
CHECK_INCLUDE_FILE("ndir.h" HAVE_NDIR_H)
CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H)
CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILE("sys/dir.h" HAVE_SYS_DIR_H)
CHECK_INCLUDE_FILE("sys/errno.h" HAVE_SYS_ERRNO_H)
CHECK_INCLUDE_FILE("sys/malloc.h" HAVE_SYS_MALLOC_H)
CHECK_INCLUDE_FILE("sys/ndir.h" HAVE_SYS_NDIR_H)
CHECK_INCLUDE_FILE("sys/resource.h" HAVE_SYS_RESOURCE_H)
CHECK_INCLUDE_FILE("sys/signal.h" HAVE_SYS_SIGNAL_H)
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE("timebits.h" HAVE_TIMEBITS_H)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
CHECK_INCLUDE_FILE("varargs.h" HAVE_VARARGS_H)
CHECK_INCLUDE_FILE("sys/time.h" TIME_WITH_SYS_TIME)
CHECK_INCLUDE_FILE("sys/time.h" TM_IN_SYS_TIME)
CHECK_INCLUDE_FILE("sys/types.h" gid_t)
CHECK_INCLUDE_FILE("sys/types.h" pid_t)
CHECK_INCLUDE_FILE("sys/types.h" size_t)
CHECK_INCLUDE_FILE("sys/types.h" gid_t)
CHECK_TYPE_SIZE("int"   SIZEOF_INT)
CHECK_TYPE_SIZE("long int"   SIZEOF_LONG_INT)
check_symbol_exists(vprintf stdio.h HAVE_VPRINTF)
check_symbol_exists(vsnprintf stdio.h HAVE_VSNPRINTF)
check_symbol_exists(setproctitle sys/types.h unistd.h HAVE_SETPROCTITLE)
check_symbol_exists(random stdlib.h HAVE_RANDOM)

this sniplet is part of a larger file. I just wanted to share the parts which i believe are not specific to my project in case it might help others when upgrading old source code projects to the new cmake build system.