File: version.cmake

package info (click to toggle)
wl-mirror 0.18.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 688 kB
  • sloc: ansic: 4,886; xml: 2,062; sh: 284; makefile: 54
file content (22 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if(NOT ${CMAKE_ARGC} EQUAL 6 OR NOT DEFINED REPO_DIR)
    message(FATAL_ERROR "usage: cmake -DREPO_DIR=<repo-dir> -P version.cmake <target> <template.h.in>")
endif()

set(version-header "${CMAKE_ARGV4}")
set(version-template "${CMAKE_ARGV5}")
set(repo-dir "${REPO_DIR}")

if(IS_DIRECTORY "${repo-dir}/.git")
    execute_process(
        COMMAND git describe --long --tags
        WORKING_DIRECTORY "${repo-dir}"
        OUTPUT_VARIABLE VERSION
    )
elseif(EXISTS "${repo-dir}/version.txt")
    file(READ "${repo-dir}/version.txt" VERSION)
else()
    set(VERSION "")
endif()

string(STRIP "${VERSION}" VERSION)
configure_file("${version-template}" "${version-header}" @ONLY)