master
cmake 26 lines 1.06 KB
Raw
1 function(get_version_impl command var_name)
2 execute_process(
3 COMMAND powershell.exe
4 -NoProfile
5 -NonInteractive
6 -ExecutionPolicy Bypass
7 -Command "$env:Path += ';${GITVERSION_SOURCE_DIR}' ; . .\\tools\\devops\\version_functions.ps1 ; ${command}"
8 OUTPUT_VARIABLE OUTPUT_VERSION
9 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
10 COMMAND_ERROR_IS_FATAL ANY)
11 string(STRIP "${OUTPUT_VERSION}" OUTPUT_VERSION)
12 SET(${var_name} ${OUTPUT_VERSION} PARENT_SCOPE)
13 endfunction()
14
15 function(find_commit_hash var_name)
16 get_version_impl("Get-Current-Commit-Hash" "command_output")
17 SET(${var_name} ${command_output} PARENT_SCOPE)
18 endfunction()
19
20 function(find_version msix_var_name nuget_var_name)
21 get_version_impl("Get-VersionInfo -Nightly $false | ConvertTo-Json" "command_output")
22 string(JSON "${msix_var_name}" GET "${command_output}" MsixVersion)
23 string(JSON "${nuget_var_name}" GET "${command_output}" NugetVersion)
24
25 return(PROPAGATE ${msix_var_name} ${nuget_var_name})
26 endfunction()