summaryrefslogtreecommitdiffhomepage
path: root/cmake/modules/GitToResource.cmake
blob: ac48cdb211bebb4fdbaae4100c61fbcf1a535553 (plain)
1
2
3
4
5
6
7
8
9
10
# Converts git version name acquired by GitDescribe to a format that can be embedded into rc file.

function(git_to_resource VAR VERSION)
	string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)-?([0-9]*)" OUTPUT ${VERSION})
	set(RC_VERSION "${CMAKE_MATCH_1},${CMAKE_MATCH_2},${CMAKE_MATCH_3},${CMAKE_MATCH_4}")
	if(NOT DEFINED CMAKE_MATCH_4)
		string(APPEND RC_VERSION "0")
	endif()
	set(${VAR} ${RC_VERSION} PARENT_SCOPE)
endfunction()