Commit e58cda7e authored by Ghislain MARY's avatar Ghislain MARY

Improve CMake scripts.

parent c1facb03
......@@ -46,9 +46,9 @@ if(MSVC)
endif()
include(CheckIncludeFile)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(CheckIncludeFile)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("memory.h" HAVE_MEMORY_H)
......@@ -61,14 +61,14 @@ check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_include_file("stdbool.h" HAVE_STDBOOL_H)
find_package(Ortp)
find_package(Mediastreamer2)
find_package(ORTP)
find_package(MS2)
find_package(OpenH264)
if(NOT ORTP_FOUND)
message(FATAL "Could not find oRTP headers/library!")
endif()
if(NOT MEDIASTREAMER2_FOUND)
if(NOT MS2_FOUND)
message(FATAL "Could not find mediastreamer2 headers/library!")
endif()
if(NOT OPENH264_FOUND)
......@@ -80,8 +80,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY
include_directories(
${MS2_INCLUDE_DIR}
${OPENH264_INCLUDE_DIR}
${MS2_INCLUDE_DIRS}
${OPENH264_INCLUDE_DIRS}
src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
......
############################################################################
# FindMediastreamer2.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the mediastreamer2 include file and library
#
# MS2_FOUND - system has mediastreamer2
# MS2_INCLUDE_DIR - the mediastreamer2 include directory
# MS2_LIBRARIES - The libraries needed to use mediastreamer2
if(UNIX)
find_package(PkgConfig)
pkg_check_modules(PC_MS2 QUIET mediastreamer>=2.7.0)
endif()
set(_MS2_ROOT_PATHS
${WITH_MS2}
${CMAKE_INSTALL_PREFIX}
)
find_path(MS2_INCLUDE_DIR
NAMES mediastreamer2/mscommon.h
HINTS _MS2_ROOT_PATHS
PATH_SUFFIXES include
)
if(NOT "${MS2_INCLUDE_DIR}" STREQUAL "")
set(HAVE_MEDIASTREAMER2_MSCOMMON_H 1)
find_library(MS2_BASE_LIBRARIES
NAMES mediastreamer_base
HINTS ${_MS2_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
find_library(MS2_VOIP_LIBRARIES
NAMES mediastreamer_voip
HINTS ${_MS2_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
set(MS2_LIBRARIES ${MS2_BASE_LIBRARIES} ${MS2_VOIP_LIBRARIES})
if(NOT "${MS2_LIBRARIES}" STREQUAL "")
set(MS2_FOUND TRUE)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(mediastreamer2
REQUIRED_VARS
MS2_LIBRARIES
MS2_INCLUDE_DIR
FAIL_MESSAGE
"Could NOT find mediastreamer2"
)
mark_as_advanced(MS2_INCLUDE_DIR MS2_LIBRARIES)
......@@ -23,12 +23,10 @@
# - Find the openh264 include file and library
#
# OPENH264_FOUND - system has openh264
# OPENH264_INCLUDE_DIR - the openh264 include directory
# OPENH264_INCLUDE_DIRS - the openh264 include directory
# OPENH264_LIBRARIES - The libraries needed to use openh264
if("${CMAKE_VERSION}" VERSION_GREATER "2.8.5")
include(CMakePushCheckState)
endif("${CMAKE_VERSION}" VERSION_GREATER "2.8.5")
include(CMakePushCheckState)
include(CheckCXXSymbolExists)
set(_OPENH264_ROOT_PATHS
......@@ -36,40 +34,36 @@ set(_OPENH264_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(OPENH264_INCLUDE_DIR
find_path(OPENH264_INCLUDE_DIRS
NAMES wels/codec_api.h
HINTS _OPENH264_ROOT_PATHS
PATH_SUFFIXES include
)
if(NOT "${OPENH264_INCLUDE_DIR}" STREQUAL "")
if(OPENH264_INCLUDE_DIRS)
set(HAVE_WELS_CODEC_API_H 1)
endif()
find_library(OPENH264_LIBRARIES
NAMES openh264
HINTS _OPENH264_ROOT_PATHS
PATH_SUFFIXES bin lib
)
find_library(OPENH264_LIBRARIES
NAMES openh264
HINTS _OPENH264_ROOT_PATHS
PATH_SUFFIXES bin lib
)
if(NOT "${OPENH264_LIBRARIES}" STREQUAL "")
if("${CMAKE_VERSION}" VERSION_GREATER "2.8.5")
cmake_push_check_state(RESET)
else()
set(SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
set(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
endif()
set(CMAKE_REQUIRED_INCLUDES ${OPENH264_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENH264_LIBRARIES})
check_cxx_symbol_exists("WelsCreateDecoder" "wels/codec_api.h" HAVE_WELS_CREATE_DECODER)
if("${CMAKE_VERSION}" VERSION_GREATER "2.8.5")
cmake_pop_check_state()
else()
set(CMAKE_REQUIRED_INCLUDES ${SAVE_CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
endif()
if(HAVE_WELS_CREATE_DECODER)
set(OPENH264_FOUND TRUE)
endif()
if(OPENH264_LIBRARIES)
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENH264_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${OPENH264_LIBRARIES})
check_cxx_symbol_exists("WelsCreateDecoder" "wels/codec_api.h" HAVE_WELS_CREATE_DECODER)
cmake_pop_check_state()
if(HAVE_WELS_CREATE_DECODER)
set(OPENH264_FOUND TRUE)
endif()
endif()
mark_as_advanced(OPENH264_INCLUDE_DIR OPENH264_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenH264
DEFAULT_MSG
OPENH264_INCLUDE_DIRS OPENH264_LIBRARIES HAVE_WELS_CODEC_API_H HAVE_WELS_CREATE_DECODER
)
mark_as_advanced(OPENH264_INCLUDE_DIRS OPENH264_LIBRARIES HAVE_WELS_CODEC_API_H HAVE_WELS_CREATE_DECODER)
############################################################################
# FindOrtp.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the oRTP include file and library
#
# ORTP_FOUND - system has oRTP
# ORTP_INCLUDE_DIR - the oRTP include directory
# ORTP_LIBRARIES - The libraries needed to use oRTP
if(UNIX)
find_package(PkgConfig)
pkg_check_modules(PC_ORTP QUIET ortp>=0.23.0)
endif()
set(_ORTP_ROOT_PATHS
${WITH_ORTP}
${CMAKE_INSTALL_PREFIX}
)
find_path(ORTP_INCLUDE_DIR
NAMES ortp/ortp.h
HINTS _ORTP_ROOT_PATHS
PATH_SUFFIXES include
)
if(NOT "${ORTP_INCLUDE_DIR}" STREQUAL "")
set(HAVE_ORTP_ORTP_H 1)
find_library(ORTP_LIBRARIES
NAMES ortp
HINTS ${_ORTP_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
if(NOT "${ORTP_LIBRARIES}" STREQUAL "")
set(ORTP_FOUND TRUE)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ortp
REQUIRED_VARS
ORTP_LIBRARIES
ORTP_INCLUDE_DIR
FAIL_MESSAGE
"Could NOT find oRTP"
)
mark_as_advanced(ORTP_INCLUDE_DIR ORTP_LIBRARIES)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment