Hi CMake Community,
I recently migrated my development environment from Windows 10 to Windows 11, and I’ve run into a problem with compiling my project using CMake.
The error message I’m getting is:
ERROR:
‘c:\users\ABC’ is not recognized as an internal or external command,
operable program or batch file
My project is located at: C:\Users\ABC\workspace\cmakeProject.
When I run the CMake build, I get this error, which suggests that the path is being misinterpreted or not handled correctly,
likely because of the spaces or special characters in the C:\Users\ABC portion of the path.
What I’ve tried so far:
Using double quotes around the path (e.g., “C:\Users\ABC(1)\workspace\cmakeProject”) in CMake-related commands.
Checking that there are no issues with how CMake is configured or any hardcoded paths in the CMakeLists.txt.
Despite these efforts, the issue persists.
Questions:
Has anyone encountered similar issues with Windows 11 where paths with spaces or special characters break CMake or the build process?
Are there specific CMake settings or workarounds that can help avoid this path issue?
Is there a known bug or patch related to this in newer versions of CMake that I should be aware of?
Any guidance or suggestions would be greatly appreciated!
Thanks in advance!
Paths with spaces and unicode characters are covered by our nightly tests. Most likely, the problem is in how you are invoking CMake, or in how you are defining paths that CMake uses during processing. Perhaps if you showed the commands you’re issuing and the paths from which you’re running, that might help. I would also recommend you reduce your problem down to a minimal but complete project that demonstrates your problem. Trying to provide this very often uncovers the cause on its own.
Hi Scott ,
I have created a small cmake project and we are trying to compile it through visual studio as well as command prompt . But it is throwing the above error when trying to do it . Attaching the cmakelists.txt here
The cmake project is placed within a folder with no special characters in the folder path , yet seeing the same issue
Can you show the sequence of commands you use to reproduce the problem? Start from scratch, i.e. no build directory. Make sure you also show the directory path you’re executing from (i.e. what’s your current working directory when you run the command(s)?). And when running the commands from a command line, how did you prepare the environment (how/did you use vcvars.bat or something similar?).
Here though the project is not within a folder with special characters , its still pointing to my userprofile directory and throwing the error that its doesnt recognize it as an internal or external command
You didn’t answer this part. It seems like whatever environment you’re running the commands in cannot find the msbuild
tool. That suggests you might be missing the command line tools, so perhaps your Visual Studio installation needs a component to be enabled/added. Either that, or you haven’t prepared your environment correctly, hence the above question I asked you to answer in my previous reply.
we dont setup any env before building the cmake project . We use Visual studio to build the cmake project
CMake requires the environment to be properly set up for the toolchain you’re using. If you’re building at a command line, you can’t just open a plain DOS prompt, PowerShell, etc. You must set up the environment correctly, and Visual Studio provides a batch script that does that for you. There should also be Start menu entries that open an appropriately configured shell/window for you to work in. I suggest you look into those, as you won’t be able to build successfully from the command line without them.
If you’re building within the Visual Studio IDE, then Visual Studio itself should be providing an appropriately configured environment internally without you doing anything. If that’s not the case, then you likely have a broken Visual Studio installation, but I can’t offer any further guidance on how to investigate that (I use VS rarely).
Hi Scott ,
This is exactly the same project we are trying to compile through either command line/visual studio -Hello world with CMake
The same project worked fine when my user profile was set with C:/Users/ABC and now with recent migration to windows 11 , the user profile is now set to C:/Users/ABC( and the same cmake project doesnt seem to build with this new change . Also the compilation is failing from the line in cmakelists.txt which has
Project(DummyProj) . it would really help me if you can help me with any details if you know on whether anywhere the user directory defined under environment is used internally for creating anything within appdata or anywhere etc . In order to build this the setup we have followed is same as old.
Please let know your thoughts on the issue.
Thanks