
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES(${NV_SOURCE_DIR}/extern/poshlib)
INCLUDE_DIRECTORIES(${NV_SOURCE_DIR}/extern/stb)

SUBDIRS(nvcore)
SUBDIRS(nvmath)
SUBDIRS(nvimage)
SUBDIRS(nvthread)
SUBDIRS(nvtt)
SUBDIRS(bc6h)
SUBDIRS(bc7)

# 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
#INCLUDE(FindGLUT)
#IF(GLUT_FOUND)
#	MESSAGE(STATUS "Looking for GLUT - found")
#ELSE(GLUT_FOUND)
#	MESSAGE(STATUS "Looking for GLUT - not found")
#ENDIF(GLUT_FOUND)

# 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
#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)

# 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)

# CUDA
FIND_PACKAGE(CUDA)
IF(CUDA_FOUND)
    IF(MINGW)
        MESSAGE(STATUS "Looking for CUDA - not supported on MinGW")
        UNSET(CUDA_FOUND)
    ENDIF(MINGW)
    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")
    ENDIF(CUDA_FOUND)
ELSE(CUDA_FOUND)
    MESSAGE(STATUS "Looking for CUDA - not found")
ENDIF(CUDA_FOUND)

# 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)

# FreeImage
#INCLUDE(${NV_CMAKE_DIR}/FindFreeImage.cmake)
#IF(FREEIMAGE_FOUND)
#	SET(HAVE_FREEIMAGE ${FREEIMAGE_FOUND} CACHE BOOL "Set to TRUE if FreeImage is found, FALSE otherwise")
#	MESSAGE(STATUS "Looking for FreeImage - found")
#ELSE(FREEIMAGE_FOUND)
#	MESSAGE(STATUS "Looking for FreeImage - not found")
#ENDIF(FREEIMAGE_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
#SET(TIFF_NAMES libtiff)
#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
#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)

# OpenMP
INCLUDE(FindOpenMP)
IF(OPENMP_FOUND)
	SET(HAVE_OPENMP ${OPENMP_FOUND} CACHE BOOL "Set to TRUE if OpenMP is found, FALSE otherwise")
	MESSAGE(STATUS "Looking for OpenMP - found")
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ELSE(OPENMP_FOUND)
	MESSAGE(STATUS "Looking for OpenMP - not found")
ENDIF(OPENMP_FOUND)
	
# Threads
FIND_PACKAGE(Threads REQUIRED)
MESSAGE(STATUS "Use thread library: ${CMAKE_THREAD_LIBS_INIT}")
SET(LIBS ${LIBS} ${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)
CHECK_INCLUDE_FILES("dispatch/dispatch.h" HAVE_DISPATCH_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)

