File: ParseOsRelease.cmake

package info (click to toggle)
opentelemetry-cpp 1.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,372 kB
  • sloc: cpp: 96,239; sh: 1,766; makefile: 36; python: 31
file content (25 lines) | stat: -rw-r--r-- 804 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
23
24
25
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Parse /etc/os-release to determine Linux distro

if(EXISTS /etc/os-release)
file(STRINGS /etc/os-release OS_RELEASE)
foreach(NameAndValue ${OS_RELEASE})
  # Strip leading spaces
  string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
  # Find variable name
  string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
  # Find the value
  string(REPLACE "${Name}=" "" Value ${NameAndValue})
  # Strip quotes from value
  string(REPLACE "\"" "" Value ${Value})
  # Set the variable
  message("-- /etc/os-release : ${Name}=${Value}")
  set("OS_RELEASE_${Name}" "${Value}")
endforeach()
else()
  set("OS_RELEASE_NAME" ${CMAKE_SYSTEM_NAME})
  set("OS_RELEASE_ID" ${CMAKE_SYSTEM_NAME})
  set("OS_RELEASE_VERSION_ID" "1.0")
endif()