# -*- cmake -*-

# - Find FMODSTUDIO
# Find the FMODSTUDIO includes and library
# This module defines
#  FMODSTUDIO_INCLUDE_DIR, where to find fmod.h and fmod_errors.h
#  FMODSTUDIO_LIBRARIES, the libraries needed to use FMODSTUDIO.
#  FMODSTUDIO, If false, do not try to use FMODSTUDIO.
# also defined, but not for general use are
#  FMODSTUDIO_LIBRARY, where to find the FMODSTUDIO library.

FIND_PATH(FMODSTUDIO_INCLUDE_DIR fmod.h PATH_SUFFIXES fmod)

SET(FMODSTUDIO_NAMES ${FMODSTUDIO_NAMES} fmod fmod_vc)
FIND_LIBRARY(FMODSTUDIO_LIBRARY
  NAMES ${FMODSTUDIO_NAMES}
  PATH_SUFFIXES fmod
  )

IF (FMODSTUDIO_SDK_DIR OR WINDOWS)
    if(WINDOWS)
        set(FMODSTUDIO_SDK_DIR "$ENV{PROGRAMFILES}/FMOD SoundSystem/FMOD Programmers API Windows" CACHE PATH "Path to FMODSTUDIO")
        STRING(REGEX REPLACE "\\\\" "/" FMODSTUDIO_SDK_DIR ${FMODSTUDIO_SDK_DIR}) 
    endif(WINDOWS)
    find_library(FMODSTUDIO_LIBRARY
             fmod_vc fmodL_vc 
             PATHS
             ${FMODSTUDIO_SDK_DIR}/api/lib
             ${FMODSTUDIO_SDK_DIR}/api
             ${FMODSTUDIO_SDK_DIR}
             )
    find_path(FMODSTUDIO_INCLUDE_DIR fmod.h
        ${FMODSTUDIO_SDK_DIR}/api/inc
        ${FMODSTUDIO_SDK_DIR}/api
        ${FMODSTUDIO_SDK_DIR}
      )
    find_path(FMODSTUDIO_INCLUDE_DIR fmod.h
        ${FMODSTUDIO_SDK_DIR}/api/inc
        ${FMODSTUDIO_SDK_DIR}/api
        ${FMODSTUDIO_SDK_DIR}
      )
    IF (FMODSTUDIO_LIBRARY AND FMODSTUDIO_INCLUDE_DIR)
      SET(FMODSTUDIO_LIBRARIES ${FMODSTUDIO_LIBRARY})
      SET(FMODSTUDIO_FOUND "YES")
    endif (FMODSTUDIO_LIBRARY AND FMODSTUDIO_INCLUDE_DIR)
ENDIF (FMODSTUDIO_SDK_DIR OR WINDOWS)

IF (FMODSTUDIO_FOUND)
  IF (NOT FMODSTUDIO_FIND_QUIETLY)
    MESSAGE(STATUS "Found FMODSTUDIO: ${FMODSTUDIO_LIBRARIES}")
  ENDIF (NOT FMODSTUDIO_FIND_QUIETLY)
ELSE (FMODSTUDIO_FOUND)
  IF (FMODSTUDIO_FIND_REQUIRED)
    MESSAGE(FATAL_ERROR "Could not find FMODSTUDIO library")
  ENDIF (FMODSTUDIO_FIND_REQUIRED)
ENDIF (FMODSTUDIO_FOUND)

# Deprecated declarations.
SET (NATIVE_FMODSTUDIO_INCLUDE_PATH ${FMODSTUDIO_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_FMODSTUDIO_LIB_PATH ${FMODSTUDIO_LIBRARY} PATH)

MARK_AS_ADVANCED(
  FMODSTUDIO_LIBRARY
  FMODSTUDIO_INCLUDE_DIR
  )
