Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conan package for json_struct #59

Open
sheepy9 opened this issue Sep 12, 2024 · 5 comments
Open

Conan package for json_struct #59

sheepy9 opened this issue Sep 12, 2024 · 5 comments

Comments

@sheepy9
Copy link
Contributor

sheepy9 commented Sep 12, 2024

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
Copy link
Owner

jorgen commented Sep 12, 2024

Yay! Lets do this!

@sheepy9
Copy link
Contributor Author

sheepy9 commented Sep 13, 2024

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
Copy link
Owner

jorgen commented Sep 13, 2024

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
Copy link
Contributor Author

sheepy9 commented Sep 13, 2024

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
Copy link
Owner

jorgen commented Sep 19, 2024

Hi @sheepy9. I have now created a merge request: conan-io/conan-center-index#25335.

I really appreciate your help, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants