cpptrace icon indicating copy to clipboard operation
cpptrace copied to clipboard

Compatibility for Homebrew Formula

Open mhx opened this issue 1 year ago • 2 comments

First of all, thanks for this project! I've started using it (optionally, for now) in one of my projects.

While trying to build on macOS, I noticed that cpptrace isn't yet available in Homebrew. So I thought "how hard can it be" and started writing up a formula, which is currently on a dev branch.

While this works fine, there are a two issues:

  1. ccache is currently a hard dependency. I believe the issue here is that if ccache happens to be installed, but it's not a dependency, then cmake will somehow find the ccache binary, but it won't be in the PATH while building. Making it a hard dependency will put ccache in the PATH. This should be fixed by #184.
  2. A more serious issue is that libdwarf (the formula is called dwarfutils in Homebrew) must be found via pkgconfig, as the formula doesn't installed a CMake config. This is fine for just building cpptrace, but when using cpptrace from another CMake project via find_package, the cpptrace::cpptrace target will try to link -ldwarf, which it doesn't find because it doesn't recall the linker search path from building cpptrace. This should be fixable by adding the original pkg_check_modules call to cpptrace-config-cmake.in and making sure the dependency is correctly resolved. Maybe you have a better idea.

mhx avatar Oct 18 '24 11:10 mhx

Hello! Thank you for opening this and taking the time to look into a homebrew formula!

Regarding libdwarf, unfortunately I'm not sure the best solution. Even with cmake this stuff is a pain (at least for me). I think what you are suggesting sounds reasonable. The current code checks for a configuration option due to something I encountered when packaging the library for conda.

https://github.com/jeremy-rifkin/cpptrace/blob/124dba5254bd4d396a2f48ab31aac5f6337000ac/cmake/in/cpptrace-config-cmake.in#L17-L19

And easy and safe solution would be to add something similar to facilitate homebrew. Using pkg_check_modules in the config file any time pkg_check_modules is used in the CMakeLists.txt could also be correct though I'd want to test that locally.

P.s.: Nice project, I think I've heard of DwarFS before :)

jeremy-rifkin avatar Oct 21 '24 05:10 jeremy-rifkin

And easy and safe solution would be to add something similar to facilitate homebrew. Using pkg_check_modules in the config file any time pkg_check_modules is used in the CMakeLists.txt could also be correct though I'd want to test that locally.

Cool, I'll see if I can play with this a bit and come up with a PR. I have the same problem in DwarFS and what I suggested is what worked for me.

P.s.: Nice project, I think I've heard of DwarFS before :)

Thanks! :)

cpptrace helped significantly in the investigation of a recent Windows-specific bug.

mhx avatar Oct 21 '24 09:10 mhx

Hi, circling back on this have you had a chance to look at things again and do you know if issues persist?

jeremy-rifkin avatar Jul 29 '25 02:07 jeremy-rifkin

Hi, circling back on this have you had a chance to look at things again and do you know if issues persist?

To be honest, I got busy with other stuff and completely forgot about this :(

Thanks for the reminder, I'll try to get back to it over the next few weeks!

mhx avatar Jul 29 '25 06:07 mhx

Sorry, it's been a while.

Good news: I think the code might be fine as-is.

As long as cpptrace is built as a shared library, the dependency on libdwarf is resolved automatically. I've tested that everything works fine on macOS and have submitted a PR to homebrew for addition of cpptrace: https://github.com/Homebrew/homebrew-core/pull/251948

mhx avatar Oct 30 '25 10:10 mhx