Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not finding lib.rs.cc on macos when running cmake build #1

Closed
stexa opened this issue Nov 8, 2022 · 2 comments · Fixed by #2
Closed

Not finding lib.rs.cc on macos when running cmake build #1

stexa opened this issue Nov 8, 2022 · 2 comments · Fixed by #2

Comments

@stexa
Copy link

stexa commented Nov 8, 2022

Thanks for your project!
I get the following issue when running cmake --build . on macos:

clang: error: no such file or directory: '/Users/{USER}/cpp-with-rust/target/cxxbridge/blobstore/src/lib.rs.cc'
clang: error: no input files
make[2]: *** [CMakeFiles/cpp_with_rust.dir/target/cxxbridge/blobstore/src/lib.rs.cc.o] Error 1
make[1]: *** [CMakeFiles/cpp_with_rust.dir/all] Error 2
make: *** [all] Error 2
@stexa
Copy link
Author

stexa commented Nov 8, 2022

It is working now:
I had to manually run cargo build --release before.
Even running cargo build was not generating the lib.rs.cc file.
Do you know why it is not being built by cmake?

pedrolcl added a commit to pedrolcl/cpp-with-rust that referenced this issue Jan 5, 2023
@pedrolcl
Copy link
Contributor

pedrolcl commented Jan 6, 2023

I've found this issue as well when working on this project in Linux, so it is not a macos only thing.

It can be triggered by the cmake clean target after a successful build. Any other build attempt after that will trigger the reported error. It doesn't matter if the build tool is GNU Make or Ninja. For instance:

cd cpp-with-rust
cmake -S . -B build
# (configuration succeeds)
cmake --build build/
# (build succeeds)
cmake --build build/ --target clean
# (clean removes two files)
cmake --build build/
# (build fails!)

Another available workaround is running cargo clean before building.

The problem is that the cmake clean target removes the OUTPUT files generated by add_custom_command(), but cargo doesn't know how to regenerate them when the target directory is already populated by the last cargo execution.

See my proposed solution on the next pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants