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

jehan's avatar
jehan committed
23
set(CPACK_PACKAGE_NAME "ortp")
jehan's avatar
jehan committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../COPYING")

set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})

set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION})

set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
"${CMAKE_BINARY_DIR}"
"^${PROJECT_SOURCE_DIR}/.git*"
)
jehan's avatar
jehan committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
find_program (WC wc)

if (WC)
        set(GIT_MINIMUN_VERSION 1.7.1) #might be even lower
else()
        set(GIT_MINIMUN_VERSION 1.7.10) # --count option of git rev-list is available only since (more or less) git 1.7.10)
endif()

find_package(Git ${GIT_MINIMUN_VERSION})
string(COMPARE GREATER "${GIT_VERSION_STRING}" "1.7.10" GIT_REV_LIST_HAS_COUNT)

if (GIT_REV_LIST_HAS_COUNT)
        set(GIT_REV_LIST_COMMAND "${GIT_EXECUTABLE}" "rev-list" "--count" "${PROJECT_VERSION}..HEAD")
        set(WC_COMMAND )
else()
        set(GIT_REV_LIST_COMMAND "${GIT_EXECUTABLE}" "rev-list" "${PROJECT_VERSION}..HEAD")
        set(WC_COMMAND "${WC}"  "-l")
endif()

jehan's avatar
jehan committed
57 58
if(GIT_EXECUTABLE)
        execute_process(
jehan's avatar
jehan committed
59 60
                COMMAND ${GIT_REV_LIST_COMMAND}
                COMMAND ${WC_COMMAND}
jehan's avatar
jehan committed
61
                OUTPUT_VARIABLE PROJECT_VERSION_BUILD
jehan's avatar
jehan committed
62
		OUTPUT_STRIP_TRAILING_WHITESPACE
jehan's avatar
jehan committed
63 64 65 66
                WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
        )
        # if BUILD VERSION is available, append it to package filename
        set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${PROJECT_VERSION_BUILD}")
jehan's avatar
jehan committed
67
	message("Package file name is ${CPACK_PACKAGE_FILE_NAME}" )
jehan's avatar
jehan committed
68
endif()
jehan's avatar
jehan committed
69
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
jehan's avatar
jehan committed
70 71 72

include(CPack)