Allow add_executable to be created from another executable
I have the following use case:
An executable is created normally via add_executable
with some C sources. This reacts on the name of the binary. In this case: If the name is bzip2
it will pack files and if it is bunzip
it will unpack an archive.
This is achieved by creating a symlink (copy on Windows) to the created executable. This already turned out to be quite difficult to achieve as e.g. add_custom_command
does not allow generator expressions for OUTPUT
: #12877 (closed)
The best solution seems to be a POST_BUILD event.
However if you want to use this created binary in a test or if you want to install it you don't have a target to refer to.
What would be needed is either an empty target so that the following works:
add_executable(bunzip)
add_custom_command(TARGET bzip2 POST_BUILD ... )
add_dependencies(bunzip bzip2)
install(TARGETS bunzip DESTINATION ${CMAKE_INSTALL_BINDIR})
Or to be able to do add_executable(bunzip bzip2 SYMLINK_OR_COPY)
or similar.