MDK 6 - Clangd choosing the wrong compile commands

The following help says 'After you install clangd, you do not need any extra setup.':
https://developer.arm.com/documentation/108029/0000/Get-started-with-an-example-project/Finalize-the-setup-of-your-development-environment/clangd.

But I cannot get it to work correctly for my own CSolution. I have checked and the issue is also present in the SimpleTrustZone project, but it is not so visible. My own CSolution has different include paths for the for CProject builds, i.e. the non-secure includes RTOS and the secure not. VSCode complains that RTOS related functions are undefined. A check of the clangd output shows that it is choosing the wrong compile commands.

The issue can be reproduced from the CSolution SimpleTrustZone project as follows:

  1. Close all files.
  2. Open main_s.c.
  3. Open the clangd output window.
  4. Restart the clangd server.

In my case I can see the following:

I[17:20:40.959] argv[0]: c:\Users\...\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\19.1.2\clangd_19.1.2\bin\clangd.exe
I[17:20:40.959] argv[1]: --compile-commands-dir=c:\repos\csolution-examples\SimpleTrustZone\out\CM33_s\AVH\Debug
I[17:20:40.959] argv[2]: --compile-commands-dir=c:\repos\csolution-examples\SimpleTrustZone\out\CM33_ns\AVH\Debug
and:
I[17:20:40.999] Loaded compilation database from c:\repos\csolution-examples\SimpleTrustZone\out\CM33_ns\AVH\Debug\compile_commands.json
I[17:20:41.000] ASTWorker building file c:\repos\csolution-examples\SimpleTrustZone\CM33_s\main_s.c version 1 with command inferred from C:\repos\csolution-examples\SimpleTrustZone\CM33_ns\main_ns.c
It can be seen that the compile command folders from both CProject folders are provided to clangd, but it is choosing the wrong compilation options, The AST worker is using a compilation command inferred from an CM33_ns CProject file to build and a CM33_s CProject file.

Basic features such as browsing do not work, I must be doing something wrong here.

How do I setup the CSolution / clangd / VSCode so that it is choosing the correct compilation options based on the CProject of the file?