zug
zug copied to clipboard
Adding a "zug_" prefix to target names and some other enhancements
Hello!
I was trying to link zug and Boost.Hana in a project of mine and ran into issues with target names, so I decided to make a fork and add a zug_
prefix to all targets, variables, and functions where one is missing and add a log function which adds a [zug::${PROJECT_NAME}]:
prefix to every status message from zug (when CCache has been or hasn't been found and when adding test targets).
I ran the check target (its name is "zug_check" in my fork) and every test is passing.
I also noticed that when I include the sequence header I get an error saying boost::mpl is not present (there has been an issue discussing this, but I don't know if this was fixed), so I was thinking of adding a metafunction that does the same thing in the meta namespace.
Are you interested in a pull requests that do this? If not, I will just keep using my fork and merge from master from time to time to keep things updated, so it's not a problem on my part if you don't want this. I would like to add a pull request that does this for immer as well if you are interested.
PS: I dig the idea of making C++ more functional and declarative coming from React, so thank you for all the great libraries 😄
Hmmm, if you use find_package(Immer)
I don't think you have this issue, do you? I think the ergonomics of having to do zug_
all the time are not great, and I like the Makefile targets to follow GNU-ish convetions like make check
to check the project, etc.
Also glad that you are finding the libraries useful or interesting!! :heart:
I'm using CMake's FetchContent module for dependencies. This is something I also picked up from the Javascript ecosystem. I was trying to use Conan for dependencies but getting it to work for multiple compilers in one project using CMake is really hard and depends on the dependencies you are using. FindPackage is ok but it demands that users of my projects have all the dependencies preinstalled, so I tend to avoid those kinds of options. I really wish C++ had a nice standardized package manager and build system like other languages now...
I don't like the zug_
ergonomics either, but I found it was the only way to have something like "namespaces" in CMake and avoid name collision since most projects add or try to add targets like test
, check
, benchmark
, and so on. I don't know if this is a problem if you manage your dependencies with FindPackage, though.
As for the GNU-ish conventions, I could add the check
target if it doesn't exist and add zug_check
as a dependency.
I also discovered a bug on MSVC concerning inline constexpr variables and was able to fix it. MSVC doesn't allow constexpr variables being extern, so you have to pass in the compiler flag /Zc:externConstexpr
to enable that .
Relevant links:
https://docs.microsoft.com/en-us/cpp/build/reference/zc-externconstexpr?view=msvc-160
https://docs.microsoft.com/en-us/cpp/cpp/selectany?view=msvc-160
Yes it's the problem of FetchContent. You can instead have them as submodules in your git repo and just specify target_include_directories