From 5bf6ff67d6a203aec0b79fa944b74e8f4420f254 Mon Sep 17 00:00:00 2001 From: Rafael Palomar Date: Fri, 22 Sep 2023 14:47:51 +0200 Subject: [PATCH] Fix configuration error in absence of lsb_release (#190) This makes that, in absence of `lsb_release`, `DISTRO_NAME` is set to `Unknown`. A warning message is printed out --- cmake/Package.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/Package.cmake b/cmake/Package.cmake index b9c3c2476..fc0ab1d26 100644 --- a/cmake/Package.cmake +++ b/cmake/Package.cmake @@ -57,10 +57,15 @@ else() # Get distro name and version find_program(LSB_RELEASE_EXEC lsb_release) - execute_process(COMMAND ${LSB_RELEASE_EXEC} -is - OUTPUT_VARIABLE DISTRO_NAME - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + if(LSB_RELEASE_EXEC) + execute_process(COMMAND ${LSB_RELEASE_EXEC} -is + OUTPUT_VARIABLE DISTRO_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + else() + set(DISTRO_NAME "Unknown") + message(WARNING "lsb_release not found. DISTRO_NAME set to Unknown") + endif() string(TOLOWER ${DISTRO_NAME} DISTRO_NAME) execute_process(COMMAND ${LSB_RELEASE_EXEC} -rs OUTPUT_VARIABLE DISTRO_VERSION