sof/scripts/cmake/dist.cmake

22 lines
900 B
CMake

# SPDX-License-Identifier: BSD-3-Clause
# depends on version.cmake
# Adds dist target
set(TARBALL_PATH_TMP "${PROJECT_BINARY_DIR}/sof-${GIT_TAG}.tar")
set(TARBALL_PATH "${PROJECT_BINARY_DIR}/sof-${GIT_TAG}.tgz")
set(TARBALL_VERSION_BINARY_PATH "${PROJECT_BINARY_DIR}/${TARBALL_VERSION_FILE_NAME}")
add_custom_target(dist
COMMAND git archive -o "${TARBALL_PATH_TMP}" HEAD
COMMAND ${CMAKE_COMMAND} -E echo "${GIT_TAG}" > "${TARBALL_VERSION_BINARY_PATH}"
COMMAND ${CMAKE_COMMAND} -E echo "${GIT_LOG_HASH}" >> "${TARBALL_VERSION_BINARY_PATH}"
COMMAND tar rf "${TARBALL_PATH_TMP}" -C "${PROJECT_BINARY_DIR}" "${TARBALL_VERSION_FILE_NAME}"
COMMAND gzip -9 < "${TARBALL_PATH_TMP}" > "${TARBALL_PATH}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMENT "Creating tarball: ${TARBALL_PATH}"
BYPRODUCTS "$TARBALL_VERSION_BINARY_PATH" "${TARBALL_PATH_TMP}" "${TARBALL_PATH}"
VERBATIM
USES_TERMINAL
)