Path names longer than MAX_PATH fail on Windows, even if long paths support is enabled
I am having multiple issues due to including out-of-source dependencies in a CMake project. As CMake uses the absolute path of those, the final path length exceeds the Win32 260-character limit, even when the system is configured to support longer paths. Some file operations pass with such a long path, while others fail with seemingly unrelated messages.
## Environment tested
* CMake version: 3.29
* Operating System: Windows 11 23H2 22631.3447
* System has long path support enabled, and verified working
* Generators: Ninja, MinGW Makefiles and Visual Studio 2022
## Minimally reproducible example
1. Create an empty CMake project
2. Set the build folder to a long name during configuration
* I've used `123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345`, 255-character long.
3. Configuration should fail with an error message of the form `TryCompile` with `Failed to set working directory to <folder>: No such file or directory`.
## Observations
1. By debugging and pausing on the error, I observed that, during the execution, `cmSystemTools::FileIsDirectory` returns true, and there are files inside the folder. So `Mkdir` and other operations worked there correctly, as expected. It always fails at the change of working directory.
2. Microsoft [documents](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry) that, by adding `longPathAware` to the application manifest, we should be able to remove this limit for the `SetCurrentDirectoryW` function. I have tried replacing `_wchdir` with `SetCurrentDirectoryW` on `cmSystemTools::ChangeDirectory`, also adding the clause to the `cmake.version.manifest` file, and even tried using `Encoding::ToWindowsExtendedPath` instead of `Encoding::ToWide` in conjunction with those, but with no success.
3. Some discussion in [this StackOverflow thread](https://stackoverflow.com/questions/56378526/how-to-change-the-current-directory-to-a-long-path) seems to also have issues, though [this GitHub issue from Microsoft](https://github.com/MicrosoftDocs/feedback/issues/1441) indicates that it should work with those steps before. As I was not able to do so, I am opening this issue instead.
4. Although `TryCompile` is not the only issue I encountered, it is the most easily reproducible, and should hopefully point out to a possible solution for the file moving/renaming issue caused by the same path length reason.
issue