Closed flaviojs closed 3 months ago
Did you try the latest version on master?
To add some background:
configure_file is only available at CMake configure time, it's not a build command. It's not suitable because the bindings will not be regenerated if the rust code changes.
You need to use the most recent version of Corrosion, and use cbindgen
0.26 (or newer). If you don't have cbindgen installed at all, thats also fine - corrosion will build it for you.
The newest version of cbindgen generates a so called depfile
(see https://github.com/mozilla/cbindgen/pull/820), which lists which rust files the generated bindings depend on. Corrosion, then uses this depfile to tell CMake when the cbindgen command needs to be rerun.
The depfile feature requires a more recent CMake version then Corrosion v0.4 requires, so it is only used on the latest master (future v0.5 version) which already requires a sufficienlty new CMake version.
I'll be closing this issue for now, but if you still encounter this on the latest master version, the please reopen the issue and provide some more information so I can reproduce.
It works as expected after updating cbindgen to 0.26 and using master, thanks. :)
As a side note, since configure_file
is only available at configure time, then cmake -E copy_if_different
probably works at build time.
During development I run
make
to ensure new code can compile. Withcmake
I expect only the files with changes to be rebuilt.Since I started using
corrosion_experimental_cbindgen
(v0.4), whatever includes the generated header gets rebuilt every time. The contents of the header did not change, only the timestamp changed.Suggestion: generate to a temporary directory and use
configure_file(COPYONLY)
to update the wanted header. This should provide thecmake
-like experience of only rebuilding when there are changes.