I am sure, that the currently accepted answer from 2013 was valid for the time being.
However, it did not work well for me with all the slashes and dots and colons in the $${path}
. Also we have to put $$list()
around a list of files nowadays to use it in a for loop.
Here is the approach I came up with. I wrote that in a *.pri
file and added it to my directory structure. No need for the extra INSTALL_HEADERS
variable:
for(header, $$list($$HEADERS)) {
path = $$OUT_PWD/../include/$$dirname(header)
pathname = $$replace(path,/,)
pathname = $$replace(pathname,\.,)
pathname = $$replace(pathname,:,)
file = headers_$${pathname}
eval($${file}.files += $$header)
eval($${file}.path = $$path)
INSTALLS *= $${file}
}
Note that the replacement characters may vary for you. For example, my first approach above had still problems with whitespaces in the path, so I added:
pathname = $$replace(pathname," ",)