Define a pre-build command without creating a new target

You are right it runs at configuration time. There is no clean way to generate sources at build time, it is not a good idea anyway since it always forces your build out of date.

Anyway, here is a suggestion:

add_custom_command( TARGET dummy
	PRE_BUILD
	COMMAND ${CMAKE_COMMAND} -P ${dummy_SOURCE_DIR}/ConfigureDate.cmake
)

This adds an extra build step every time dummy target is build. The command runs CMake in script mode to generate the header file, which is then used to build dummy.