# Find PolyVox includes and library
#
# This module defines
#  POLYVOXCORE_INCLUDE_DIR
#  POLYVOXCORE_LIBRARIES, the libraries to link against to use PolyVoxCore.
#  POLYVOXCORE_LIB_DIR, the location of the libraries
#  POLYVOXCORE_FOUND, If false, do not try to use PolyVoxCore
#  POLYVOXUTIL_INCLUDE_DIR
#  POLYVOXUTIL_LIBRARIES, the libraries to link against to use PolyVoxUtil.
#  POLYVOXUTIL_LIB_DIR, the location of the libraries
#  POLYVOXUTIL_FOUND, If false, do not try to use PolyVoxUtil
#
# Copyright © 2007, Matt Williams
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

IF (POLYVOXCORE_LIBRARIES AND POLYVOXCODE_INCLUDE_DIR AND POLYVOXUTIL_LIBRARIES AND POLYVOXUTIL_INCLUDE_DIR)
	SET(POLYVOX_FIND_QUIETLY TRUE) # Already in cache, be silent
ENDIF (POLYVOXCORE_LIBRARIES AND POLYVOXCODE_INCLUDE_DIR AND POLYVOXUTIL_LIBRARIES AND POLYVOXUTIL_INCLUDE_DIR)

IF (WIN32) #Windows
	MESSAGE(STATUS "Looking for PolyVox")
	SET(POLYVOX_HOME_EXISTS $ENV{POLYVOX_HOME})
	IF (POLYVOX_HOME_EXISTS)
		SET(POLYVOXCORE_INCLUDE_DIR $ENV{POLYVOX_HOME}/PolyVoxCore/include)
		SET(POLYVOXCORE_LIB_DIR $ENV{POLYVOX_HOME}/PolyVoxCore/lib)
		SET(POLYVOXUTIL_INCLUDE_DIR $ENV{POLYVOX_HOME}/PolyVoxUtil/include)
		SET(POLYVOXUTIL_LIB_DIR $ENV{POLYVOX_HOME}/PolyVoxUtil/lib)
		SET(POLYVOX_LIBRARIES debug PolyVoxCore_d debug PolyVoxUtil_d optimized PolyVoxCore optimized PolyVoxUtil)
	ENDIF (POLYVOX_HOME_EXISTS)
ELSE (WIN32) #Unix
	MESSAGE(STATUS "PolyVox check not written for Unix yet")
	#CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
	#FIND_PACKAGE(PkgConfig)
	#PKG_SEARCH_MODULE(OGRE OGRE)
	#SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
	#SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
	#SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
ENDIF (WIN32)

#Do some preparation
#SEPARATE_ARGUMENTS(POLYVOX_INCLUDE_DIR)
#SEPARATE_ARGUMENTS(POLYVOX_LIBRARIES)

SET(POLYVOXCORE_INCLUDE_DIR ${POLYVOXCORE_INCLUDE_DIR} CACHE PATH "")
SET(POLYVOXCORE_LIBRARIES ${POLYVOXCORE_LIBRARIES} CACHE STRING "")
SET(POLYVOXCORE_LIB_DIR ${POLYVOXCORE_LIB_DIR} CACHE PATH "")

SET(POLYVOXUTIL_INCLUDE_DIR ${POLYVOXUTIL_INCLUDE_DIR} CACHE PATH "")
SET(POLYVOXUTIL_LIBRARIES ${POLYVOXUTIL_LIBRARIES} CACHE STRING "")
SET(POLYVOXUTIL_LIB_DIR ${POLYVOXUTIL_LIB_DIR} CACHE PATH "")

IF (POLYVOXCORE_LIBRARIES AND POLYVOXCODE_INCLUDE_DIR AND POLYVOXUTIL_LIBRARIES AND POLYVOXUTIL_INCLUDE_DIR)
	SET(POLYVOX_FOUND TRUE)
ENDIF (POLYVOXCORE_LIBRARIES AND POLYVOXCODE_INCLUDE_DIR AND POLYVOXUTIL_LIBRARIES AND POLYVOXUTIL_INCLUDE_DIR)

IF (POLYVOX_FOUND)
	IF (NOT POLYVOX_FIND_QUIETLY)
		MESSAGE(STATUS "  libraries : ${POLYVOXCORE_LIBRARIES} from ${POLYVOXCORE_LIB_DIR} and ${POLYVOXUTIL_LIBRARIES} from ${POLYVOXUTIL_LIB_DIR}")
		MESSAGE(STATUS "  includes  : ${POLYVOXCORE_INCLUDE_DIR} and ${POLYVOXUTIL_INCLUDE_DIR}")
	ENDIF (NOT POLYVOX_FIND_QUIETLY)
ELSE (POLYVOX_FOUND)
	IF (POLYVOX_FIND_REQUIRED)
		MESSAGE(FATAL_ERROR "Could not find PolyVox")
	ENDIF (POLYVOX_FIND_REQUIRED)
ENDIF (POLYVOX_FOUND)
