1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4# Author: Alex Turbov
5
6if(NOT EXISTS "${CMAKE_SYSROOT}/etc/centos-release")
7  return()
8endif()
9
10# Get the first string only
11file(
12    STRINGS "${CMAKE_SYSROOT}/etc/centos-release" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT
13    LIMIT_COUNT 1
14  )
15
16#
17# Example:
18#   CentOS release 6.10 (Final)
19#
20if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "CentOS release ([0-9\.]+) .*")
21
22  set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME CentOS)
23  set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME "${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT}")
24  set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID centos)
25  set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE rhel)
26  set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION ${CMAKE_MATCH_1})
27  set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ${CMAKE_MATCH_1})
28
29  list(
30      APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT
31      CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME
32      CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME
33      CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID
34      CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE
35      CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION
36      CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID
37    )
38
39endif()
40
41unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT)
42