cmake: How to check existence of an unreadable file
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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?
permissions devices cmake
add a comment |Â
up vote
0
down vote
favorite
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?
permissions devices cmake
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 incmake
. And there is a whole bunch of similar switches! We probably won't keep this after market release.
â Philippos
Apr 10 at 12:12
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
permissions devices cmake
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?
permissions devices cmake
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 incmake
. And there is a whole bunch of similar switches! We probably won't keep this after market release.
â Philippos
Apr 10 at 12:12
add a comment |Â
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 incmake
. 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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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