CMakeLists.txt 3.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# 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
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22
#
############################################################################

23
cmake_minimum_required(VERSION 3.0)
Ghislain MARY's avatar
Ghislain MARY committed
24
project(bcg729 VERSION 1.0.4 LANGUAGES C)
25 26


27 28 29
set(PACKAGE "${PROJECT_NAME}")
set(PACKAGE_NAME "${PROJECT_NAME}")
set(PACKAGE_VERSION "${PROJECT_VERSION}")
30 31 32 33 34 35 36
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "support@belledonne-communications.com")
set(PACKAGE_TARNAME "bcg729")
set(PACKAGE_URL "")
set(VERSION "${PACKAGE_VERSION}")


37 38
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
39
option(ENABLE_TESTS "Enable compilation of the tests." NO)
40 41

include(GNUInstallDirs)
42 43 44 45 46 47 48 49


include_directories(
	include
	src
	${CMAKE_CURRENT_BINARY_DIR}
	${CMAKE_CURRENT_BINARY_DIR}/src
)
50 51 52 53
set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
if(MSVC)
	include_directories(${MSVC_INCLUDE_DIR})
endif()
54

55 56 57 58 59 60
set(BCG729_CPPFLAGS )
if(ENABLE_STATIC)
	set(BCG729_STATIC 1)
	list(APPEND BCG729_CPPFLAGS "-DBCG729_STATIC")
endif()

61 62 63 64
add_definitions(-DHAVE_CONFIG_H)
if(MSVC)
	add_definitions("/W3")
else()
65 66 67 68
	add_definitions("-Wall")
	if (NOT IOS)
		add_definitions("-Werror")
	endif()
Peter Wu's avatar
Peter Wu committed
69
	add_definitions("-fvisibility=hidden")
70 71
endif()

72 73 74
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)

add_subdirectory(include)
75
add_subdirectory(src)
76
if(ENABLE_TESTS)
jehan's avatar
jehan committed
77
	add_subdirectory(test)
78
endif()
79 80


81 82 83 84 85 86 87 88 89 90 91 92 93 94
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	"${CMAKE_CURRENT_BINARY_DIR}/Bcg729ConfigVersion.cmake"
	VERSION ${PACKAGE_VERSION}
	COMPATIBILITY AnyNewerVersion
)
export(EXPORT Bcg729Targets
	FILE "${CMAKE_CURRENT_BINARY_DIR}/Bcg729Targets.cmake"
)
configure_file(Bcg729Config.cmake.in
	"${CMAKE_CURRENT_BINARY_DIR}/Bcg729Config.cmake"
	@ONLY
)

95 96 97 98 99 100 101 102 103 104 105 106 107
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(includedir  "\${prefix}/include")
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
configure_file(libbcg729.pc.in
	"${CMAKE_CURRENT_BINARY_DIR}/libbcg729.pc"
	@ONLY
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/libbcg729.pc"
	DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

108 109 110 111 112 113 114 115 116 117
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/Bcg729/cmake")
install(EXPORT Bcg729Targets
	FILE Bcg729Targets.cmake
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/Bcg729Config.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/Bcg729ConfigVersion.cmake"
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
118

Ghislain MARY's avatar
Ghislain MARY committed
119
add_subdirectory(build)
120