Select which compiler clangd uses for lsp

I am trying to get the c++ language server working with emacs. I work in high performance computing, so my toolchains are vastly different from project to project. When using the lsp mode in emacs (cc +lsp), it selects gcc-12 on my system as the compiler to use with clangd.

What happened?

{{{Clangd auto selects gcc_12 as the default compiler on my system.}}}

What did you expect to happen?

{{{Since compile_commands.json has icpx (Intel Compiler) selected, I expect clangd to get libraries from Intel compilers instead of gcc.}}}

Steps to reproduce

  1. Generate a compile_commands.json with a different compiler or libraries selected (I used bear on my Makefile)
  2. use doom emacs to start lsp server. init.el should have (cc +lsp)
  3. If libstdc++ is not installed for gcc (in my case gcc_12) the include will show file not found. But the compiler used in my case icpx, is able to compile and run the code successfully.

System information

Loading data dump...