2
0

CM_linux_packages.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # determine the version number from the #define in libyuv/version.h
  2. EXECUTE_PROCESS (
  3. COMMAND grep --perl-regex --only-matching "(?<=LIBYUV_VERSION )[0-9]+" include/libyuv/version.h
  4. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  5. OUTPUT_VARIABLE YUV_VERSION_NUMBER
  6. OUTPUT_STRIP_TRAILING_WHITESPACE )
  7. SET ( YUV_VER_MAJOR 0 )
  8. SET ( YUV_VER_MINOR 0 )
  9. SET ( YUV_VER_PATCH ${YUV_VERSION_NUMBER} )
  10. SET ( YUV_VERSION ${YUV_VER_MAJOR}.${YUV_VER_MINOR}.${YUV_VER_PATCH} )
  11. MESSAGE ( "Building ver.: ${YUV_VERSION}" )
  12. # is this a 32-bit or 64-bit build?
  13. IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  14. SET ( YUV_BIT_SIZE 64 )
  15. ELSEIF ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
  16. SET ( YUV_BIT_SIZE 32 )
  17. ELSE ()
  18. MESSAGE ( FATAL_ERROR "CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" )
  19. ENDIF ()
  20. # detect if this is a ARM build
  21. STRING (FIND "${CMAKE_CXX_COMPILER}" "arm-linux-gnueabihf-g++" pos)
  22. IF ( ${pos} EQUAL -1 )
  23. SET ( YUV_CROSS_COMPILE_FOR_ARM7 FALSE )
  24. ELSE ()
  25. MESSAGE ( "Cross compiling for ARM7" )
  26. SET ( YUV_CROSS_COMPILE_FOR_ARM7 TRUE )
  27. ENDIF ()
  28. STRING (FIND "${CMAKE_SYSTEM_PROCESSOR}" "arm" pos)
  29. IF ( ${pos} EQUAL -1 )
  30. SET ( YUV_COMPILE_FOR_ARM7 FALSE )
  31. ELSE ()
  32. MESSAGE ( "Compiling for ARM" )
  33. SET ( YUV_COMPILE_FOR_ARM7 TRUE )
  34. ENDIF ()
  35. # setup the sytem name, such as "x86-32", "amd-64", and "arm-32
  36. IF ( ${YUV_CROSS_COMPILE_FOR_ARM7} OR ${YUV_COMPILE_FOR_ARM7} )
  37. SET ( YUV_SYSTEM_NAME "armhf-${YUV_BIT_SIZE}" )
  38. ELSE ()
  39. IF ( YUV_BIT_SIZE EQUAL 32 )
  40. SET ( YUV_SYSTEM_NAME "x86-${YUV_BIT_SIZE}" )
  41. ELSE ()
  42. SET ( YUV_SYSTEM_NAME "amd-${YUV_BIT_SIZE}" )
  43. ENDIF ()
  44. ENDIF ()
  45. MESSAGE ( "Packaging for: ${YUV_SYSTEM_NAME}" )
  46. # define all the variables needed by CPack to create .deb and .rpm packages
  47. SET ( CPACK_PACKAGE_VENDOR "Frank Barchard" )
  48. SET ( CPACK_PACKAGE_CONTACT "fbarchard@chromium.org" )
  49. SET ( CPACK_PACKAGE_VERSION ${YUV_VERSION} )
  50. SET ( CPACK_PACKAGE_VERSION_MAJOR ${YUV_VER_MAJOR} )
  51. SET ( CPACK_PACKAGE_VERSION_MINOR ${YUV_VER_MINOR} )
  52. SET ( CPACK_PACKAGE_VERSION_PATCH ${YUV_VER_PATCH} )
  53. SET ( CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE )
  54. SET ( CPACK_SYSTEM_NAME "linux-${YUV_SYSTEM_NAME}" )
  55. SET ( CPACK_PACKAGE_NAME "libyuv" )
  56. SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "YUV library" )
  57. SET ( CPACK_PACKAGE_DESCRIPTION "YUV library and YUV conversion tool" )
  58. SET ( CPACK_DEBIAN_PACKAGE_SECTION "other" )
  59. SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
  60. SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Frank Barchard <fbarchard@chromium.org>" )
  61. SET ( CPACK_GENERATOR "DEB;RPM" )
  62. # create the .deb and .rpm files (you'll need build-essential and rpm tools)
  63. INCLUDE( CPack )