﻿# - Locate FMOD library
# This module defines
#  FMODEX_LIBRARY, the library to link against
#  FMODEX_FOUND, if false, do not try to link to FMOD
#  FMODEX_INCLUDE_DIR, where to find headers.
#
#
# This file was taken from RakNet 4.082.
# Please see licenses/RakNet license.txt for the underlying license and related copyright.
#
#
#
#  Modified work: Copyright (c) 2016, SLikeSoft UG (haftungsbeschränkt)
#
# This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
#  license found in the license.txt file in the root directory of this source tree.
#

IF(FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
	# in cache already
	SET(FMODEX_FIND_QUIETLY TRUE)
ENDIF(FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)


FIND_PATH(FMODEX_INCLUDE_DIR
	fmod.h
	PATHS
	$ENV{FMODEX_DIR}/include
	/usr/local/include
	/usr/include
	/sw/include
	/opt/local/include
	/opt/csw/include
	/opt/include
	/usr/local/include/fmodex
	/usr/include/fmodex
	/sw/include/fmodex
	/opt/local/include/fmodex
	/opt/csw/include/fmodex
	/opt/include/fmodex
	"${PROGRAMFILESX86}/FMOD SoundSystem/FMOD Programmers API Win32/api/inc"
	PATH_SUFFIXES fmod fmod3
)

set(WINLIBNAME " ")
set(WINLIBEXT " ")

IF(WIN32 AND NOT UNIX)
	IF (MSVC)
		set(WINLIBNAME fmodex_vc)
		set(WINLIBEXT "lib")
	ENDIF(MSVC)
	IF(CMAKE_GENERATOR MATCHES "Borland Makefiles")
		set(WINLIBNAME fmodex_bc)
		set(WINLIBEXT "lib")
	ENDIF()
	IF(CMAKE_GENERATOR MATCHES "MinGW Makefiles")
		set(WINLIBNAME libfmodex)
		set(WINLIBEXT "a")
	ENDIF()
ENDIF(WIN32 AND NOT UNIX)

set(LINUXLIBS libfmodex)

IF(UNIX AND NOT WIN32)
	set(LINUXADDLIBS "")

	set (PASTVERSIONS 4.44.59 4.44.58 4.44.57 4.44.56 4.44.55 4.44.54 4.44.53 4.44.52 4.44.51 4.44.50 4.44.49 4.44.48 4.44.47 4.44.46 4.44.45 4.44.44 4.44.43 4.44.42 4.44.41 4.44.40 4.44.39 4.44.38 4.44.37 4.44.36 4.44.35 4.44.34 4.44.33 4.44.32 4.44.31 4.44.30 4.44.29 4.44.28 4.44.27 4.44.26 4.44.25 4.44.24 4.44.23 4.44.22 4.44.21 4.44.20 4.44.19 4.44.18 4.44.17 4.44.16 4.44.15 4.44.14 4.44.13 4.44.12 4.44.11 4.44.10 4.44.09 4.44.08 4.44.07 4.44.06 4.44.06 4.44.05 4.44.04 4.44.03 4.44.02 4.44.01 4.44.00 4.42.22 4.42.21 4.42.20 4.42.19 4.42.18 4.42.17 4.42.16 4.42.15 4.42.14 4.42.13 4.42.12 4.42.11 4.42.10 4.42.09 4.42.08 4.42.07 4.42.06 4.42.05 4.42.04 4.42.03 4.42.02 4.42.01 4.42.00 4.40.30 4.40.29 4.40.28 4.40.27 4.40.26 4.40.25 4.40.24 4.40.23 4.40.23 4.40.22 4.40.21 4.40.20 4.40.19 4.40.18 4.40.17 4.40.16 4.40.15 4.40.14 4.40.13 4.40.12 4.40.11 4.40.10 4.40.09 4.40.08 4.40.07 4.40.06 4.40.05 4.40.04 4.40.03 4.40.02 4.40.01 4.40.00 4.38.24 4.38.23 4.38.22 4.38.21 4.38.20 4.38.19 4.38.18 4.38.17 4.38.16 4.38.15 4.38.14 4.38.13 4.38.12 4.38.11 4.38.10 4.38.09 4.38.08 4.38.07 4.38.06 4.38.05 4.38.04 4.38.03 4.38.02 4.38.01 4.38.00 4.36.23 4.36.22 4.36.21 4.36.20 4.36.19 4.36.18 4.36.17 4.36.16 4.36.15 4.36.14 4.36.13 4.36.12 4.36.11 4.36.10 4.36.09 4.36.08 4.36.07 4.36.06 4.36.05 4.36.04 4.36.03 4.36.02 4.36.01 4.36.00 4.34.05 4.30.22 4.28.08 4.28.07 4.28.06 4.28.05 4.28.04 4.28.03 4.28.02 4.28.01 4.28.00 4.27.10 4.27.09 4.27.08 4.27.07 4.27.06 4.27.05 4.27.04 4.27.03 4.27.02 4.27.01 4.27.00 4.25.00 4.23.00 4.21.00 4.19.00 4.17.00 4.15.00 4.13.00 4.11.00 4.09.07 4.09.06 4.09.05 4.09.04 4.09.03 4.09.02 4.09.01 4.08.00 4.07.25 4.07.24 4.07.23 4.07.22 4.07.21 4.07.20 4.07.19 4.07.18 4.07.17 4.07.16 4.07.15 4.07.14 4.07.13 4.07.12 4.07.11 4.07.10 4.07.09 4.07.08 4.07.07 4.07.06 4.07.05 4.07.04 4.07.03 4.07.02 4.07.01 4.07.00 4.06.00 4.04.53 4.04.51 4.04.49 4.04.47 4.04.45 4.04.43 4.04.41 4.04.39 4.04.37 4.04.35 4.04.33 4.04.31 4.04.29 4.04.28 4.04.27 4.04.26 4.04.25 4.04.24 4.04.23 4.04.21 4.04.20 4.04.19 4.04.18 4.04.17 4.04.16 4.04.15 4.04.14 4.04.13 4.04.12 4.04.11 4.04.10 4.04.08 4.04.06 4.04.04 4.04.02 4.04.00 4.03.10 4.03.09 4.03.08 4.03.07 4.03.06 4.03.05 4.03.04 4.03.03 4.03.02 4.03.01 4.03.00 4.02.10 4.02.09 4.02.08 4.02.07 4.02.06 4.02.05 4.02.04 4.02.03 4.02.02 4.02.01 4.02.00 4.01.07 4.01.06 4.01.05 4.01.04 4.01.03 4.01.02 4.01.01 4.01.00 4.00.37 4.00.36 4.00.35 4.00.34 4.00.33 4.00.32 4.00.31 4.00.30 4.00.29 4.00.28 4.00.27 4.00.26 4.00.25 4.00.24 4.00.23 4.00.22 4.00.21 4.00.20 4.00.19 4.00.18 4.00.17 4.00.16 4.00.14 4.00.13 4.00.12 4.00.11 4.00.10 4.00.09 4.00.08 4.00.07 4.00.06 4.00.05 4.00.04 4.00.03 4.00.02 4.00.01)

	#add existing supported versions
	FOREACH (CURRENTVERSION ${PASTVERSIONS})
		set(LINUXADDLIBS ${LINUXADDLIBS} libfmodex-${CURRENTVERSION}.so)
	ENDFOREACH(CURRENTVERSION)

	set(LINUXLIBS ${LINUXLIBS} ${LINUXADDLIBS})
ENDIF(UNIX AND NOT WIN32)

FIND_LIBRARY(FMODEX_LIBRARY
	NAMES ${LINUXLIBS} ${WINLIBNAME}
	PATHS
	$ENV{FMODEX_DIR}/lib
	/usr/local/lib
	/usr/lib
	/usr/local/X11R6/lib
	/usr/X11R6/lib
	/sw/lib
	/opt/local/lib
	/opt/csw/lib
	/opt/lib
	"${PROGRAMFILESX86}/FMOD SoundSystem/FMOD Programmers API Win32/api/lib"
	/usr/freeware/lib64
)

IF(FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
	SET(FMODEX_FOUND "YES")
	IF(NOT FMODEX_FIND_QUIETLY)
		MESSAGE(STATUS "Found FMOD EX: ${FMODEX_LIBRARY}")
	ENDIF(NOT FMODEX_FIND_QUIETLY)
ELSE(FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
	IF(NOT FMODEX_FIND_QUIETLY)
		MESSAGE(STATUS "Warning: Unable to find FMOD EX!")
	ENDIF(NOT FMODEX_FIND_QUIETLY)
ENDIF(FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
