Write basic FindLibWebRTC.cmake file

This commit is contained in:
Axel Isouard 2017-01-29 18:25:47 +01:00
parent fdbbed3bb2
commit a15061d9d4
No known key found for this signature in database
GPG key ID: 4E64BB3EAAF31C29

View file

@ -1,13 +1,60 @@
find_path(LIBWEBRTC_INCLUDE_DIR typedefs.h # - Try to find LibWebRTC
HINTS # Once done this will define
ENV LIBWEBRTCDIR # LIBWEBRTC_FOUND - System has LibWebRTC
PATH_SUFFIXES webrtc # LIBWEBRTC_INCLUDE_DIRS - The LibWebRTC include directories
include/webrtc include) # LIBWEBRTC_LIBRARIES - The libraries needed to use LibWebRTC
# LIBWEBRTC_DEFINITIONS - Compiler switches required for using LibWebRTC
find_library(LIBWEBRTC_LIBRARY if (LibWebRTC_FIND_QUIETLY)
NAMES webrtc set(_FIND_FLAGS QUIET)
HINTS endif (LibWebRTC_FIND_QUIETLY)
ENV LIBWEBRTCDIR
PATH_SUFFIXES lib)
mark_as_advanced(LIBWEBRTC_LIBRARY LIBWEBRTC_INCLUDE_DIR) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED ${_FIND_FLAGS})
if (APPLE)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(COREAUDIO_LIBRARY CoreAudio)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
find_library(COREGRAPHICS_LIBRARY CoreGraphics)
find_library(FOUNDATION_LIBRARY Foundation)
elseif (UNIX)
find_package(X11 REQUIRED ${_FIND_FLAGS})
endif (APPLE)
if (WIN32)
set(LIBWEBRTC_DEFINITIONS -DWEBRTC_WIN -DNOMINMAX)
elseif (UNIX)
set(LIBWEBRTC_DEFINITIONS -DWEBRTC_POSIX -std=gnu++0x -D_GLIBCXX_USE_CXX11_ABI=0)
endif (WIN32)
find_path(LIBWEBRTC_INCLUDE_DIR libwebrtc.h
HINTS ${PC_LIBXML_INCLUDEDIR} ${PC_LIBXML_INCLUDE_DIRS}
PATH_SUFFIXES libwebrtc)
find_library(LIBWEBRTC_LIBRARY NAMES webrtc
HINTS ${PC_LIBXML_LIBDIR} ${PC_LIBXML_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibWebRTC DEFAULT_MSG
LIBWEBRTC_LIBRARY LIBWEBRTC_INCLUDE_DIR)
if (LIBWEBRTC_FOUND)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARY} Threads::Threads)
if (WIN32)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARIES} msdmo.lib wmcodecdspuuid.lib
dmoguids.lib ole32.lib secur32.lib)
elseif (APPLE)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARIES}
${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY} ${COREFOUNDATION_LIBRARY}
${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY})
elseif (UNIX)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARIES} ${X11_LIBRARIES}
${CMAKE_DL_LIBS})
endif (WIN32)
set(LIBWEBRTC_INCLUDE_DIRS ${LIBWEBRTC_INCLUDE_DIR})
endif()
mark_as_advanced(LIBWEBRTC_INCLUDE_DIR LIBWEBRTC_LIBRARY)