Include the bcm2835 library for the Raspberry Pi

Hello everyone, I`m new to this forum and CMake.

For a school project, we are working with c++.

And we are using CMake to link and build the files.
Now a few months in the project I’m working with the MLX90461 IR camera.
I’m using the following GitHub project to make the IR camera

In this GitHub project, there is a simple example code which can be run with the makefile.
But I want to include the example code to the CMakeLists.
I have the following CMakeFile.txt file

cmake_minimum_required(VERSION 3.10)



add_executable(robot main.cpp) # Ignore this file for now, this one works great!
add_executable(camera MLX90641/Examples/print_grid.cpp)

# Add files to libray for the MLX90641 #

# MLX90641 #
target_link_libraries(mlx90641 -lm)
target_link_libraries(mlx90641 -lbcm2835)

add_definitions(-I/usr/include -L/usr/lib -lwiringPi)

target_link_libraries(camera mlx90641)

When I run the exmaple code with the make file it runs:
g++ -IHeaders/ MLX90641_API.cpp MLX90641_I2C_Driver.cpp Examples/print_grid.cpp -o printgrid -lm -lbcm2835

And it links the bcm2835 library. But somehow I can’t get it to work via the CMakeLists.txt file.
In bouth the MLX90641_API.cpp and print_grid.cpp There is a #include <bcm2835.h> without a error of CLion.

I have installed the bcm2835 file based on this anwers on the Raspberry pi forum:

Is there somebody here that could me out with this? I’m stuck at this problem for 3 days now.

Is there nobody out there that could help me out with linking the BCM2835 library?

These are not definitions. I expect you want target_include_directories, target_link_directories, and target_link_libraries for the three flags here.