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

Add meson documentation #761

Merged
merged 1 commit into from Jul 3, 2023
Merged

Add meson documentation #761

merged 1 commit into from Jul 3, 2023

Conversation

MaxBrandtner
Copy link
Contributor

The following changes to the README file add documentation, how to use cJSON in a meson project. This would resolve #760.

@Alanscut
Copy link
Collaborator

Hi @MaxBrandtner
Thanks for your contribution. :)

I'm not that familiar with Meson. Is it a framework used to compile and build cjson, like CMake? It looks you only added cjson as a dependency, instead of building cjson.

Besides this, I noticed that example and example.c are also added. Are they releated to cjson?

@MaxBrandtner
Copy link
Contributor Author

Meson is a build system. It has a configuration file meson.build which is the file that I described above. cjson is the variable that holds the dependency libcjson. Because we usually use more than one dependency when programming, the dependenies are stored in a dependency var (which I named cjson) to make it less tedious to debug the execution parameter. Perhaps I should have used a more descriptive name like dependency_list. Furthermore, the source files are usually kept in a sourcefiles variable, which I didn't do, but should have done for the sake of consistency. example.c is the source file(it could carry any other name or be a collection of source files), while example is the executable(which can have any name you want it to have) which is stored in the build directory. The build directory is specified when building the program so if you want to have a build dir .build you would compile the program in the following way.

meson setup .build
ninja -C .build

# execute compiled code
./.build/example

Perhaps a more generalized way would be:
meson.build

project('program-example', 'c')

dependency_list = dependency('libcjson')
sourcefiles = files('example.c')

executable(
    'example',
    sourcefiles,
    dependencies:  dependency_list,
)

@Alanscut
Copy link
Collaborator

Alanscut commented Jul 1, 2023

Thanks for your detailed information! :)
This PR looks good to me now.

@Alanscut Alanscut merged commit 543c288 into DaveGamble:master Jul 3, 2023
@DL6ER DL6ER mentioned this pull request Dec 26, 2023
5 tasks
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

Successfully merging this pull request may close these issues.

how to compile with meson
2 participants