filipdutescu / modern-cpp-template

A template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
The Unlicense
1.73k stars 215 forks source link

Fix clang format target command #23

Closed nhanders closed 3 years ago

nhanders commented 3 years ago

closes #21

Summary

When using multiple sources/headers, the building of the custom target clang-format was failing.

This was fixed by using the WORKING_DIRECTORY argument of add_custom_target.

Side Notes

I know you said you'd fixed this in the next release @filipdutescu, but I thought I'd help you along here.

Thank you for putting this template together! The world of modern C++ can be extremely confusing, but having a template like this with best practices has already made a world of difference to me!

Testing

✅ Able to reproduce error by adding src/main.cpp and building as an executable with ${PROJECT_NAME}_BUILD_EXECUTABLE set to ON. This work fixed this error. ✅ Able to run clang-format target with the setup described in the test above

Pull Request Readiness Checklist

See details at CONTRIBUTING.md.

filipdutescu commented 3 years ago

hey! thanks very much for your kind contribution! please accept my apologies for taking so long before acknowledging it. I will review the PR today, and leave comments afterwards, but I just wanted to thank you and apologize, before anything else

filipdutescu commented 3 years ago

looks great and such an elegant solution! thanks a lot!