CMakeLists.txt 2.91 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) 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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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
#
############################################################################

cmake_minimum_required(VERSION 3.0)
project(LINPHONE_PACKAGE) # Dummy project

#find_package(Linphone REQUIRED)
find_package(Git)

if(GIT_EXECUTABLE)
	execute_process(
		COMMAND ${GIT_EXECUTABLE} describe --always
		OUTPUT_VARIABLE LINPHONE_GIT_REVISION
		OUTPUT_STRIP_TRAILING_WHITESPACE
		WORKING_DIRECTORY ${LINPHONE_SOURCE_DIR}
	)
else()
	set(LINPHONE_GIT_REVISION "0.0.0")
endif()
string(REGEX REPLACE "([0-9.]+)-?.*" "\\1" LINPHONE_VERSION "${LINPHONE_GIT_REVISION}")
string(REPLACE "." ";" SPLITTED_LINPHONE_VERSION ${LINPHONE_VERSION})
list(GET SPLITTED_LINPHONE_VERSION 0 LINPHONE_MAJOR_VERSION)
list(GET SPLITTED_LINPHONE_VERSION 1 LINPHONE_MINOR_VERSION)
list(GET SPLITTED_LINPHONE_VERSION 2 LINPHONE_MICRO_VERSION)
set(PACKAGE_VERSION "${LINPHONE_VERSION}")

# Prepare the tarball
set(LINPHONE_SDK_TMP "${CMAKE_CURRENT_BINARY_DIR}/linphone-raspberry")
file(REMOVE_RECURSE "${LINPHONE_SDK_TMP}")
file(COPY "${LINPHONE_OUTPUT_DIR}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/desktop-raspberry" "${LINPHONE_SDK_TMP}")
file(REMOVE_RECURSE "${LINPHONE_SDK_TMP}/etc")
file(REMOVE_RECURSE "${LINPHONE_SDK_TMP}/sbin")
file(REMOVE_RECURSE "${LINPHONE_SDK_TMP}/share/doc")
file(REMOVE_RECURSE "${LINPHONE_SDK_TMP}/share/java")
file(REMOVE_RECURSE "${LINPHONE_SDK_TMP}/share/man")
file(GLOB FILES_TO_DELETE
	"${LINPHONE_SDK_TMP}/bin/cx18*"
	"${LINPHONE_SDK_TMP}/bin/decode_tm*"
	"${LINPHONE_SDK_TMP}/bin/dvb*"
	"${LINPHONE_SDK_TMP}/bin/ir-*"
	"${LINPHONE_SDK_TMP}/bin/ivtv*"
	"${LINPHONE_SDK_TMP}/bin/rds-*"
)
file(REMOVE ${FILES_TO_DELETE})

# Generate the tarball containing the output of the build
add_custom_target(create_tar ALL COMMAND
68
	${CMAKE_COMMAND} -E tar "cvjf" "linphone-raspberry-pi${RASPBERRY_VERSION}-${LINPHONE_GIT_REVISION}.tar.bz2" "${LINPHONE_SDK_TMP}"
69 70
)

71
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/linphone-raspberry-pi${RASPBERRY_VERSION}-${LINPHONE_GIT_REVISION}.tar.bz2" DESTINATION .)