jorgen / json_struct

json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Other
425 stars 57 forks source link

Conan package for json_struct #59

Open sheepy9 opened 2 months ago

sheepy9 commented 2 months ago

Hi, would you be interested in having json_struct be available as a conan package? If so, I can submit a pull request adding the conan recipe. Then you could submit an inclusion request to have json_struct available on conancenter, making it super easy for anyone using conan to discover/use your library.

Cheers.

jorgen commented 2 months ago

Yay! Lets do this!

sheepy9 commented 2 months ago

I added a PR here #60

After this you can submit a pull request on conancenter to have json_struct included.

Feel free to open any issues here and ping me if there are any additional requirements by conancenter.

jorgen commented 2 months ago

Hi, I am a bit new to conan. So I have requested access, and I have used your files to create a receipt inside my fork of conan-center-index: https://github.com/jorgen/conan-center-index/tree/json_struct_receipt. But I'm not able to build it with conand create. Do you know if I'm doing something wrong @sheepy9?

sheepy9 commented 2 months ago

My bad. Should be fixed now in #61 It seems there were some additional files required by CPACK in the original CMakeLists.txt like the readme and the license file.

So, since this is a header only library, there are two ways to make the conan package. One way is to just copy the header files, ignore everything else and call it a day. I chose to honor the existing CMakeLists, so that users can still bulid tests/benchmarsk and use find_package and link to json_struct::json_struct. An unexpected thing there was that the CMakeLists requires additional, non-source code files to be present.

If you check out the test_package, you will see an example of how json_struct will be consumed as a conan package. Basically users would just list json_struct/x.y.z as a dependency and it will be available to cmake in find_package.

You might need this when submitting the package to conancenter. It's a minimal example for using the package

from conan import ConanFile
from conan.tools.cmake import cmake_layout

class ExampleRecipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeDeps", "CMakeToolchain"

    def requirements(self):
        self.requires("json_struct/1.0.0")

    def layout(self):
        cmake_layout(self)
jorgen commented 2 months ago

Hi @sheepy9. I have now created a merge request: https://github.com/conan-io/conan-center-index/pull/25335.

I really appreciate your help, thank you!