I was able to figure it out, I was just inexperienced with CMake. This might sound basic to some of you but I’ll document what I did here if it could be of help for anyone in the future:
- Clone both Paho C and Paho C++ libs to different folders
- Open CMakeGui, select PahoC repo as the source, and create a folder called “bin_cross_compiled” inside it and use it as the target. Hit Configure → Specify Toolchain files for cross-compiling
- Use what is called a toolchain file, which basically contains CMAKE variables for cross-compiling, like which C compiler to use.
Mine is
➜ toolchains cat arm_legato_wp85xx.cmake
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)SET(CMAKE_C_COMPILER /opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER /opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++)
- Make sure to change your
CMAKE_INSTALL_PREFIX
afterwards, otherwisemake install
will install the cross-compiled binaries to your host system. - You can activate various settings (I used SSL, disabled testing, doc, etc…)
- Hit
Generate
- Navigate to your build folder described in step 1
- run
make
thenmake install
and you should have your binaries for Paho-C in the CMAKE_INSTALL_PREFIX folder.
The steps are pretty much the same for Paho C++ but you’ll need to also set up a variable to point to the build folder of PahoC since it needs it to build.