eclipse / paho.mqtt.cpp

Other
1.01k stars 432 forks source link

Build with PAHO_WITH_MQTT_C is broken #469

Closed ZaychukAleksey closed 3 months ago

ZaychukAleksey commented 9 months ago
git clone --recurse-submodules https://github.com/eclipse/paho.mqtt.cpp.git
cd paho.mqtt.cpp/
cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_STATIC=ON -DPAHO_BUILD_DOCUMENTATION=OFF -DPAHO_BUILD_SAMPLES=OFF

yields:

CMake Error at CMakeLists.txt:60 (add_subdirectory):
  add_subdirectory given source
  "/tmp/paho.mqtt.cpp/scr/externals/paho-mqtt-c" which is not an existing
  directory.

CMake Error at CMakeLists.txt:64 (add_library):
  add_library cannot create ALIAS target "eclipse-paho-mqtt-c::paho-mqtt3a"
  because target "paho-mqtt3a" does not already exist.

CMake Error at CMakeLists.txt:66 (add_library):
  add_library cannot create ALIAS target "eclipse-paho-mqtt-c::paho-mqtt3as"
  because target "paho-mqtt3as" does not already exist.

Which is definitely a bug in CmakeLists since that line should look like this:

add_subdirectory(${PROJECT_SOURCE_DIR}/src/externals/paho-mqtt-c)

But even after fixing the line, the build still fails with:

CMake Error in cmake/CMakeLists.txt:
  export called with target "paho-mqttpp3" which requires target
  "paho-mqtt3as" that is not in any export set.

CMake Error in cmake/CMakeLists.txt:
  export called with target "paho-mqttpp3" which requires target
  "paho-mqtt3as" that is not in any export set.

CMake Error in cmake/CMakeLists.txt:
  export called with target "paho-mqttpp3-static" which requires target
  "paho-mqtt3as" that is not in any export set.
BillyChen39 commented 9 months ago

I can reproduce this error.

CMake Error in cmake/CMakeLists.txt:
  export called with target "paho-mqttpp3" which requires target
  "paho-mqtt3as" that is not in any export set.

But even with this error message, i can still compile the library by running cmake --build build. I'm not sure why this message appears.

fpagliughi commented 9 months ago

Yes, apologies. I should have marked the PAHO_WITH_MQTT_C feature as experimental. It came in as a PR and I didn't fully test it before the release. There is a PR up on the Paho C repo and some updates in the repo here that should get it working better.

charanhs123 commented 8 months ago

Hello , the build error is persistent and the cmake cant be completed

-ThinkPad-T16-Gen-1:~/paho.mqtt.cpp$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_STATIC=ON -DPAHO_BUILD_DOCUMENTATION=ON -DPAHO_BUILD_SAMPLES=ON -- Paho C: Bundled CMake Error at CMakeLists.txt:60 (add_subdirectory): The source directory

/home/charanhs/paho.mqtt.cpp/src/externals/paho-mqtt-c

does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:64 (add_library): add_library cannot create ALIAS target "eclipse-paho-mqtt-c::paho-mqtt3a" because target "paho-mqtt3a" does not already exist.

CMake Error at CMakeLists.txt:66 (add_library): add_library cannot create ALIAS target "eclipse-paho-mqtt-c::paho-mqtt3as" because target "paho-mqtt3as" does not already exist.

-- Configuring incomplete, errors occurred! See also "/home/charanhs/paho.mqtt.cpp/build/CMakeFiles/CMakeOutput.log".

fpagliughi commented 3 months ago

I was waiting for an update to the Paho C library to get the build issues cleaned up, but there hasn't been a release there in a while, so I reworked the build to just work with the existing C v3.1.13.

I think this should all be fixed in master now, though I still need to test on Windows and MacOS. Let me know if you still see a problem.

fpagliughi commented 3 months ago

I believe (hope) this is fixed. If not, please re-open.