I have a project that consist of C/C++/proto/bash.
The C/C++ now works fine. proto works via an add_custom_command.
(The cpp_generate_proto did not work with my protofiles in subdirectories)
But I have not found a satisfying way of copying the script files to
the bin directory.
I have seen from previous answers that configure_file(… COPY_ONLY)
been suggested.
And it kind of works. But the copying of those files are at the
generator phase. So when I change one of those files cmake are
refgenerating build files. Also it will not detect if the files are removed.
So rm bin/*.sh is not detected, and I have to run cmake . again.
And it does not change the execute bit.
I could change the execute bit in the repository, and it will kind of
work, but I do not like it.
It also does not do syntax check on the scripts.
What I would like to happen, when building, and when a script in the
source tree is changed, is:
bash -n $src && cp $src $trg && chmod +x $trg
I have tried with add_custom_command/add_custom_target/add_dependencies
with no luck.
What I have for now ended up with is:
add_custom_target(Scripts ALL
make VPATH=${CMAKE_SOURCE_DIR} -f ${CMAKE_SOURCE_DIR}/MakeShellScripts
)
And let the MakeShellScripts makefile do the work.
But is there really not possible to do this inside CMake ?
Define a target, sources, and how to convert the sources to the target?