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)