INCLUDE(FindPkgConfig OPTIONAL)

IF(PKG_CONFIG_FOUND)
	INCLUDE(FindPkgConfig)
	PKG_CHECK_MODULES(LIBSRTP srtp)
ENDIF(PKG_CONFIG_FOUND)

IF(NOT LIBSRTP_FOUND)
	FIND_PATH(LIBSRTP_INCLUDE_DIR srtp/srtp.h
		/usr/local/include
		/usr/include
	)

	FIND_LIBRARY(LIBSRTP_LIBRARY_DIR
		NAMES srtp
		PATH
		/usr/local/lib
		/usr/local/lib64
		/usr/lib
		/usr/lib64
	)
	MESSAGE(STATUS "Found LIBSRTP: ${LIBSRTP_LIBRARY_DIR} ${LIBSRTP_INCLUDE_DIR}")
ENDIF(NOT LIBSRTP_FOUND)

IF(LIBSRTP_LIBRARY_DIR AND LIBSRTP_INCLUDE_DIR)
	SET(LIBSRTP_FOUND TRUE)
ENDIF(LIBSRTP_LIBRARY_DIR AND LIBSRTP_INCLUDE_DIR)

IF(NOT LIBSRTP_FOUND)
	IF(LIBSRTP_FIND_REQUIRED)
		MESSAGE(FATAL_ERROR "Could not find LIBSRTP")
	ENDIF(LIBSRTP_FIND_REQUIRED)
ENDIF(NOT LIBSRTP_FOUND)
