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

Building paho.mqtt.cpp: cmake doesn't pick up my c++ compiler correctly. #463

Closed
AirborneLizard opened this issue Dec 5, 2023 · 4 comments
Labels
bug Confirmed bug fix added A fix has been pushed to the repo and is being tested
Milestone

Comments

@AirborneLizard
Copy link

I'm trying to build paho.mqtt.cpp in a docker container and cmake doesn't pick up my c++ compiler correctly:

CMake Error at src/CMakeLists.txt:94 (target_compile_options):
Error evaluating generator expression:
$<CXX_COMPILER_ID:MSVC,Clang>
$<CXX_COMPILER_ID> expression requires one or zero parameters.

The container is based on Ubuntu 18.04 and it doesn't have MSVC.

paho.mqtt.c builds just fine.

I've tried setting the CXX environment variables and that didn't help.

Also tried the cmake option -DCMAKE_CXX_COMPILER=clang++ and that didn't help either.

The relevant lines from my Dockerfile are:

paho_mqtt_c

RUN git clone --no-checkout https://github.com/eclipse/paho.mqtt.c.git /usr/src/paho_mqtt_c &&
cd /usr/src/paho_mqtt_c &&
git checkout tags/v1.3.13 &&
mkdir /usr/src/paho_mqtt_c/build &&
cd /usr/src/paho_mqtt_c/build &&
cmake /usr/src/paho_mqtt_c &&
make &&
make install

paho_mqtt_cpp

RUN git clone --no-checkout https://github.com/eclipse/paho.mqtt.cpp.git /usr/src/paho_mqtt_cpp &&
cd /usr/src/paho_mqtt_cpp &&
git checkout tags/v1.3.1 &&
mkdir /usr/src/paho_mqtt_cpp/build &&
cd /usr/src/paho_mqtt_cpp/build &&
cmake /usr/src/paho_mqtt_cpp -DCMAKE_CXX_COMPILER=clang++ -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=FALSE && -DPAHO_MQTT_C_PATH=/usr/src/paho_mqtt_c .
make &&
make install &&
rm -rf /usr/src/paho_mqtt_cpp &&
rm -rf /usr/src/paho_mqtt_c

@fpagliughi
Copy link
Contributor

Oh. Someone recently reported this in one of my other C++ projects.

It’s a CMake thing.

I’m guessing that you’re using a version of CMake older than 3.15. Before that, CXX_COMPILER_ID didn’t allow multiple IDs. But I didn’t realize that and copy/pasted this into a couple of my projects that were claiming to be compliant with older versions.

I was literally going to fix it in the other project this evening. If it works, I’ll fix it here, too

@fpagliughi fpagliughi added the bug Confirmed bug label Dec 5, 2023
@fpagliughi fpagliughi added this to the v1.4 milestone Dec 5, 2023
@AirborneLizard
Copy link
Author

Thanks.

I'm using cmake version 3.10.2 which is the one that's in the Ubuntu 18.04 package store.

@fpagliughi
Copy link
Contributor

OK. That confirms it. But no worries, I'll get it fixed. The build claims to work back to CMake v3.5, and I will make sure that remains true for this version of the library.

In the meantime, if you want to patch and build on your system, in src/CMakeLists.txt, at around line 97, there's a line:

  $<$<NOT:$<CXX_COMPILER_ID:MSVC,Clang>>:-Wall -Wextra>

Change it to:

$<$<NOT:$<OR:$<CXX_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:Clang>>>:-Wall -Wextra -Wpedantic>

@fpagliughi fpagliughi added the fix added A fix has been pushed to the repo and is being tested label Dec 5, 2023
@fpagliughi fpagliughi modified the milestones: v1.4, v1.3.2 Dec 5, 2023
@fpagliughi
Copy link
Contributor

Fixed in v1.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug fix added A fix has been pushed to the repo and is being tested
Projects
None yet
Development

No branches or pull requests

2 participants