You probably want file(GENERATE)
, which can use generator expressions but writes the file during the CMake generation phase:
file(GENERATE
OUTPUT "$<TARGET_FILE_DIR:tgt>/qt.conf"
CONTENT "${text_to_write}" # Use one of these two
#INPUT "/path/to/somewhere/qt.conf" #
)