summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2023-03-30 10:39:50 +0300
committerPanu Matilainen <pmatilai@redhat.com>2023-03-30 11:52:59 +0300
commit4f2627e08bf2880a5d16f62a675bba87d027035a (patch)
tree520004f2657b16c9d585da266f9081a9b7f56cb0
parent909e0aeec642e5925ad5200c60612018d72cd582 (diff)
downloadrpm-4f2627e08bf2880a5d16f62a675bba87d027035a.tar.gz
Restore snapshot make target in cmake
Refactor the dist rule into a slightly more generic function that we can call with suitable values for generating dist and snapshot tarballs. This includes preliminaries for requiring a tag for dist tarball but that involves further complications so not done yet. Local HEAD is not exactly the right thing to be building dist tarballs from.
-rw-r--r--CMakeLists.txt36
1 files changed, 24 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5b974276..387990b8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -390,15 +390,27 @@ install(DIRECTORY DESTINATION ${RPMCONFIGDIR}/lua)
install(DIRECTORY DESTINATION ${RPMCONFIGDIR}/macros.d)
install(FILES CONTRIBUTING.md COPYING CREDITS INSTALL README TYPE DOC)
-set(namever ${PROJECT_NAME}-${PROJECT_VERSION})
-set(distfmt tar.gz)
-set(distname ${namever}.${distfmt})
-add_custom_command(OUTPUT ${distname}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMAND git archive
- --format=${distfmt}
- --output=${CMAKE_BINARY_DIR}/${distname}
- --prefix=${namever}/
- HEAD
-)
-add_custom_target(dist DEPENDS ${distname})
+function(add_tarball targetname namever treeish)
+ set(distfmt tar.gz)
+ set(tarname ${namever}.${distfmt})
+ add_custom_command(OUTPUT ${tarname}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMAND git archive
+ --format=${distfmt}
+ --output=${CMAKE_BINARY_DIR}/${tarname}
+ --prefix=${namever}/
+ ${treeish}
+ )
+ add_custom_target(${targetname} DEPENDS ${tarname})
+endfunction()
+
+add_tarball(dist ${PROJECT_NAME}-${PROJECT_VERSION} HEAD)
+
+if (EXISTS ${CMAKE_SOURCE_DIR}/.git)
+ execute_process(COMMAND git rev-list --count HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE gitcount
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ add_tarball(snapshot
+ ${PROJECT_NAME}-${PROJECT_VERSION}-git${gitcount} HEAD)
+endif()