Warning, /graphics/kgeotag/cmake/UpdateVersion.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2018-2021 Tobias Leupold <tl at stonemx dot de>
0002 # SPDX-FileCopyrightText: 2012-2018 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005
0006 if (NOT DEFINED BASE_DIR)
0007 message(FATAL_ERROR "UpdateVersion.cmake: BASE_DIR not set. "
0008 "Please supply base working directory!")
0009 endif()
0010
0011 # Version header locations
0012 set(VERSION_H_IN ${BASE_DIR}/src/version.h.in)
0013 set(VERSION_H_CURRENT ${CMAKE_BINARY_DIR}/version.h.current)
0014 set(VERSION_H_GENERATED ${CMAKE_BINARY_DIR}/version.h)
0015
0016 if (EXISTS "${BASE_DIR}/.git" AND EXISTS "${VERSION_H_IN}")
0017 # We're not working on a release tarball and have to generate a version.h
0018 message(STATUS "Generating version.h from git")
0019 include(${CMAKE_CURRENT_LIST_DIR}/GitDescription.cmake)
0020 git_get_description(VERSION GIT_ARGS)
0021 if (NOT VERSION)
0022 set(VERSION "unknown")
0023 endif()
0024 else()
0025 # We're compiling a release tarball and generate version.h
0026 # from the CMakeLists.txt project version
0027 message(STATUS "Generating version.h from CMakeLists.txt")
0028 set(VERSION "${PROJECT_VERSION}")
0029 endif()
0030
0031 message(STATUS "Updating version information to ${VERSION}")
0032 # write version info to a temporary file
0033 configure_file(${VERSION_H_IN} ${VERSION_H_CURRENT})
0034 # update info if changed
0035 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
0036 ${VERSION_H_CURRENT} ${VERSION_H_GENERATED})
0037 # make sure info doesn't get stale
0038 file(REMOVE ${VERSION_H_CURRENT})