CMake incompatible with nix flake (develop) - $out is prefixed in src dir

nix develop prefixes $out with $PWD. I thought it is great until I found a CMake project that fails because of that.

I am tring to develop qtmqtt v6.4.1. I run nix develop -f <file> in the repo. Contents of <file> is below.

{ pkgs ? import /nix/store/jgpswiw206q2dda3aafcs7115flwxamk-source { } }:
let
  drv = { qtModule, fetchFromGitHub, qtdeclarative, qtwebsockets }:
    qtModule rec {
      pname = "qtmqtt";
      version = "6.4.1";
      src = fetchFromGitHub {
        owner = "qt";
        repo = pname;
        rev = "v${version}";
        hash = "sha256-KCGHKxfRHpuzvKRERI6ROn+M2LPf5LTlcnd9eCUutZY=";
      };
      qtInputs = [ qtdeclarative qtwebsockets ];
    };
in
pkgs.qt6.callPackage drv {}

CMake fails with error.

CMake Error in src/mqtt/CMakeLists.txt:
  Target "Mqtt" INTERFACE_INCLUDE_DIRECTORIES property contains path:

    "/home/user/qtmqtt/outputs/dev/include/QtMqtt"

  which is prefixed in the source directory.

I found some resources that seem relevant here.

That problem should happen often. As long as you wish to build a developer snapshot of any library with CMake config. While $out is installation path, the project fails before that - at configuration.

I can work around the problem by changing $out to point outside the repo or enter nix develop -f <file> outside the repo. However, this goes against intended behaviour, right?

Same does not apply for nix-shell; in that case $out is in /nix/store.

Does it mean that nix flake does not support development shell for a CMake project?