When building using cmake, and providing -DWITH_CJSON=OFF the cJson discovery process is still running and failing if I don't have cJson installed.
A simple fix in the main CMakeLists.txt will do the trick, surround the following block:
FIND_PACKAGE(cJSON) if (CJSON_FOUND) message(STATUS ${CJSON_FOUND}) else (CJSON_FOUND) message(STATUS "Optional dependency cJSON not found. Some features will be disabled.") endif(CJSON_FOUND)
with an :
if (WITH_CJSON) ... endif()
That's all!
The text was updated successfully, but these errors were encountered:
madhat1
added a commit
to madhat1/mosquitto
that referenced
this issue
Jan 17, 2021
When using cmake to build the project, cJson discovery
should only be performed if WITH_CJSON=ON.
Closeseclipse#2026.
Signed-off-by: Boris Feinstein <madhat1@gmail.com>
You're right, but logically if WITH_CJSON=OFF was provided it's not correct to perform the discovery to begin with and show the 'missing cJson' warning, in this case the user explicitly wants to not use cJson. FIND_PACKAGE(cJSON) may fail if the build environment contains a misconfigured or otherwise irrelevant cJson (for a different architecture for example).
Anyway, the fix solves all potential errors and avoids performing discovery if WITH_CJSON=OFF was provided thus adhering to the developers wishes to 'not use cJson'.
When building using cmake, and providing -DWITH_CJSON=OFF the cJson discovery process is still running and failing if I don't have cJson installed.
A simple fix in the main CMakeLists.txt will do the trick, surround the following block:
FIND_PACKAGE(cJSON)
if (CJSON_FOUND)
message(STATUS ${CJSON_FOUND})
else (CJSON_FOUND)
message(STATUS "Optional dependency cJSON not found. Some features will be disabled.")
endif(CJSON_FOUND)
with an :
if (WITH_CJSON)
...
endif()
That's all!
The text was updated successfully, but these errors were encountered: