From dbe28ecdceffcf3516e88ddf611cb7405b9566ce Mon Sep 17 00:00:00 2001 From: Roman Dementiev Date: Thu, 11 Jul 2024 19:29:40 +0200 Subject: [PATCH] Update CMakeLists.txt (#784) * Update CMakeLists.txt fixes obs builds --- src/CMakeLists.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 530a1003..53c899c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,13 +17,17 @@ else() endif() if (LINUX) - file(STRINGS "/etc/os-release" OS_RELEASE_CONTENTS) - foreach(LINE ${OS_RELEASE_CONTENTS}) - if(LINE MATCHES "^ID=") - string(REGEX REPLACE "^ID=\"?\([a-zA-Z]+\)\"?" "\\1" OS_ID ${LINE}) - endif() - endforeach() - message(STATUS "Detected Linux distribution: ${OS_ID}") + if(EXISTS "/etc/os-release") # AND IS_READABLE "/etc/os-release" (3.29 cmake required :-( ) + file(STRINGS "/etc/os-release" OS_RELEASE_CONTENTS) + foreach(LINE ${OS_RELEASE_CONTENTS}) + if(LINE MATCHES "^ID=") + string(REGEX REPLACE "^ID=\"?\([a-zA-Z]+\)\"?" "\\1" OS_ID ${LINE}) + endif() + endforeach() + message(STATUS "Detected Linux distribution: ${OS_ID}") + else() + message(STATUS "Unable to read /etc/os-release") + endif() endif() if(NOT DEFINED NO_ASAN)