Detecting PCAN driver in application's CMake

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
Vicky
Posts: 2
Joined: Wed 15. Jan 2020, 15:55

Detecting PCAN driver in application's CMake

Post by Vicky » Tue 3. Mar 2020, 10:21

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,

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: Detecting PCAN driver in application's CMake

Post by S.Grosjean » Fri 6. Mar 2020, 13:00

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,
— Stéphane

Post Reply