include Adafruit BNO055 libraries in Qt project using CMake

Hello,

I want to include an Adafruit BNO055 sensor to my Qt project using CMAke.

I downloaded the drivers from: GitHub - adafruit/Adafruit_BNO055: Unified sensor driver for the Adafruit BNO055 orientation sensor breakout

The driver does not have a CMakeLists.txt. So i tried to make one of my own:

cmake_minimum_required (VERSION 2.6)



SET( UTILITY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utility )

SET( ARDUINO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/arduino )

SET( INCLUDEPATH ${CMAKE_CURRENT_SOURCE_DIR} )



set(CMAKE_AUTOMOC ON)





include_directories(${INCLUDEPATH})



SET( SOURCES ${SOURCES}

   	Adafruit_BNO055.cpp

	${UTILITY_PATH}/imumaths.h

	${UTILITY_PATH}/matrix.h

	${UTILITY_PATH}/quaternion.h

	${UTILITY_PATH}/vector.h

	${ARDUINO_PATH}/Arduino.h

	${ARDUINO_PATH}/WProgram.h



   )



IF(WIN32)

        SET(SOURCES ${SOURCES}

        Adafruit_BNO055.h

	${UTILITY_PATH}/imumaths.h

	${UTILITY_PATH}/matrix.h

	${UTILITY_PATH}/quaternion.h

	${UTILITY_PATH}/vector.h

	${ARDUINO_PATH}/Arduino.h

	${ARDUINO_PATH}/WProgram.h

)

ENDIF(WIN32)



add_executable(${PROJECTNAME} ${SOURCES})

SETUP_TARGET_BUILD(${PROJECTNAME})



INSTALL(TARGETS ${PROJECTNAME} RUNTIME

DESTINATION ${CMAKE_INSTALL_PREFIX}

LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})

When I compile my code, I get the following error:

In file included from /home/user/projekte/arNew/source/ext.drivers/src/ext/drivers/imu/adafruit/Adafruit_BNO055.cpp:24:0:
/home/user/projekte/arNew/source/ext.drivers/src/ext/drivers/imu/adafruit/arduino/WProgram.h:8:27: fatal error: avr/interrupt.h: No such file or directory
 #include <avr/interrupt.h>
                           ^
compilation terminated.
make[2]: *** [ext.drivers/src/ext/drivers/imu/adafruit/CMakeFiles/ext.drivers.dir/Adafruit_BNO055.cpp.o] Error 1

I have installed the Arduino 1-8.7 in my usr/share location

Do I have to include something like find_package(Arduino REQUIRED xyz) to make this work?

On Windows at least I'd install the library using the IDE library manager. Qt sounds like a GUI widgetset, dunno how this is related to Arduino.

Hello,

Thank you for your reply. I did install the default libraries on the Ubuntu using Arduino IDE.
The libraries are located in "/usr/share/arduino 1.8.7/libraries" and also in "usr/lib/avr"

Usually in CMake to locate any libraries we use the "find_package" command. Unfortunately, that does not work with the Arduino libraries. So is there a way that I can locate these libraries in my CMakeList?

The error i get when i use the find_package command is this:

"By not providing "FindArduino.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Arduino", but CMake did not find one. Could not find a package configuration file provided by "Arduino" with any of the following names: ArduinoConfig.cmake arduino-config.cmake Add the installation prefix of "Arduino" to CMAKE_PREFIX_PATH or set "Arduino_DIR" to a directory containing one of the above files. If "Arduino" provides a separate development package or SDK, be sure it has been installed."

Why don't you use the Arduino IDE for Arduino projects? Find help for other development systems in the related groups, not here.