mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
1.07k stars 85 forks source link

Added support for use of units as subdirectory when *dependencies* are *also* subdirectories #446

Closed Cazadorro closed 1 year ago

Cazadorro commented 1 year ago

Added check for gsl::gsl-lite to avoid find_package if targets already added by add_subdirectory(...) and did the same for fmt::fmt and ranges-v3, with out these changes, impossible to use library if dependencies are also subdirectories, complains about not being able to find package (when it no longer needs to)

gitpod-io[bot] commented 1 year ago

JohelEGP commented 1 year ago

I think https://cmake.org/cmake/help/latest/command/cmake_language.html#set-dependency-provider can be used to work around that.

Cazadorro commented 1 year ago

Thanks!

Unfortunately, I have mixed feelings about that. On one side, I understand your point, and I see how this PR fixes your problem. On the other hand, doing dependency management via add_subdirectory is really wrong, and I wouldn't like to encourage it or complicate the code logic to provide support for such scenarios.

definitely agree, but the problem is 7 fold:

The practical reality on the ground is why other libraries support such use cases out of the box, we have no other real option. Trust me, myself and the thousands of other engineers that work in these kinds of environments would much rather be using package managers, but unlike rust's cargo, or heck even PIP, neither Conan or VCPKG provide adequate solutions to these problems. IME, 99% of the people who have the same issues simply don't attempt to use libraries like this if they don't immediately work offline. I know at my company, I'm at least the fourth person to attempt to use this library, and the only person to attempt to actually stick with it despite the dev ops problems associated with it, and I was hoping this would kind of pave the way for further usage.

Now if you want to do something that requires a newest stable version of CMake, that doesn't impede us, or really anybody because CMake is so portable and easy to get, even in legacy environment.

mpusz commented 1 year ago

Thanks for your "attempt to use this library" and being "the only person to attempt to actually stick with it" :-D You convinced me with tour answer. Thanks again!