From 9b0b281b75b1183c0a1bb0134e7c1c8d0ae966a7 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 8 Oct 2016 14:22:36 -0400 Subject: [PATCH] config: Allow setting USERNAME/HOSTNAME from the environment Allowing this to be controlled externally improves reproducibility, as well as provides a more useful address to report for "Compiled by". For example, I intend to set it to the packaging list when building the Debian package. Signed-off-by: James McCoy --- config/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index cf84f8c6a4..a16000aba8 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -142,12 +142,16 @@ configure_file ( find_program(WHOAMI_PROG whoami) find_program(HOSTNAME_PROG hostname) -if (NOT DEFINED USERNAME AND EXISTS ${WHOAMI_PROG}) +if (DEFINED ENV{USERNAME}) + set(USERNAME $ENV{USERNAME}) +elseif (NOT DEFINED USERNAME AND EXISTS ${WHOAMI_PROG}) execute_process(COMMAND ${WHOAMI_PROG} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE USERNAME) endif() -if (EXISTS ${HOSTNAME_PROG}) +if (DEFINED ENV{HOSTNAME}) + set(HOSTNAME $ENV{HOSTNAME}) +elseif (EXISTS ${HOSTNAME_PROG}) execute_process(COMMAND ${HOSTNAME_PROG} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE HOSTNAME)