
SUBDIRS(nvcore)
SUBDIRS(nvmath)
SUBDIRS(nvimage)
SUBDIRS(nvtt)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

# initial variables
SET(GLUT TRUE CACHE BOOL "")
SET(GLEW TRUE CACHE BOOL "")
SET(CG TRUE CACHE BOOL "")
SET(CUDA TRUE CACHE BOOL "")
SET(OPENEXR TRUE CACHE BOOL "")

# OpenGL
INCLUDE(FindOpenGL)
IF(OPENGL_FOUND)
	MESSAGE(STATUS "Looking for OpenGL - found")
ELSE(OPENGL_FOUND)
	MESSAGE(STATUS "Looking for OpenGL - not found")
ENDIF(OPENGL_FOUND)

# GLUT
IF(GLUT)
	INCLUDE(${NV_CMAKE_DIR}/FindGLUT.cmake)
	#INCLUDE(FindGLUT)
	IF(GLUT_FOUND)
		MESSAGE(STATUS "Looking for GLUT - found")
	ELSE(GLUT_FOUND)
		MESSAGE(STATUS "Looking for GLUT - not found")
	ENDIF(GLUT_FOUND)
ENDIF(GLUT)

# DirectX
INCLUDE(${NV_CMAKE_DIR}/FindDirectX.cmake)
IF(DX10_FOUND)
	MESSAGE(STATUS "Looking for DirectX - found")
ELSE(DX10_FOUND)
	MESSAGE(STATUS "Looking for DirectX - not found")
ENDIF(DX10_FOUND)

# GLEW
IF(GLEW)
	INCLUDE(${NV_CMAKE_DIR}/FindGLEW.cmake)
	IF(GLEW_FOUND)
		MESSAGE(STATUS "Looking for GLEW - found")
	ELSE(GLEW_FOUND)
		MESSAGE(STATUS "Looking for GLEW - not found")
	ENDIF(GLEW_FOUND)
ENDIF(GLEW)

# Cg
IF(CG)
	INCLUDE(${NV_CMAKE_DIR}/FindCg.cmake)
	IF(CG_FOUND)
		MESSAGE(STATUS "Looking for Cg - found")
	ELSE(CG_FOUND)
		MESSAGE(STATUS "Looking for Cg - not found")
	ENDIF(CG_FOUND)
ENDIF(CG)

# CUDA
IF(CUDA)
	INCLUDE(${NV_CMAKE_DIR}/FindCUDA.cmake)
	IF(CUDA_FOUND)
		SET(HAVE_CUDA ${CUDA_FOUND} CACHE BOOL "Set to TRUE if CUDA is found, FALSE otherwise")
		MESSAGE(STATUS "Looking for CUDA - found")
	ELSE(CUDA_FOUND)
		MESSAGE(STATUS "Looking for CUDA - not found")
	ENDIF(CUDA_FOUND)
ENDIF(CUDA)

# Maya
INCLUDE(${NV_CMAKE_DIR}/FindMaya.cmake)
IF(MAYA_FOUND)
	SET(HAVE_MAYA ${MAYA_FOUND} CACHE BOOL "Set to TRUE if Maya is found, FALSE otherwise")
	MESSAGE(STATUS "Looking for Maya - found")
ELSE(MAYA_FOUND)
	MESSAGE(STATUS "Looking for Maya - not found")
ENDIF(MAYA_FOUND)

# JPEG
INCLUDE(FindJPEG)
IF(JPEG_FOUND)
	SET(HAVE_JPEG ${JPEG_FOUND} CACHE BOOL "Set to TRUE if JPEG is found, FALSE otherwise")
	MESSAGE(STATUS "Looking for JPEG - found")
ELSE(JPEG_FOUND)
	MESSAGE(STATUS "Looking for JPEG - not found")
ENDIF(JPEG_FOUND)

# PNG
INCLUDE(FindPNG)
IF(PNG_FOUND)
	SET(HAVE_PNG ${PNG_FOUND} CACHE BOOL "Set to TRUE if PNG is found, FALSE otherwise")
	MESSAGE(STATUS "Looking for PNG - found")
ELSE(PNG_FOUND)
	MESSAGE(STATUS "Looking for PNG - not found")
ENDIF(PNG_FOUND)

# TIFF
INCLUDE(FindTIFF)
IF(TIFF_FOUND)
	SET(HAVE_TIFF ${TIFF_FOUND} CACHE BOOL "Set to TRUE if TIFF is found, FALSE otherwise")
	MESSAGE(STATUS "Looking for TIFF - found")
ELSE(TIFF_FOUND)
	MESSAGE(STATUS "Looking for TIFF - not found")
ENDIF(TIFF_FOUND)

# OpenEXR
IF(OPENEXR)
	INCLUDE(${NV_CMAKE_DIR}/FindOpenEXR.cmake)
	IF(OPENEXR_FOUND)
		SET(HAVE_OPENEXR ${OPENEXR_FOUND} CACHE BOOL "Set to TRUE if OpenEXR is found, FALSE otherwise")
		MESSAGE(STATUS "Looking for OpenEXR - found")
	ELSE(OPENEXR_FOUND)
		MESSAGE(STATUS "Looking for OpenEXR - not found")
	ENDIF(OPENEXR_FOUND)
ENDIF(OPENEXR)

# Qt
FIND_PACKAGE(Qt4)

# Threads
FIND_PACKAGE(Threads REQUIRED)
MESSAGE(STATUS "Use thread library: ${CMAKE_THREAD_LIBS_INIT}")

# configuration file
INCLUDE(CheckIncludeFiles)

CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES(stdarg.h HAVE_STDARG_H)
CHECK_INCLUDE_FILES(signal.h HAVE_SIGNAL_H)
CHECK_INCLUDE_FILES(execinfo.h HAVE_EXECINFO_H)
CHECK_INCLUDE_FILES(malloc.h HAVE_MALLOC_H)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/nvconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/nvconfig.h)

#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/nvconfig.h DESTINATION include)

