020-TryDebianVersion.cmake 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # Author: Alex Turbov
  4. if(NOT EXISTS "${CMAKE_SYSROOT}/etc/debian_version")
  5. return()
  6. endif()
  7. # Get the first string only
  8. file(
  9. STRINGS "${CMAKE_SYSROOT}/etc/debian_version" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT
  10. LIMIT_COUNT 1
  11. )
  12. #
  13. # Example:
  14. # 6.0.10 # Old debian
  15. # wheezy/sid # Ubuntu
  16. #
  17. if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "[0-9]+(\.[0-9]+)*")
  18. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME Debian)
  19. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID debian)
  20. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION ${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT})
  21. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT})
  22. list(
  23. APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT
  24. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME
  25. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID
  26. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION
  27. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID
  28. )
  29. endif()
  30. unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT)