Page 1 of 1

Detecting PCAN driver in application's CMake

Posted: Tue 3. Mar 2020, 10:21
by Vicky
Hello everyone,

I've got an application that uses PCI devices from PEAK systems. Earlier I was using socketCAN to read and write CAN messages. Recently, I added a feature to accommodate the pcan driver as well. Currently, I'm using,

Code: Select all

option(CAN_DRIVER "CAN driver option" sockcan)
in CMake to switch between pcan and socketCAN using a macro, where the user is forced to set
CAN_DRIVER
option to
pcan
during CMake execution to use pcan linker for building appropriate libraries that will be linked to my application.

I'm thinking of getting rid of this compile-time option such a way that the CMake can use pcan driver whenever available else socket CAN is used. I would be happy if someone could let me whether there are some environmental variables or CMake macro that can be used to detect the presence of a pcan driver?

Regards,

Re: Detecting PCAN driver in application's CMake

Posted: Fri 6. Mar 2020, 13:00
by S.Grosjean
Hi,

What do you mean with "the presence of a pcan driver"?

If you want to know whether the pcan driver is loaded, then your application can test the existence of the file "/sys/class/pcan/version".

Regards,