summaryrefslogtreecommitdiffstats
path: root/.gitlab/ci/ctest_annotation.cmake
blob: a21975323057a489c3788fd612b09cea8c9b2140 (plain)
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
function (ctest_annotation_report file)
  set(label "")

  if (EXISTS "${file}")
    file(READ "${file}" json)
  else ()
    set(json "{\"CDash\": []}")
  endif ()

  foreach (arg IN LISTS ARGN)
    if (NOT label)
      set(label "${arg}")
      continue ()
    endif ()

    set(item "{\"external_link\":{\"label\":\"${label}\",\"url\":\"${arg}\"}}")
    set(label "")

    string(JSON length LENGTH "${json}" "CDash")
    string(JSON json SET "${json}" "CDash" "${length}" "${item}")
  endforeach ()

  file(WRITE "${file}" "${json}")
endfunction ()

if (NOT DEFINED build_id)
  include("${CTEST_BINARY_DIRECTORY}/cdash-build-id" OPTIONAL)
endif ()
function (store_build_id build_id)
  file(WRITE "${CTEST_BINARY_DIRECTORY}/cdash-build-id"
    "set(build_id \"${build_id}\")\n")
endfunction ()