CMakeLists.txt 3.78 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
#
############################################################################

if(NOT CPACK_PACKAGE_NAME)
24
	set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
25
endif()
26

27
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Toolbox package used by Belledonne Communications projects")
jehan's avatar
jehan committed
28
set(CPACK_PACKAGE_VENDOR "Belledonne Communications")
29
set(CPACK_PACKAGE_CONTACT "jehan.monnier@linphone.org")
30

jehan's avatar
jehan committed
31
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../COPYING")
32

33 34 35
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
36

37
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION})
jehan's avatar
jehan committed
38

39
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
40
set(CPACK_SOURCE_GENERATOR "TGZ")
41
set(CPACK_SOURCE_IGNORE_FILES
42 43
"^${CMAKE_BINARY_DIR}"
"^${PROJECT_SOURCE_DIR}/\\\\.git.*"
44
)
jehan's avatar
jehan committed
45

jehan's avatar
jehan committed
46 47 48 49
#set(CPACK_COMPONENTS_ALL runtime devel)
#set(CPACK_COMPONENT_DEVEL_DEPENDS runtime)
#set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME ${PACKAGE})
#set(CPACK_COMPONENT_DEVEL_DISPLAY_NAME ${PACKAGE}-devel)
jehan's avatar
jehan committed
50

51
find_package(Git 1.7.10) # --count option of git rev-list is available only since (more or less) git 1.7.10
52 53 54 55 56
if(GIT_EXECUTABLE)
	execute_process(
		COMMAND ${GIT_EXECUTABLE} rev-list --count ${PROJECT_VERSION}..HEAD
		OUTPUT_VARIABLE PROJECT_VERSION_BUILD
		OUTPUT_STRIP_TRAILING_WHITESPACE
57
		WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
58 59 60
	)
	# if BUILD VERSION is available, append it to package filename
	set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${PROJECT_VERSION_BUILD}")
61 62 63

	set(CPACK_RPM_PACKAGE_RELEASE "${PROJECT_VERSION_BUILD}")
	set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_BUILD}")
64 65
endif()

66
set(CPACK_RPM_COMPONENT_INSTALL OFF)
67
if("${CPACK_GENERATOR}" STREQUAL "RPM")
68
	set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)
69
endif()
jehan's avatar
jehan committed
70

71 72 73
if("${CPACK_GENERATOR}" STREQUAL "RPM" OR "${CPACK_GENERATOR}" STREQUAL "DEB")
	if (NOT CPACK_PACKAGING_INSTALL_PREFIX AND CMAKE_INSTALL_PREFIX)
		set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
Ghislain MARY's avatar
Ghislain MARY committed
74
		message(STATUS "Setting packaging install prefix to ${CPACK_PACKAGING_INSTALL_PREFIX}")
75 76 77
	endif()
endif()

jehan's avatar
jehan committed
78
if("${CPACK_GENERATOR}" STREQUAL "DEB")
79
	set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
80
	set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
81 82
	set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackEnv.cmake")
	file(WRITE "${CPACK_PROJECT_CONFIG_FILE}" "set(ENV{LD_LIBRARY_PATH} \"./${CMAKE_INSTALL_FULL_LIBDIR}\")")
jehan's avatar
jehan committed
83
	set(SHLIBS_FILE     "${CMAKE_CURRENT_BINARY_DIR}/shlibs")
84
	file(WRITE "${SHLIBS_FILE}" "libbctoolbox  ${BCTOOLBOX_SO_VERSION} ${CPACK_PACKAGE_NAME}\n")
85
	file(APPEND "${SHLIBS_FILE}" "libbctoolbox-tester  ${BCTOOLBOXTESTER_SO_VERSION} ${CPACK_PACKAGE_NAME}\n")
jehan's avatar
jehan committed
86 87 88 89
	execute_process(COMMAND chmod 644 "${SHLIBS_FILE}")
	set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${SHLIBS_FILE})
endif()

90
include(CPack)