CMakeLists.txt 4.28 KB
Newer Older
Ghislain MARY's avatar
Ghislain MARY committed
1 2
############################################################################
# CMakeLists.txt
Ronan's avatar
Ronan committed
3
# Copyright (C) 2016-2018  Belledonne Communications, Grenoble France
Ghislain MARY's avatar
Ghislain MARY committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
############################################################################
#
# 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
#
############################################################################

Sandrine Avakian's avatar
Sandrine Avakian committed
23 24
cmake_minimum_required(VERSION 3.0)

Ghislain MARY's avatar
Ghislain MARY committed
25
project(BV16 VERSION 2.1 LANGUAGES C)
26

Ronan's avatar
Ronan committed
27 28
include(GNUInstallDirs)

Sandrine Avakian's avatar
Sandrine Avakian committed
29 30 31
include_directories(${CMAKE_BINARY_DIR} ./bv16)
include_directories(${CMAKE_BINARY_DIR} ./bvcommon)

Ghislain MARY's avatar
Ghislain MARY committed
32 33
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
34
option(ENABLE_TOOLS "Build tools." NO)
Ghislain MARY's avatar
Ghislain MARY committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71


find_library(LIBM NAMES m)


set(BV16_SOURCE_FILES
	bv16/bitpack.c
	bv16/coarptch.c
	bv16/decoder.c
	bv16/encoder.c
	bv16/excdec.c
	bv16/excquan.c
	bv16/fineptch.c
	bv16/gaindec.c
	bv16/gainquan.c
	bv16/levelest.c
	bv16/lspdec.c
	bv16/lspquan.c
	bv16/plc.c
	bv16/postfilt.c
	bv16/ptquan.c
	bv16/tables.c
	bvcommon/a2lsp.c
	bvcommon/allpole.c
	bvcommon/allzero.c
	bvcommon/autocor.c
	bvcommon/cmtables.c
	bvcommon/levdur.c
	bvcommon/lsp2a.c
	bvcommon/ptdec.c
	bvcommon/stblchck.c
	bvcommon/stblzlsp.c
	bvcommon/utility.c
)
set(BROADVOICE16_SOURCE_FILES
	bv16/bv.c
	bv16/g192.c
Sandrine Avakian's avatar
Sandrine Avakian committed
72 73
)

74 75 76
# Levinson method conflicts with AMRWB, so renaming this one
add_definitions("-DLevinson=bv16_Levinson")

Ghislain MARY's avatar
Ghislain MARY committed
77
add_definitions("-DWMOPS=0" "-DG192BITSTREAM=0")
Sandrine Avakian's avatar
Sandrine Avakian committed
78 79 80


if(MSVC)
Ghislain MARY's avatar
Ghislain MARY committed
81
	list(APPEND BV16_SOURCE_FILES bv16.def)
82
	set_source_files_properties(bv16/g192.c PROPERTIES COMPILE_FLAGS "/wd4267") # Disable "possible loss of data" warning
Sandrine Avakian's avatar
Sandrine Avakian committed
83 84
endif(MSVC)

Ghislain MARY's avatar
Ghislain MARY committed
85 86 87
set(LIBS )
if(LIBM)
	list(APPEND LIBS ${LIBM})
Sandrine Avakian's avatar
Sandrine Avakian committed
88 89
endif()

Ghislain MARY's avatar
Ghislain MARY committed
90 91 92 93 94
if(ENABLE_STATIC)
	add_library(bv16-static STATIC ${BV16_SOURCE_FILES})
	set_target_properties(bv16-static PROPERTIES OUTPUT_NAME bv16)
	target_link_libraries(bv16-static ${LIBS})
	install(TARGETS bv16-static
Ronan's avatar
Ronan committed
95 96 97
		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Ghislain MARY's avatar
Ghislain MARY committed
98 99 100 101 102 103 104
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()
if(ENABLE_SHARED)
	add_library(bv16 SHARED ${BV16_SOURCE_FILES})
	target_link_libraries(bv16 ${LIBS})
	install(TARGETS bv16
Ronan's avatar
Ronan committed
105 106 107
		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Ghislain MARY's avatar
Ghislain MARY committed
108 109 110 111 112 113 114 115 116 117
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bv16.pdb
				DESTINATION bin
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
Sandrine Avakian's avatar
Sandrine Avakian committed
118 119
endif()

120 121 122 123 124 125 126 127 128
if(ENABLE_TOOLS)
	add_executable(BroadVoice16 ${BROADVOICE16_SOURCE_FILES})
	if(ENABLE_SHARED)
		target_link_libraries(BroadVoice16 bv16)
	else()
		target_link_libraries(BroadVoice16 bv16-static)
	endif()
	if (NOT IOS)
		install(TARGETS BroadVoice16
Ronan's avatar
Ronan committed
129 130 131
			RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
			LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
			ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
132 133 134
			PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
		)
	endif()
135
endif()
Sandrine Avakian's avatar
Sandrine Avakian committed
136 137 138

file(GLOB BV16_HEADER_FILES "bv16/*.h")
install(FILES ${BV16_HEADER_FILES}
139 140
	DESTINATION include/bv16-floatingpoint/bv16
	PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
Sandrine Avakian's avatar
Sandrine Avakian committed
141 142
)

Ghislain MARY's avatar
Ghislain MARY committed
143
file(GLOB BV16_COMMON_HEADER_FILES "bvcommon/*.h")
Sandrine Avakian's avatar
Sandrine Avakian committed
144
install(FILES ${BV16_COMMON_HEADER_FILES}
145 146
	DESTINATION include/bv16-floatingpoint/bvcommon
	PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
Sandrine Avakian's avatar
Sandrine Avakian committed
147
)
148

Ronan's avatar
Ronan committed
149
add_subdirectory(build)