#
# Copyright (C) 2013	Emmanuel Roullit <emmanuel.roullit@gmail.com>
#

IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
  FIND_PROGRAM(DPKG_CMD dpkg)
  IF(NOT DPKG_CMD)
    EXECUTE_PROCESS(COMMAND uname -p
      OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    MESSAGE(STATUS "Can not find dpkg in your path, default to uname -p: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.")
  ELSE(NOT DPKG_CMD)
    EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
      OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )
  ENDIF(NOT DPKG_CMD)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
