2
0

ParseOsRelease.cmake 804 B

12345678910111213141516171819202122232425
  1. # Copyright The OpenTelemetry Authors
  2. # SPDX-License-Identifier: Apache-2.0
  3. # Parse /etc/os-release to determine Linux distro
  4. if(EXISTS /etc/os-release)
  5. file(STRINGS /etc/os-release OS_RELEASE)
  6. foreach(NameAndValue ${OS_RELEASE})
  7. # Strip leading spaces
  8. string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
  9. # Find variable name
  10. string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
  11. # Find the value
  12. string(REPLACE "${Name}=" "" Value ${NameAndValue})
  13. # Strip quotes from value
  14. string(REPLACE "\"" "" Value ${Value})
  15. # Set the variable
  16. message("-- /etc/os-release : ${Name}=${Value}")
  17. set("OS_RELEASE_${Name}" "${Value}")
  18. endforeach()
  19. else()
  20. set("OS_RELEASE_NAME" ${CMAKE_SYSTEM_NAME})
  21. set("OS_RELEASE_ID" ${CMAKE_SYSTEM_NAME})
  22. set("OS_RELEASE_VERSION_ID" "1.0")
  23. endif()