1
0
mirror of https://github.com/altlinux/admc.git synced 2025-03-16 14:50:13 +03:00

add version extration from spec file for cmake

This commit is contained in:
august-alt 2021-02-11 16:51:06 +04:00
parent d253326441
commit ae3637b97f

View File

@ -1,5 +1,19 @@
cmake_minimum_required(VERSION 3.0)
project(admc VERSION 0.3.1)
# You can get version from spec by first finding Versions keyword.
# After that you can use awk to split line by : and then select second part of it.
# Finally you want to clear all the spaces around version.
# OUTPUT_VARIABLE argument of execute_process allows you to capture output of the command.
execute_process(
COMMAND
bash -c "grep Version: .gear/admc.spec | awk -F\":\" '{ print $2 }' | tr -d [:space:]"
OUTPUT_VARIABLE GEAR_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# To ensure that we have indeed captured the project version we use message to provide us with console output.
message(STATUS "Project version is: " ${GEAR_VERSION})
project(admc VERSION ${GEAR_VERSION})
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}