nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
42.97k stars 6.72k forks source link

building with cmake #3880

Closed ozcanay closed 1 year ago

ozcanay commented 1 year ago

Description

Cmake .. && make -j does not work properly on CentOS-7

Reproduction steps

I am having trouble compiling the project. Here is what I am doing:

git clone https://github.com/nlohmann/json.git
cd json
mkdir build
cd build
cmake ..

So far, so good.

However, when I execute:

make -j

Nothing happens, no response at all.

Expected vs. actual results

I was expecting makefile to produce any message.

Minimal code example

No response

Error messages

No response

Compiler and operating system

gcc 10.1.0, CentOS7

Library version

3.11.2 (develop branch)

Validation

nlohmann commented 1 year ago

Which CMake version are you using? Can you share the complete output of running CMake?

ozcanay commented 1 year ago

image

nlohmann commented 1 year ago

This is as expected. Your CMake version is so old that JSON_BuildTests_INIT is unconditionally set to OFF, see https://github.com/nlohmann/json/blob/develop/CMakeLists.txt#L35.

Without setting JSON_BuildTests to ON, the tests will not be built.

Fix: Call

cmake .. -DJSON_BuildTests=ON

or upgrade CMake.

ozcanay commented 1 year ago

I would rather see a warning about this issue, though.

nlohmann commented 1 year ago

When the library is included as third-party, no tests should be compiled unless explicitly specified with -DJSON_BuildTests=ON. This is also documented in the README.

In which situation would you expect a warning?