Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# This CMakeLists.txt file is used to import the jsmn library into your CMake based project.
# Use the add_subdirectory command to include this directory in your build and include jsmn in your target_link_libraries command.
# For example
# add_subdirectory(jsmn build) will import the jsmn library into your projects CMake build system.
# target_link_libraries(example jsmn) will link the jsmn library to your example target.
# You can then use #include "jsmn.h" in your source files to include the jsmn library.

add_library(jsmn INTERFACE)

target_include_directories(jsmn INTERFACE
${CMAKE_CURRENT_LIST_DIR}
)
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,35 @@ If you get `JSMN_ERROR_NOMEM`, you can re-allocate more tokens and call
periodically call `jsmn_parse` and check if return value is `JSMN_ERROR_PART`.
You will get this error until you reach the end of JSON data.


Git Submodule in CMake Projects
-------------------------------

The jsmn library can be integrated into a CMake project as a git submodule
using the CMakeLists.txt file provided in the jsmn repository.

Your project must first be initialized with git:

git init

Then, add the jsmn library as a submodule of your project:

git submodule add https://github.com/zserge/jsmn.git

Next, update the submodules:

git submodule update --init --recursive

Finally, include the jsmn library in your CMakeLists.txt file with the
add_subdirectory and target_link_libraries commands:

add_subdirectory(jsmn build)
target_link_libraries(my_project jsmn)

You can then use #include "jsmn.h" in your source files to include the
jsmn library and begin using the jsmn library.


Other info
----------

Expand Down