cpr icon indicating copy to clipboard operation
cpr copied to clipboard

Homebrew?

Open jackfischer opened this issue 8 years ago • 9 comments

It would be great if cpr could be easily installed and linked against via homebrew!

jackfischer avatar Jul 20 '16 21:07 jackfischer

@jackfischer, I agree! Do you know the relevant steps for getting that done? I've got no experience with that, so any expertise on the process would be greatly appreciated.

whoshuu avatar Sep 27 '16 04:09 whoshuu

I move headers to include directories and libcpr.a to linking directories, then specify linking args -lcpr -lcurl and it works(my machine has libcurl not sure it's installed by system or homebrew), not familiar with homebrew formula though..

ahxxm avatar Oct 31 '16 01:10 ahxxm

I have some experience maintaining projects on Homebrew, and I could help get this onto there. The problem is that the CMake project as it is now won't really work for Homebrew.

Homebrew is designed to build the libraries from source, so every project on there works by having a "formula" that tells Homebrew how to build the project. The formula system can easily understand CMake projects (as well as autoconf projects), but it expects the CMake project to be able to do some things that this project's can't right now.

The way I see it, there are three things that need to be done for this to get added to Homebrew:

  1. This needs to have an install target. Right now, I can run cmake; make and it builds the project. However, if I try to run make install, it tells me that the target doesn't exist. I know there's a simple way to create an install target in CMake that copies over the headers, library files, and create the pkg-config files as well (I just don't know CMake well enough). This is important to getting it working with Homebrew (Homebrew changes the prefix when configuring to get the files to go where it wants)
  2. There should be a way to create both static and shared libraries at the same time. Forcing it to configure and make twice to get both doesn't make much sense, and would make creating the Homebrew formula much more complicated than it needs to be. Allowing both to be built at the same time is important to getting this to work.
  3. Once both of the above are done, there needs to be another stable release. Homebrew can have a build type for "current git/hg version" (some libraries have it), but all projects need a default build type of a stable release. Having a stable release with the above changes means that Homebrew would be able to build it.

Once this is done, I am willing to do the work to get the Homebrew formula written and submitted to the formula repository.

LRFLEW avatar Dec 21 '16 18:12 LRFLEW

Hey @LRFLEW ! I would say your suggestions are helpful in the general case, not just for the sake of making a Homebrew formula :)

Regarding static and shared libraries simultaneously -- is that thing really required? CMake doesn't provide a way of building both at the same time, but it is rather easy to make a flag to build one set of libraries at a time. Another way around would be to explicitly create each library twice within the CMakeLists.txt files, which (as for me) looks really ugly, but if it is tolerated by the repo owner then it is also an option.

mexus avatar Dec 21 '16 18:12 mexus

Regarding static and shared libraries simultaneously -- is that thing really required?

No, it's not really required, but if we want to formula to include both, it should do it in one go. I don't know CMake all that well, but I would be surprised if there isn't a reasonably simple solution. ~~This page suggests it can be done with two calls to add_library, and since they use the same source files, using a variable for the sources list should keep the CMakeLists.txt file easy enough to read.~~ ~~This page seems more relevant. Basically, it explains how to create two targets that use the same built object files.~~ Making it two targets (that both get compiled with make all) on one configuration call would work as well.

LRFLEW avatar Dec 21 '16 19:12 LRFLEW

@LRFLEW before you edited, I made the minor change needed to add both targets like the first post suggests, and once I set the tests to link to the static library, all was well! I can read through the other link you posted.

EDIT: You can see my changes: https://github.com/ethanhs/cpr/

I'll see if the object system is better and if it is, then I'll try that instead.

emmatyping avatar Dec 21 '16 20:12 emmatyping

@LRFLEW I'm not sure objects are what we are looking for, it doesn't provide two libraries.

one large library file such as libbig.a is produced

This is useful for large projects that want to modularize within, but I don't think this is the silver bullet we're looking for.

emmatyping avatar Dec 21 '16 20:12 emmatyping

This is probably not that important now that using cpr through the conan package manager works so well.

However if we still want a make install, I'd be happy to take a look.

atif1996 avatar Feb 01 '21 21:02 atif1996

Sure. You are more than welcome.

COM8 avatar Feb 02 '21 05:02 COM8