You can run cmake scripts at build time with the -P command line argument.
If you need variables from cmake configure time in that cmake script, just make it a .cmake.in file and use configure_file() to prepare it, maybe with @ONLY parameter to not get confused with replaced variables and script-internal variables.