Home | History | Annotate | Download | only in CMake
      1 # ------------------- Debianization ---------------------
      2 if (UNIX)
      3 
      4     # Set build environment
      5     SET(CPACK_GENERATOR "TGZ;DEB")
      6     SET(CPACK_SOURCE_TGZ "ON")
      7 
      8     # Common package information
      9     SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
     10         "FlatBuffers is an efficient cross platform serialization library for C++, with support for Java, C# and Go. It was created at Google specifically for game development and other performance-critical applications.")
     11     SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
     12     SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Vitaly Isaev <vitalyisaev2 (a] gmail.com>")
     13 
     14     # Derive package version from git
     15     EXECUTE_PROCESS(
     16         COMMAND date +%Y%m%d
     17         OUTPUT_VARIABLE DATE
     18         OUTPUT_STRIP_TRAILING_WHITESPACE
     19     )
     20     EXECUTE_PROCESS(
     21       COMMAND git describe
     22       WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     23       OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
     24       OUTPUT_STRIP_TRAILING_WHITESPACE
     25     )
     26     string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
     27     string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
     28     string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
     29     string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
     30     SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
     31     SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
     32     SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
     33     SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
     34     SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
     35 
     36     # Derive architecture
     37     IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
     38       FIND_PROGRAM(DPKG_CMD dpkg)
     39       IF(NOT DPKG_CMD)
     40         MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
     41         SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
     42       ENDIF(NOT DPKG_CMD)
     43       EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
     44         OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
     45         OUTPUT_STRIP_TRAILING_WHITESPACE
     46         )
     47     ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
     48 
     49     # Package name
     50     SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
     51     SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
     52     SET(CPACK_PACKAGE_FILE_NAME 
     53         "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
     54 
     55 endif(UNIX)
     56 
     57 INCLUDE(CPack)
     58