# append_timestamp.cmake cmake_minimum_required(VERSION 3.5) # Check for the presence of the two expected arguments if(NOT HEADER_FILE OR NOT MODIFICATION_TIME OR NOT IDENTIFIER) message(FATAL_ERROR "Usage: cmake -D HEADER_FILE:string=\"filename.h\" -D IDENTIFIER:string=\"variable_prefix\" -D MODIFICATION_TIME:string=\"2021-01-01 01:01:01\" -P append_timestamp.cmake ") endif() # Append the timestamp to the header file file(APPEND ${HEADER_FILE} "const char* ${IDENTIFIER}_last_modified=\"${MODIFICATION_TIME}\";\n")