json_struct icon indicating copy to clipboard operation
json_struct copied to clipboard

Conan package for json_struct

Open sheepy9 opened this issue 1 year ago • 5 comments

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.

sheepy9 avatar Sep 12 '24 13:09 sheepy9

Yay! Lets do this!

jorgen avatar Sep 12 '24 18:09 jorgen

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.

sheepy9 avatar Sep 13 '24 13:09 sheepy9

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?

jorgen avatar Sep 13 '24 16:09 jorgen

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)

sheepy9 avatar Sep 13 '24 21:09 sheepy9

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!

jorgen avatar Sep 19 '24 22:09 jorgen

The library has been available on conancenter for a while now, so I'm going to close the issue.

sheepy9 avatar Sep 03 '25 21:09 sheepy9