jeremy-rifkin / libassert

The most over-engineered C++ assertion library
MIT License
539 stars 36 forks source link

fmt Integration is Broken #89

Closed robert-harrison-klein closed 7 months ago

robert-harrison-klein commented 7 months ago

Hello!

I don't think fmt integration currently works. You define a target, libassert::assert, and specify that users can add a compile definition LIBASSERT_USE_FMT to enable fmt integration on the target. However, you never link the fmt::fmt library to libassert::assert, so enabling LIBASSERT_USE_FMT results in a failure to compile. Specifically:

libassert/include/libassert/assert.hpp:50:11: fatal error: 'fmt/format.h' file not found

I think the fix is pretty straightforward. I think you just need to add a CMake option for fmt integration that will conditionally link libassert::assert to fmt::fmt.

Best, Rob

jeremy-rifkin commented 7 months ago

Hi Rob, This is intentional. LIBASSERT_USE_FMT just turns on the relevant code in the assert.hpp header and it's relying on the user having already appropriately installed fmt or linked against fmt::fmt. The thought was if a user is using this flag they should already be using fmt in their codebase. I'm happy to revisit this however presently I figured it was best to not try to have libassert manage this dependency.

jeremy-rifkin commented 7 months ago

I'll close for now, please let me know if there's anything else I can help with or if you have ideas for improving the current state of affairs!

robert-harrison-klein commented 1 month ago

Thanks for the help with this Jeremy. I finally figured out what I was doing wrong. I was including both fmt and libassert as subdirectories of my own project. Now that I am properly building and installing them as dependencies and using find_package in my CMakeLists.txt, fmt integration appears to work as intended.

jeremy-rifkin commented 1 month ago

Excellent! I’m glad you got it working!