From a8e85bd146cd38d43846d9e27acd9ec1075e169b Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 1 Oct 2022 22:44:51 +0200 Subject: [PATCH] cmake: Work-around gcc 7 not supporting SOURCE_DATE_EPOCH --- CMakeLists.txt | 6 ++++++ Firmware/Configuration.h | 11 ++++++++--- Firmware/ultralcd.cpp | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d2ff87db..5134de875 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,6 +240,12 @@ if(CMAKE_CROSSCOMPILING) # TODO: get date from the last git commit to set as epoch set(ENV{SOURCE_DATE_EPOCH} 0) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8") + string(TIMESTAMP SOURCE_DATE_EPOCH "%Y-%m-%d") + add_compile_definitions(SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}") + string(TIMESTAMP SOURCE_TIME_EPOCH "%H:%M:%S") + add_compile_definitions(SOURCE_TIME_EPOCH="${SOURCE_TIME_EPOCH}") + endif() # default optimization flags set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index af36b3616..454ccbc10 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -63,6 +63,13 @@ extern PGM_P sPrinterName; #undef DEBUG_BUILD #endif +#ifndef SOURCE_DATE_EPOCH +#define SOURCE_DATE_EPOCH __DATE__ +#endif +#ifndef SOURCE_TIME_EPOCH +#define SOURCE_TIME_EPOCH __TIME__ +#endif + #include "Configuration_prusa.h" #define FW_PRUSA3D_MAGIC "PRUSA3DFW" @@ -78,9 +85,7 @@ extern PGM_P sPrinterName; // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. -//#define STRING_VERSION "1.0.2" - -#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time +#define STRING_VERSION_CONFIG_H SOURCE_DATE_EPOCH " " SOURCE_TIME_EPOCH // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. // SERIAL_PORT selects which serial port should be used for communication with the host. diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8a8bf7fa5..74bee7ad4 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1657,7 +1657,7 @@ static void lcd_support_menu() MENU_ITEM_BACK_P(PSTR(NOZZLE_TYPE)); MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 - MENU_ITEM_BACK_P(PSTR(__DATE__)); + MENU_ITEM_BACK_P(PSTR(SOURCE_DATE_EPOCH)); #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG) MENU_ITEM_BACK_P(STR_SEPARATOR);