Annoying behavior of `CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=ON` on Windows hosts
I'm trying to use PATH
only for finding programs, and nothing else.
But on Windows this doesn't work. There, CMake seems to search the parent of each directory in the PATH
as a prefix.
I found the culprit in cmFindBase::FillSystemEnvironmentPath()
:
#if defined(_WIN32) || defined(__CYGWIN__)
paths.AddEnvPrefixPath("PATH", true);
#endif
I think I see the rationale behind this, but I think it would be good to have a flag to disable this behavior.
I tried setting CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
and CMAKE_PROGRAM_PATH
to the contents of PATH
, but it causes more problems (my binutils are in a custom directory, and CMakeFindBinUtils.cmake
ignores CMAKE_PROGRAM_PATH
).
I'm also forced to use CMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF
, because enabling it extracts the paths from PATH
too.
Edited by Egor