PROJECT(GNUGo)

INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/times.h HAVE_SYS_TIMES_H)
CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES("sys/time.h;time.h" TIME_WITH_SYS_TIME)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES(curses.h HAVE_CURSES_H)
CHECK_INCLUDE_FILES(glib.h HAVE_GLIB_H)
CHECK_INCLUDE_FILES(ncurses/curses.h HAVE_NCURSES_CURSES_H)
CHECK_INCLUDE_FILES(ncurses/term.h HAVE_NCURSES_TERM_H)
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(term.h HAVE_TERM_H)
CHECK_INCLUDE_FILES(crtdbg.h HAVE_CRTDBG_H)
CHECK_INCLUDE_FILES("winsock.h;io.h" HAVE_WINSOCK_IO_H)

INCLUDE(CheckTypeSize)
CHECK_TYPE_SIZE(long SIZEOF_LONG)

INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(times HAVE_TIMES)
CHECK_FUNCTION_EXISTS(usleep HAVE_USLEEP)
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
# FIXME: Probably necessary to add the glib library for this test to pass.
CHECK_FUNCTION_EXISTS(g_vsnprintf HAVE_G_VSNPRINTF)

SET(PRAGMAS "")
IF(WIN32)
    SET(PRAGMAS "#pragma warning(disable: 4244 4305)")
ENDIF(WIN32)

IF(MSVC80)
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
    ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
ENDIF(MSVC80)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/config.h)

# Make sure all files know about and can find config.h
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

# Recurse into subdirectories.
ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(sgf)
ADD_SUBDIRECTORY(engine)
ADD_SUBDIRECTORY(patterns)
ADD_SUBDIRECTORY(interface)
