eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.05k stars 2.39k forks source link

FindcJSON.cmake is not able to find cJSON #2691

Open steinlec opened 1 year ago

steinlec commented 1 year ago

I have the need to compile mosquitto 2.0.15 with cJSON on Ubuntu 18.04. In this context I use cJSON from source, compile it, and install it to an image directory with make DESTDIR=<...> install. While doing this, the file ./cmake/FindcJSON.cmake is not able to find cJSON in the image directory, even if I set export CJSON_DIR=<...>. But if I modify the file ./cmake/FindcJSON.cmake in the corresponding way, everything works fine.

--- a/cmake/FindcJSON.cmake
+++ b/cmake/FindcJSON.cmake
@@ -10,12 +10,14 @@ FIND_PATH(
                CJSON_INCLUDE_DIR
                cjson/cJSON.h
        HINTS
-               CJSON_DIR
+               ${CJSON_DIR}
+               PATH_SUFFIXES usr/local/include usr/include
 )

 FIND_LIBRARY( CJSON_LIBRARY
        NAMES cjson
        HINTS ${CJSON_DIR}
+       PATH_SUFFIXES usr/local/lib usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
 )

 FIND_PACKAGE_HANDLE_STANDARD_ARGS( cJSON DEFAULT_MSG

Maybe this patch would be helpful.

eye-c commented 1 year ago

I have the need to compile mosquitto 2.0.15 with cJSON on Ubuntu 18.04. In this context I use cJSON from source, compile it, and install it to an image directory with make DESTDIR=<...> install. While doing this, the file ./cmake/FindcJSON.cmake is not able to find cJSON in the image directory, even if I set export CJSON_DIR=<...>. But if I modify the file ./cmake/FindcJSON.cmake in the corresponding way, everything works fine.

@steinlec I'm trying to compile mosquitto with cJSON but cJSON is not found. I looked into installing cJSON but there are many libs with that name. Which version of cJSON are you using?

steinlec commented 1 year ago

@eye-c I am using https://github.com/DaveGamble/cJSON in version 1.7.15.