# Confusion using cmake\_path(HAS\_FILENAME \<path-var\> \<out-var\>)

**URL:** https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749
**Category:** Code
**Created:** [October 10, 2024, 11:55am UTC](https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749 "2024-10-10T11:55:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![octopus42](https://discourse.cmake.org/user_avatar/discourse.cmake.org/octopus42/32/4646_2.png) [@octopus42](https://discourse.cmake.org/u/octopus42)
#### Post date: [October 10, 2024, 11:55am UTC](https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749/1 "2024-10-10T11:55:29Z")

</div>

I’m attempting to use cmake\_path(HAS\_FILENAME ) to determine if a file exists within a path. I’m either using it incorrectly or something else is going on because it always return ‘ON’.

Basically, I’m doing this (an example)

```auto
set(path "C:/My_Dir/test/my.dll")
cmake_path(HAS_FILENAME path isThere)
message(STATUS "Eval: ${isThere}")

```

Every run prints “Eval: ON” no matter if that path contains my.dll or not. I’ve even set the path to an empty dir and it still return ON. Also tried setting isThere to false before execution of the cmake\_path line and it gets changed to ON

What am I doing wrong?

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [October 10, 2024, 1:22pm UTC](https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749/2 "2024-10-10T13:22:47Z")

</div>

to quote the documentation:

> [@https://cmake.org/cmake/help/latest/command/cmake\_path.html](#):
>
> This command is for the manipulation of paths. Only syntactic aspects of paths are handled, there is no interaction of any kind with any underlying file system. The path may represent a non-existing path or even one that is not allowed to exist on the current file system or platform. For operations that do interact with the filesystem, see the [`file()`](https://cmake.org/cmake/help/latest/command/file.html#command:file) command.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [October 10, 2024, 4:27pm UTC](https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749/3 "2024-10-10T16:27:26Z")

</div>

see too CMake [file-operations](https://cmake.org/cmake/help/latest/command/if.html#file-operations)
