Should cmake-gui restore the previous binary directory when the source directory is empty?

When I start cmake-gui, the “Where is the source code” field is empty, but “Where to build the binaries” still contains the binary directory used during the previous session.

Is this the expected behaviour?

It seems potentially unsafe or confusing because, after selecting a new source directory, the GUI still displays a binary directory associated with a previous and possibly unrelated project. A user could then configure the new project into the old project’s build tree. Indeed I’ve observed students often make this mistake.

I would expect one of the following behaviours:

  1. Both fields start empty (the binary-directory history remains available in the drop-down, but the editable field itself starts empty)
  2. Both source and binary directories are restored as a pair.

Before filing an issue, could someone confirm which behaviour is intended?

CMake version: 3.25.1 (also observed with CMake version 4.3.4)
Operating system: Debian 12 (also observed on Windows 11)

Personally, I would have thought that if the binary directory is restored, so should the source directory. If the binary directory is missing or doesn’t contain a CMakeCache.txt, then restoring the source directory would only make sense if the app actually knew which source directory corresponded to the binary directory, but it might be relying on details that would normally be in the binary directory to do that (I haven’t checked the app’s source code).

It seems reasonable to me to restore neither if the app can’t reliably determine both. As you say, restoring just the binary directory and not the source directory has its dangers.