Integrating an external CMake library (github.com/nlohmann/json)

dastoned
Posts: 50
Joined: Fri May 29, 2020 2:52 pm

Integrating an external CMake library (github.com/nlohmann/json)

Postby dastoned » Fri Oct 23, 2020 1:22 pm

Hi!

How am I supposed to import an external CMake library (specifically https://github.com/nlohmann/json) into an ESP-IDF project?

The ESP-IDF does not seem to comply with CMake's usual procedure for pulling in external stuff - adding "add_subdirectory(components/nlohmann_json)" will fail with a nasty error which appears a conflicting definition of "project" function.

Section "Using Third-Party CMake Projects with Components" in the build system documentation enthusiastically promises to "import these third-party projects, sometimes even without modification!" but is starved of all relevant detail. E.g. how do you interface with the external library's CMakeLists? The 9-line snippet of CMake code there I have no idea what to do with - do I put it into my top-level CMakeLists.txt (tried, fails), into main/CMakeLists.txt (tried, fails), the external's CMakeLists.txt, ...?

As an alternative (since https://github.com/nlohmann/json is implemented as header files) I'll gladly take any hack or workaround anybody has found for pulling in this specific JSON library.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 127 guests