CMakeLists.txt 3.44 KB
Newer Older
Ghislain MARY's avatar
Ghislain MARY committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# CMakeLists.txt
# Copyright (C) 2016  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
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Ghislain MARY's avatar
Ghislain MARY committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#
############################################################################

cmake_minimum_required(VERSION 3.0)
project(MSCODEC2 VERSION 0.1 LANGUAGES C)


option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)


include(GNUInstallDirs)

if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
	set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
	message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

40 41 42 43
find_package(Mediastreamer2 CONFIG REQUIRED)
find_package(bctoolbox CONFIG REQUIRED)
find_package(ortp CONFIG REQUIRED)

Ghislain MARY's avatar
Ghislain MARY committed
44 45 46 47 48 49 50 51
find_package(Codec2 REQUIRED)


include_directories(
	${MEDIASTREAMER2_INCLUDE_DIRS}
	${CODEC2_INCLUDE_DIRS}
)

Benjamin REIS's avatar
Benjamin REIS committed
52
set(LIBS ${MEDIASTREAMER2_LIBRARIES} ${CODEC2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
Ghislain MARY's avatar
Ghislain MARY committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

set(SOURCE_FILES mscodec2.c)

if(ENABLE_STATIC)
	add_library(mscodec2-static STATIC ${SOURCE_FILES})
	set_target_properties(mscodec2-static PROPERTIES OUTPUT_NAME mscodec2)
	target_link_libraries(mscodec2-static ${LIBS})
	install(TARGETS mscodec2-static
		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
	)
endif()
if(ENABLE_SHARED)
68 69 70 71 72
	if(NOT IOS)
		add_library(mscodec2 MODULE ${SOURCE_FILES})
	else()
		add_library(mscodec2 SHARED ${SOURCE_FILES})
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
73
	target_link_libraries(mscodec2 ${LIBS})
74
	if(IOS)
75 76
		set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET})
		set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/osx/")
77 78
		set_target_properties(mscodec2 PROPERTIES
			FRAMEWORK TRUE
79 80
			MACOSX_FRAMEWORK_IDENTIFIER org.linphone.mscodec2
  			MACOSX_FRAMEWORK_INFO_PLIST Info.plist.in
81 82
		) 
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
83 84 85 86 87 88 89 90 91 92
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/libmscodec2.pdb
				DESTINATION bin
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
		set_target_properties(mscodec2 PROPERTIES PREFIX "lib")
	endif()
	install(TARGETS mscodec2
93 94 95 96
		RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/mediastreamer/plugins
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mediastreamer/plugins
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/mediastreamer/plugins
		FRAMEWORK DESTINATION Frameworks
Ghislain MARY's avatar
Ghislain MARY committed
97 98 99
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()