CMake Warning: No source or binary directory provided.

Hi,

I’ve been using CMake for my project since almost 2 years ago, it always worked fine for me both on Windows and Linux. However, recently when I try to build it locally in my windows machine following an update to Visual Studio, it stops working. Before, Cmake will automatically create a folder /build in the project and works with it, but now I am getting this weird warning:

CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.

And when I try to continue to build the app, I get this error that again I have no idea why it happens:

cmake --build ./build --config Release
Error: could not load cache

Does anyone know why this happens when it was working correctly before? Could this be caused by a breaking change in the latest version of CMake? The same project is able to build on my Ubuntu virtual machine without issue, though it used CMake 3.22.1 which is much older than the CMake on my windows machine. If so, how do I fix this? Thanks.

1 Like

Bump, does anyone know how to fix this issue? It is not writing any files to the /build folder, but in earlier version of CMake this was happening.

I assume you deleted the old build directory before attempting the build with the updated compilers? Usually the cache creates all sort of weird errors when you change something in the build environment.

What is the first CMake command you’re using?

It would be like

cmake -S <source_dir>  -B <build_dir>

For example if already in the top-level project source code directory where CMakeLists.txt is, type

cmake -S . -B build

cmake --build build --config Release