Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJSON discovery fails even if WITH_CJSON=OFF #2026

Closed
madhat1 opened this issue Jan 17, 2021 · 2 comments
Closed

CJSON discovery fails even if WITH_CJSON=OFF #2026

madhat1 opened this issue Jan 17, 2021 · 2 comments
Milestone

Comments

@madhat1
Copy link
Contributor

madhat1 commented Jan 17, 2021

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!

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.

Closes eclipse#2026.

Signed-off-by: Boris Feinstein <[email protected]>
@ralight
Copy link
Contributor

ralight commented Jan 19, 2021

It feels like the whole point of FIND_PACKAGE(cJSON) is to deal with this... but ok, if it works I'm happy.

@ralight ralight added this to the 2.0.6 milestone Jan 19, 2021
@madhat1
Copy link
Contributor Author

madhat1 commented Jan 19, 2021

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'.

@madhat1 madhat1 closed this as completed Jan 19, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants