I am installing a directory that is created by a custom command. How do I make that step in the install depend on first executing the custom comamnd ?
There is no way to make the install script (or its build system target) depend on anything other than
all. See this issue. You can make the
install() command in your code have
OPTIONAL to skip installing it if it doesn’t exist.
An output of the custom command must be part of a target that is not excluded from ALL.
I was not aware that the install command depended on the all target. I did not see mention of that in https://cmake.org/cmake/help/latest/command/install.html
Using the ALL option in add_custom_target I was able the get the command to execute before the install.
How do I get the add_custom_target command to recognize that the directory has already been created so that the command is not re-run with each make all ?
make (and some other tools) do not handle dependencies on directories all that well. CMake can’t fix that.
I suggest setting the dependency to one file in that directory that is created for sure.