010-TryOldCentOS.cmake 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/centos-release")
  5. return()
  6. endif()
  7. # Get the first string only
  8. file(
  9. STRINGS "${CMAKE_SYSROOT}/etc/centos-release" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT
  10. LIMIT_COUNT 1
  11. )
  12. #
  13. # Example:
  14. # CentOS release 6.10 (Final)
  15. #
  16. if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "CentOS release ([0-9\.]+) .*")
  17. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME CentOS)
  18. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME "${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT}")
  19. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID centos)
  20. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE rhel)
  21. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION ${CMAKE_MATCH_1})
  22. set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ${CMAKE_MATCH_1})
  23. list(
  24. APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT
  25. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME
  26. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME
  27. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID
  28. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE
  29. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION
  30. CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID
  31. )
  32. endif()
  33. unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT)