if(EXISTS): checks for read permissions for files, not for existence
Tested OS:
> lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
CMake script:
> cat script.cmake
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/a.txt")
message("OK")
else()
message("FAIL")
endif()
File to test:
> touch a.txt
> chmod +r a.txt
> cmake -P script.cmake
OK
Removing read permission, but not file:
> chmod -r a.txt
> ls a.txt
a.txt
> cmake -P script.cmake
FAIL
CMake version:
> cmake --version
cmake version 3.27.0
I guess it's here:
Not sure why R_OK
is used there since F_OK
is already mentioned.