cmake: How to check existence of an unreadable file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












Theoretically, cmake can check for the existence of a file



if(EXISTS "/dev/spidev0.0")


according to the documentation this should be True if the named file or directory exists. Behavior is well-defined only for full paths., but I found that the said condition fails if the user has neither read not write rights on that file. If I add the permissions, it works.



However, the user that builds the project is not supposed to access the device, so the file permissions are zero for him. The built software will run under a different account with SPI access, so the corresponding module is to be build if the device file is found. test -e /dev/spidev0.0 is true, but cmake seems to do test -r.



As a workaround, I can check for the symlink in /sys/class/spidev/spidev0.0, but what's the correct way to handle the problem?







share|improve this question




















  • I’m curious — why does the build vary depending on the presence of a device? Would it not be possible to build the project with SPI support in all cases, and check for the presence of the device at runtime? After all, software can be built on one system for use on another, with different devices, or a device can come and go during a system’s lifetime...
    – Stephen Kitt
    Apr 10 at 11:47










  • You are mainly right. During development, the software is build and tested on a variety of devices (Jenkins build slaves). It's a lazy way of handling the features along with their tests in cmake. And there is a whole bunch of similar switches! We probably won't keep this after market release.
    – Philippos
    Apr 10 at 12:12















up vote
0
down vote

favorite
1












Theoretically, cmake can check for the existence of a file



if(EXISTS "/dev/spidev0.0")


according to the documentation this should be True if the named file or directory exists. Behavior is well-defined only for full paths., but I found that the said condition fails if the user has neither read not write rights on that file. If I add the permissions, it works.



However, the user that builds the project is not supposed to access the device, so the file permissions are zero for him. The built software will run under a different account with SPI access, so the corresponding module is to be build if the device file is found. test -e /dev/spidev0.0 is true, but cmake seems to do test -r.



As a workaround, I can check for the symlink in /sys/class/spidev/spidev0.0, but what's the correct way to handle the problem?







share|improve this question




















  • I’m curious — why does the build vary depending on the presence of a device? Would it not be possible to build the project with SPI support in all cases, and check for the presence of the device at runtime? After all, software can be built on one system for use on another, with different devices, or a device can come and go during a system’s lifetime...
    – Stephen Kitt
    Apr 10 at 11:47










  • You are mainly right. During development, the software is build and tested on a variety of devices (Jenkins build slaves). It's a lazy way of handling the features along with their tests in cmake. And there is a whole bunch of similar switches! We probably won't keep this after market release.
    – Philippos
    Apr 10 at 12:12













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





Theoretically, cmake can check for the existence of a file



if(EXISTS "/dev/spidev0.0")


according to the documentation this should be True if the named file or directory exists. Behavior is well-defined only for full paths., but I found that the said condition fails if the user has neither read not write rights on that file. If I add the permissions, it works.



However, the user that builds the project is not supposed to access the device, so the file permissions are zero for him. The built software will run under a different account with SPI access, so the corresponding module is to be build if the device file is found. test -e /dev/spidev0.0 is true, but cmake seems to do test -r.



As a workaround, I can check for the symlink in /sys/class/spidev/spidev0.0, but what's the correct way to handle the problem?







share|improve this question












Theoretically, cmake can check for the existence of a file



if(EXISTS "/dev/spidev0.0")


according to the documentation this should be True if the named file or directory exists. Behavior is well-defined only for full paths., but I found that the said condition fails if the user has neither read not write rights on that file. If I add the permissions, it works.



However, the user that builds the project is not supposed to access the device, so the file permissions are zero for him. The built software will run under a different account with SPI access, so the corresponding module is to be build if the device file is found. test -e /dev/spidev0.0 is true, but cmake seems to do test -r.



As a workaround, I can check for the symlink in /sys/class/spidev/spidev0.0, but what's the correct way to handle the problem?









share|improve this question











share|improve this question




share|improve this question










asked Apr 10 at 11:43









Philippos

5,90211545




5,90211545











  • I’m curious — why does the build vary depending on the presence of a device? Would it not be possible to build the project with SPI support in all cases, and check for the presence of the device at runtime? After all, software can be built on one system for use on another, with different devices, or a device can come and go during a system’s lifetime...
    – Stephen Kitt
    Apr 10 at 11:47










  • You are mainly right. During development, the software is build and tested on a variety of devices (Jenkins build slaves). It's a lazy way of handling the features along with their tests in cmake. And there is a whole bunch of similar switches! We probably won't keep this after market release.
    – Philippos
    Apr 10 at 12:12

















  • I’m curious — why does the build vary depending on the presence of a device? Would it not be possible to build the project with SPI support in all cases, and check for the presence of the device at runtime? After all, software can be built on one system for use on another, with different devices, or a device can come and go during a system’s lifetime...
    – Stephen Kitt
    Apr 10 at 11:47










  • You are mainly right. During development, the software is build and tested on a variety of devices (Jenkins build slaves). It's a lazy way of handling the features along with their tests in cmake. And there is a whole bunch of similar switches! We probably won't keep this after market release.
    – Philippos
    Apr 10 at 12:12
















I’m curious — why does the build vary depending on the presence of a device? Would it not be possible to build the project with SPI support in all cases, and check for the presence of the device at runtime? After all, software can be built on one system for use on another, with different devices, or a device can come and go during a system’s lifetime...
– Stephen Kitt
Apr 10 at 11:47




I’m curious — why does the build vary depending on the presence of a device? Would it not be possible to build the project with SPI support in all cases, and check for the presence of the device at runtime? After all, software can be built on one system for use on another, with different devices, or a device can come and go during a system’s lifetime...
– Stephen Kitt
Apr 10 at 11:47












You are mainly right. During development, the software is build and tested on a variety of devices (Jenkins build slaves). It's a lazy way of handling the features along with their tests in cmake. And there is a whole bunch of similar switches! We probably won't keep this after market release.
– Philippos
Apr 10 at 12:12





You are mainly right. During development, the software is build and tested on a variety of devices (Jenkins build slaves). It's a lazy way of handling the features along with their tests in cmake. And there is a whole bunch of similar switches! We probably won't keep this after market release.
– Philippos
Apr 10 at 12:12
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436753%2fcmake-how-to-check-existence-of-an-unreadable-file%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436753%2fcmake-how-to-check-existence-of-an-unreadable-file%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay