Commit 4d5b6620 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Improve CMake find_package functionality.

Showing with 9 additions and 185 deletions
......@@ -55,48 +55,28 @@ if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
add_subdirectory(oboe)
include_directories (oboe/include)
find_package(BcToolbox)
if(NOT BCTOOLBOX_FOUND)
find_package(bctoolbox CONFIG REQUIRED)
endif()
find_package(Ortp)
if(NOT ORTP_FOUND)
find_package(ortp CONFIG REQUIRED)
endif()
find_package(Mediastreamer2)
if(NOT MEDIASTREAMER2_FOUND)
find_package(Mediastreamer2 CONFIG REQUIRED)
endif()
find_package(Mediastreamer2 5.3.0 REQUIRED)
set(OBOE_INCUDE_DIRS "${PROJECT_SOURCE_DIR}/include")
include_directories(
${MEDIASTREAMER2_INCLUDE_DIRS}
${OBOE_INCUDE_DIRS}
)
set(LIBS ${MEDIASTREAMER2_LIBRARIES} oboe ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
set(SOURCE_FILES msoboe.cpp msoboe_player.cpp msoboe_recorder.cpp)
set(MS2_PLUGINS_DIR "${MEDIASTREAMER2_PLUGINS_LOCATION}")
if(BUILD_SHARED_LIBS)
add_library(msoboe MODULE ${SOURCE_FILES})
else()
add_library(msoboe STATIC ${SOURCE_FILES})
endif()
target_link_libraries(msoboe ${LIBS})
target_include_directories(msoboe PRIVATE
oboe/include
include
)
target_link_libraries(msoboe PRIVATE ${Mediastreamer2_TARGET} oboe)
install(TARGETS msoboe
RUNTIME DESTINATION ${MS2_PLUGINS_DIR}
LIBRARY DESTINATION ${MS2_PLUGINS_DIR}
ARCHIVE DESTINATION ${MS2_PLUGINS_DIR}
RUNTIME DESTINATION ${Mediastreamer2_PLUGINS_DIR}
LIBRARY DESTINATION ${Mediastreamer2_PLUGINS_DIR}
ARCHIVE DESTINATION ${Mediastreamer2_PLUGINS_DIR}
FRAMEWORK DESTINATION Frameworks
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
############################################################################
# FindBctoolbox.cmake
# Copyright (C) 2023 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the bctoolbox include files and library
#
# BCTOOLBOX_FOUND - System has lib bctoolbox
# BCTOOLBOX_INCLUDE_DIRS - The bctoolbox include directories
# BCTOOLBOX_LIBRARIES - The libraries needed to use bctoolbox
# BCTOOLBOX_CMAKE_DIR - The bctoolbox cmake directory
# BCTOOLBOX_CORE_FOUND - System has core bctoolbox
# BCTOOLBOX_CORE_INCLUDE_DIRS - The core bctoolbox include directories
# BCTOOLBOX_CORE_LIBRARIES - The core bctoolbox libraries
# BCTOOLBOX_TESTER_FOUND - System has bctoolbox tester
# BCTOOLBOX_TESTER_INCLUDE_DIRS - The bctoolbox tester include directories
# BCTOOLBOX_TESTER_LIBRARIES - The bctoolbox tester libraries
if(TARGET bctoolbox)
set(BCTOOLBOX_CORE_LIBRARIES bctoolbox)
get_target_property(BCTOOLBOX_CORE_INCLUDE_DIRS bctoolbox INTERFACE_INCLUDE_DIRECTORIES)
set(BCTOOLBOX_CORE_FOUND TRUE)
get_target_property(BCTOOLBOX_SOURCE_DIR bctoolbox SOURCE_DIR)
set(BCTOOLBOX_CMAKE_DIR "${BCTOOLBOX_SOURCE_DIR}/../cmake")
if(TARGET bctoolbox-tester)
set(BCTOOLBOX_TESTER_LIBRARIES bctoolbox-tester)
get_target_property(BCTOOLBOX_TESTER_INCLUDE_DIRS bctoolbox-tester INTERFACE_INCLUDE_DIRECTORIES)
set(BCTOOLBOX_TESTER_FOUND TRUE)
set(BCTOOLBOX_TESTER_COMPONENT_VARIABLES BCTOOLBOX_TESTER_FOUND BCTOOLBOX_TESTER_INCLUDE_DIRS BCTOOLBOX_TESTER_LIBRARIES)
endif()
set(BCTOOLBOX_LIBRARIES ${BCTOOLBOX_CORE_LIBRARIES} ${BCTOOLBOX_TESTER_LIBRARIES})
set(BCTOOLBOX_INCLUDE_DIRS ${BCTOOLBOX_CORE_INCLUDE_DIRS} ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BcToolbox
DEFAULT_MSG
BCTOOLBOX_INCLUDE_DIRS BCTOOLBOX_LIBRARIES BCTOOLBOX_CMAKE_DIR
BCTOOLBOX_CORE_FOUND BCTOOLBOX_CORE_INCLUDE_DIRS BCTOOLBOX_CORE_LIBRARIES
${BCTOOLBOX_TESTER_COMPONENT_VARIABLES}
)
mark_as_advanced(
BCTOOLBOX_INCLUDE_DIRS BCTOOLBOX_LIBRARIES BCTOOLBOX_CMAKE_DIR
BCTOOLBOX_CORE_FOUND BCTOOLBOX_CORE_INCLUDE_DIRS BCTOOLBOX_CORE_LIBRARIES
${BCTOOLBOX_TESTER_COMPONENT_VARIABLES}
)
endif()
############################################################################
# FindMediastreamer2.cmake
# Copyright (C) 2023 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the mediastreamer2 include files and library
#
# MEDIASTREAMER2_FOUND - system has lib mediastreamer2
# MEDIASTREAMER2_INCLUDE_DIRS - the mediasteamer2 include directory
# MEDIASTREAMER2_LIBRARIES - The library needed to use mediasteamer2
# MEDIASTREAMER2_PLUGINS_LOCATION - The location of the mediastreamer2 plugins
if(TARGET mediastreamer2)
set(MEDIASTREAMER2_LIBRARIES mediastreamer2)
get_target_property(MEDIASTREAMER2_INCLUDE_DIRS mediastreamer2 INTERFACE_INCLUDE_DIRECTORIES)
define_property(TARGET PROPERTY "MS2_PLUGINS" BRIEF_DOCS "Stores the location of mediastreamer2 plugins" FULL_DOCS "Stores the location of mediastreamer2 plugins")
get_target_property(MEDIASTREAMER2_PLUGINS_LOCATION mediastreamer2 MS2_PLUGINS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Mediastreamer2
DEFAULT_MSG
MEDIASTREAMER2_INCLUDE_DIRS MEDIASTREAMER2_LIBRARIES
)
mark_as_advanced(MEDIASTREAMER2_INCLUDE_DIRS MEDIASTREAMER2_LIBRARIES)
endif()
############################################################################
# FindOrtp.cmake
# Copyright (C) 2023 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the ortp include files and library
#
# ORTP_FOUND - system has lib ortp
# ORTP_INCLUDE_DIRS - the ortp include directory
# ORTP_LIBRARIES - The library needed to use ortp
if(TARGET ortp)
set(ORTP_LIBRARIES ortp)
get_target_property(ORTP_INCLUDE_DIRS ortp INTERFACE_INCLUDE_DIRECTORIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Ortp
DEFAULT_MSG
ORTP_INCLUDE_DIRS ORTP_LIBRARIES
)
mark_as_advanced(ORTP_INCLUDE_DIRS ORTP_LIBRARIES)
endif()
Supports Markdown
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