Commit b8170864 authored by Ghislain MARY's avatar Ghislain MARY

Allow compilation with CMake.

parent c3f6c23e
############################################################################
# CMakeLists.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.
#
############################################################################
cmake_minimum_required(VERSION 2.8)
project(MSOPENH264 C)
enable_language(CXX)
set(PACKAGE "msopenh264")
set(PACKAGE_NAME "${PACKAGE}")
set(PACKAGE_VERSION "1.0")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "support@belledonne-communications.com")
set(PACKAGE_TARNAME "msopenh264")
set(PACKAGE_URL "")
set(VERSION "${PACKAGE_VERSION}")
set(WITH_OPENH264 "${CMAKE_INSTALL_PREFIX}" CACHE STRING "Set prefix where libopenh264 can be found (ex:/usr or /usr/local)")
include(CheckIncludeFile)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
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(Mediastreamer2)
find_package(OpenH264)
if(NOT MEDIASTREAMER2_FOUND)
message(WARNING "Could not find mediastreamer2 headers/library!")
endif()
if(NOT OPENH264_FOUND)
message(WARNING "Could not find openh264 headers/library!")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(
src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
)
add_definitions(-DHAVE_CONFIG_H)
if(NOT MSVC)
add_definitions(-Wall -Wno-error=unknown-pragmas)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-Werror -Wno-error=unknown-warning-option)
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
add_definitions(-Werror -Wno-error=pragmas)
endif()
endif(NOT MSVC)
add_subdirectory(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_DIRS - the mediastreamer2 include directory
# MS2_LIBRARIES - The libraries needed to use mediastreamer2
if(UNIX)
find_package(PkgConfig)
pkg_check_modules(_CUNIT QUIET cunit)
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)
############################################################################
# FindOpenH264.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 openh264 include file and library
#
# OPENH264_FOUND - system has openh264
# OPENH264_INCLUDE_DIR - 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(CheckLibraryExists)
set(_OPENH264_ROOT_PATHS
${WITH_OPENH264}
${CMAKE_INSTALL_PREFIX}
)
find_path(OPENH264_INCLUDE_DIR
NAMES wels/codec_api.h
HINTS _OPENH264_ROOT_PATHS
PATH_SUFFIXES include
)
if(NOT "${OPENH264_INCLUDE_DIR}" STREQUAL "")
set(HAVE_WELS_CODEC_API_H 1)
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_library_exists(${OPENH264_LIBRARIES} "WelsCreateDecoder" "" 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()
endif()
endif()
mark_as_advanced(OPENH264_INCLUDE_DIR OPENH264_LIBRARIES)
############################################################################
# CMakeLists.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.
#
############################################################################
set(INCLUDES ${OPENH264_INCLUDE_DIR})
set(LIBS ${OPENH264_LIBRARIES})
if(WIN32)
list(APPEND LIBS ws2_32)
endif()
set(SOURCE_FILES
msopenh264.cpp
msopenh264dec.cpp
msopenh264enc.cpp
)
add_library(msopenh264 SHARED ${SOURCE_FILES})
set_target_properties(msopenh264 PROPERTIES VERSION ${PACKAGE_VERSION} SOVERSION 0)
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/msopenh264.pdb
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
set_target_properties(msopenh264 PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LINK_FLAGS}")
if("${CMAKE_VERSION}" VERSION_GREATER "2.8.10")
target_include_directories(msopenh264 PUBLIC ${INCLUDES})
else()
include_directories(${INCLUDES})
endif()
target_link_libraries(msopenh264 ${LIBS})
install(TARGETS msopenh264
RUNTIME DESTINATION lib/mediastreamer/plugins
LIBRARY DESTINATION lib/mediastreamer/plugins
ARCHIVE DESTINATION lib/mediastreamer/plugins
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
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