File: version-parent.cmake

package info (click to toggle)
rocm-cmake 6.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 948 kB
  • sloc: cpp: 82; python: 33; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 1,321 bytes parent folder | download | duplicates (2)
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
# ######################################################################################################################
# Copyright (C) 2017 Advanced Micro Devices, Inc.
# ######################################################################################################################

find_program(GIT NAMES git)

# Try to test without git
file(MAKE_DIRECTORY ${TMP_DIR}/repo)
execute_process(
    COMMAND ${GIT} describe --dirty --long --always --match [0-9]*
    WORKING_DIRECTORY ${TMP_DIR}/repo
    OUTPUT_VARIABLE GIT_TAG
    RESULT_VARIABLE RESULT)
if(NOT ${RESULT} EQUAL 0)
    set(GIT_TAG 0)
endif()
execute_process(
    COMMAND ${GIT} rev-list HEAD
    WORKING_DIRECTORY ${TMP_DIR}/repo
    OUTPUT_VARIABLE REVS
    RESULT_VARIABLE RESULT)
separate_arguments(REVS UNIX_COMMAND "${REVS}")
list(GET REVS 10 PARENT)
string(STRIP "${REVS}" REVS)
message("PARENT: ${PARENT}")
write_version_cmake(
    ${TMP_DIR}/repo
    "1.0 PARENT ${PARENT}"
    "
    test_expect_eq(\${PROJECT_VERSION_MAJOR} 1)
    test_expect_eq(\${PROJECT_VERSION_MINOR} 0)
    test_expect_eq(\${PROJECT_VERSION_PATCH} 0)
    test_expect_eq(\${PROJECT_VERSION_TWEAK} ${GIT_TAG})
    test_expect_eq(\${PROJECT_VERSION}
        \${PROJECT_VERSION_MAJOR}.\${PROJECT_VERSION_MINOR}.\${PROJECT_VERSION_PATCH})
")
install_dir(${TMP_DIR}/repo)