# How to detect "dot" in PATH

**URL:** <https://discourse.cmake.org/t/how-to-detect-dot-in-path/6551>\
**Category:** Code\
**Created:** [September 22, 2022, 3:42pm UTC](https://discourse.cmake.org/t/how-to-detect-dot-in-path/6551 "2022-09-22T15:42:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathomp4](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mathomp4/32/176_2.png) [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Post date:** [September 22, 2022, 3:42pm UTC](https://discourse.cmake.org/t/how-to-detect-dot-in-path/6551/1 "2022-09-22T15:42:50Z")

</div>

All,

This is a fun one. In trying to help a user of a library I help maintain, he was having all sorts of issues at CMake time. After a day or so of puzzling over `--trace --debug-find` output, I finally realized the issue was that he had `.` in his `PATH`. This library simply builds a few sublibraries with `add_subdirectory()` in order.

And since `find_package()` is _really_ good at finding things on a system, it was finding a half-baked `.cmake` file in a subdirectory under the build dir and not, say, the “real” one that would be installed in the install step.

Now, I never run with dot-in-PATH as I learned long ago that is trouble. And the other devs I consulted on this also don’t have dot-in-PATH so they couldn’t replicate either. So I was wondering, does anyone know a good way to maybe have CMake search `$PATH` for it? I figure `list(FIND)` could do it but I’d need to convert `$ENV{PATH}` to a list somehow?

Thanks,  
Matt

Note: I know a “better” solution might be to add `NO_SYSTEM_ENVIRONMENT_PATH` in to the `find_package()` calls that are being done, but I keep fearing dot-in-PATH might come back to haunt me.

Note2: I suppose even better is moving to ExternalProject\_Add, but that’s future me issue. 🙂

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [September 27, 2022, 7:06pm UTC](https://discourse.cmake.org/t/how-to-detect-dot-in-path/6551/2 "2022-09-27T19:06:42Z")

</div>

> [@mathomp4](#):
>
> So I was wondering, does anyone know a good way to maybe have CMake search `$PATH` for it? I figure `list(FIND)` could do it but I’d need to convert `$ENV{PATH}` to a list somehow?

There is `cmake_path(CONVERT <input> TO_CMAKE_PATH_LIST <out-var> [NORMALIZE])` that you can use to get a CMake list from the environment variable.
