SET(WIN_DIRECTORIES "")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
	list(APPEND WIN_DIRECTORIES "C:/Program Files/Mega-Nerd/libsndfile")
else()
	list(APPEND WIN_DIRECTORIES "C:/Program Files (x86)/Mega-Nerd/libsndfile")
endif()

FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h
  PATH_SUFFIXES include src
  PATHS
  /usr/local
  /usr
  /sw # Fink
  /opt/local # DarwinPorts
  /opt/csw # Blastwave
  /opt
	${WIN_DIRECTORIES}
  HINTS $ENV{LIBSNDFILE_SRC}
)

FIND_LIBRARY(LIBSNDFILE_LIBRARY_RELEASE
	PATH_SUFFIXES bin lib
  NAMES sndfile libsndfile libsndfile-1
	PATHS ${WIN_DIRECTORIES}
)
if (LIBSNDFILE_LIBRARY_RELEASE)
	list(APPEND LIBSNDFILE_LIBRARY optimized ${LIBSNDFILE_LIBRARY_RELEASE})
endif()

FIND_LIBRARY(LIBSNDFILE_LIBRARY_DEBUG
	PATH_SUFFIXES bin lib
  NAMES sndfile_d libsndfile_d libsndfile-1_d
	PATHS ${WIN_DIRECTORIES}
)
if (LIBSNDFILE_LIBRARY_DEBUG)
	list(APPEND LIBSNDFILE_LIBRARY debug ${LIBSNDFILE_LIBRARY_DEBUG})
else()
#	if (UNIX)
		list(APPEND LIBSNDFILE_LIBRARY debug ${LIBSNDFILE_LIBRARY_RELEASE})
#	endif()
endif()

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSNDFILE DEFAULT_MSG LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
