monostep/cmake/WriteBuildStamp.cmake

22 lines
748 B
CMake
Raw Permalink Normal View History

# Generates BuildStamp.h with the current date/time. Run as a build-time
# custom command so the stamp is refreshed on every build (the TU that includes
# it is recompiled because the header mtime changes each time).
if(NOT DEFINED MONOSTEP_BUILD_STAMP_HEADER)
message(FATAL_ERROR "MONOSTEP_BUILD_STAMP_HEADER must be set")
endif()
string(TIMESTAMP STAMP "%Y-%m-%d__%H:%M:%S")
get_filename_component(MONOSTEP_BUILD_STAMP_DIR "${MONOSTEP_BUILD_STAMP_HEADER}" DIRECTORY)
file(MAKE_DIRECTORY "${MONOSTEP_BUILD_STAMP_DIR}")
file(WRITE "${MONOSTEP_BUILD_STAMP_HEADER}"
"// Generated at build time - do not edit.
#ifndef MONOSTEP_BUILD_STAMP_H_INCLUDED
#define MONOSTEP_BUILD_STAMP_H_INCLUDED
#define MONOSTEP_BUILD_DATE \"${STAMP}\"
#endif
")