See all the CMakeLists.txt and cmake_install.cmake files, plus the CMakeFiles directories?
How can I remove them from the installed directories? Or rather, exclude them from being installed.
Preferably, without having to list the header files multiple times…
You can put the header files into a variable and use it for the source list and the install(FILES) call. Or, if you’re using CMake 3.23+, you can put the headers into a FILE_SET and install the FILE_SET directly.
You can pass EXCLUDE arguments to install(FILES), but the set of files differs from generator to generator. I would encourage factoring out the list of headers in one of the ways described above.