install(TARGETS ... OPTIONAL) doesn't work with nonexistent targets
If you do:
install(TARGETS noexist DESTINATION bin OPTIONAL)
it still throws an error complaining that the target doesn't exist.
Looking through the code, it seems that it's an error for the target to not exist at configure/generate time, but it's not an error for the target's output file to not exist at install time. (So for example, if you have an existing target foo
, and you say install(TARGETS foo DESTINATION bin OPTIONAL)
, then you can run make install
without having built foo
yet.)
Either this should be fixed in cmInstallCommand
to allow you to OPTIONAL
install nonexistent targets, or the documentation should be updated to explain this.