A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://arduinojson.org/v7/how-to/use-arduinojson-with-cmake/ below:

How to use ArduinoJson with CMake?

This page explains how to include the ArduinoJson library in your CMake project.

Method 1: using the FetchContent module

If you use CMake 3.14 or above, you can use the built-in FetchContent module.

cmake_minimum_required(VERSION 3.14)
project(example)

include(FetchContent)
FetchContent_Declare(ArduinoJson
    GIT_REPOSITORY https://github.com/bblanchon/ArduinoJson.git
    GIT_TAG        v7.4.2
)
FetchContent_MakeAvailable(ArduinoJson)

add_executable(example example.cpp)
target_link_libraries(example ArduinoJson)
Method 2: using cget

Alternatively, you can use the cget package manager.

On the command line prompt, run:

cget install bblanchon/ArduinoJson

Then, in your CMakeLists.txt, add the following:

cmake_minimum_required(VERSION 3.0)
project(example)

include(cget/cget/cget.cmake)
find_package(ArduinoJson 7 REQUIRED)

add_executable(example example.cpp)
target_link_libraries(example ArduinoJson)
Method 3: using git submodule

Lastly, you can rely on Git submodules to fetch the ArduinoJson source.

On the command line prompt, run:

git submodule add https://github.com/bblanchon/ArduinoJson.git third-party/ArduinoJson

Then, in your CMakeLists.txt, add the following:

cmake_minimum_required(VERSION 3.0)
project(example)

add_subdirectory(third-party/ArduinoJson)

add_executable(example example.cpp)
target_link_libraries(example ArduinoJson)
  1. Home
  2. Version 7
  3. How To's
  4. How to use ArduinoJson with CMake?

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4