File: makeDist.cmake

package info (click to toggle)
open-coarrays 2.10.2%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,712 kB
  • sloc: ansic: 11,788; f90: 11,161; sh: 3,745; makefile: 81
file content (89 lines) | stat: -rw-r--r-- 3,441 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# CMake file to be called in script mode (${CMAKE_COMMAND} -P <file>) to
# Generate a source archive release asset from add_custom_command
#
# See SourceDistTarget.cmake

if(NOT CMAKE_ARGV3)
  message(FATAL_ERROR "Must pass the top level src dir to ${CMAKE_ARGV2} as the first argument")
endif()

if(NOT CMAKE_ARGV4)
  message(FATAL_ERROR "Must pass the top level src dir to ${CMAKE_ARGV2} as the second argument")
endif()

find_package(Git)
if(NOT GIT_FOUND)
  message( FATAL_ERROR "You can't create a source archive release asset without git!")
endif()

execute_process(COMMAND "${GIT_EXECUTABLE}" describe --always
  RESULT_VARIABLE git_status
  OUTPUT_VARIABLE git_version
  WORKING_DIRECTORY "${CMAKE_ARGV3}"
  OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT (git_status STREQUAL "0"))
  message( FATAL_ERROR "git describe --always failed with exit status: ${git_status} and message:
${git_version}")
endif()

set(archive "OpenCoarrays-${git_version}")
set(l_archive "opencoarrays-${git_version}")
set(release_asset "${CMAKE_ARGV4}/${archive}.tar.gz")
execute_process(
  COMMAND "${GIT_EXECUTABLE}" archive "--prefix=${archive}/" -o "${release_asset}" "${git_version}"
  RESULT_VARIABLE git_status
  OUTPUT_VARIABLE git_output
  WORKING_DIRECTORY "${CMAKE_ARGV3}"
  OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT (git_status STREQUAL "0"))
  message( FATAL_ERROR "git archive ... failed with exit status: ${git_status} and message:
${git_output}")
else()
  message( STATUS "Source code release asset created from `git archive`: ${release_asset}")
endif()

file(SHA256 "${release_asset}" tarball_sha256)
set(sha256_checksum "${tarball_sha256}  ${archive}.tar.gz")
configure_file("${CMAKE_ARGV3}/cmake/opencoarrays-VER-SHA256.txt.in"
  "${CMAKE_ARGV4}/${l_archive}-SHA256.txt"
  @ONLY)
message( STATUS
  "SHA 256 checksum of release tarball written out as: ${CMAKE_ARGV4}/${l_archive}-SHA256.txt" )

find_program(GPG_EXECUTABLE
  gpg
  DOC "Location of GnuPG (gpg) executable")

if(GPG_EXECUTABLE)
  execute_process(
    COMMAND "${GPG_EXECUTABLE}" --armor --detach-sign --comment "@gpg_comment@" "${CMAKE_ARGV4}/${l_archive}-SHA256.txt"
    RESULT_VARIABLE gpg_status
    OUTPUT_VARIABLE gpg_output
    WORKING_DIRECTORY "${CMAKE_ARGV4}")
  if(NOT (gpg_status STREQUAL "0"))
    message( WARNING "GPG signing of ${CMAKE_ARGV4}/${l_archive}-SHA256.txt appears to have failed
with status: ${gpg_status} and output: ${gpg_output}")
  else()
    configure_file("${CMAKE_ARGV3}/cmake/opencoarrays-VER-SHA256.txt.asc.in"
      "${CMAKE_ARGV4}/${l_archive}-GPG.comment"
      @ONLY)
    file(READ "${CMAKE_ARGV4}/${l_archive}-GPG.comment" gpg_comment)
    configure_file("${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc"
      "${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc.out"
      @ONLY)
    file(RENAME "${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc.out"
      "${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc")
    message(STATUS "GPG signed SHA256 checksum created: ${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc")
  endif()
  execute_process(
    COMMAND "${GPG_EXECUTABLE}" --armor --detach-sign --comment "Detached signature of ${archive}.tar.gz." "${release_asset}"
    RESULT_VARIABLE gpg_status
    RESULT_VARIABLE gpg_output
    WORKING_DIRECTORY "${CMAKE_ARGV4}"
    )
    if(NOT (gpg_status STREQUAL "0"))
      message( WARNING "GPG signing of ${release_asset} appears to have failed
with status: ${gpg_status} and output: ${gpg_output}")
    endif()
endif()