My problem consists in the fact that “CMAKE_EXPORT_COMPILE_COMMANDS” has no effect on MSVC generator. CMake simply ignores it. In order to get compile_commands.json one has to either generate project with Ninja, MingW or Make generator.
I’ve succeded in generating it witn MingW on Windows. Once I did it, I wanted to feed MingW’s clangd with it. However, the clangd was constantly crashing (I did it by means of Emacs). Now, however, I’ve tried this in Powershell
$env:URHO3D_HOME='C:\Users\darko\.urho3d\msvc\'
cmake -G"Ninja" .. -DURHO3D_ANGELSCRIPT=0 -DURHO3D_LUA=0 -DURHO3D_URHO2D=0 -DURHO3D_IK=0 -DURHO3D_NETWORK=0 -DURHO3D_PHYSICS2D=0 -DURHO3D_WEBP=0 -DCMAKE_MAKE_PROGRAM:STRING="c:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe" ..
and for some reason, it worked, i.e. i’ve succeded in configuring the build. However, the build itself does not work and fails with
PS C:\Users\darko\Development\persistence\ninja> & "c:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe"
[2/2] Linking CXX executable bin\Persistence_d.exe
FAILED: bin/Persistence_d.exe
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -mtune=generic -Wno-invalid-offsetof -march=native -msse3 -pthread -Qunused-arguments -fcolor-diagnostics -Wno-argument-outside-range -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -DDEBUG -D_DEBUG -Xlinker /subsystem:windows CMakeFiles/Persistence.dir/Source/Application.cpp.obj -o bin\Persistence_d.exe -Xlinker /implib:Persistence_d.lib -Xlinker /pdb:bin\Persistence_d.pdb -Xlinker /version:0.0 C:/Users/darko/.urho3d/msvc/lib/Urho3D.lib -luser32.lib -lgdi32.lib -lwinmm.lib -limm32.lib -lole32.lib -loleaut32.lib -lsetupapi.lib -lversion.lib -luuid.lib -lws2_32.lib -liphlpapi.lib -lwinmm.lib -lopengl32.lib -limm32.lib -lole32.lib -loleaut32.lib -lsetupapi.lib -lversion.lib -luuid.lib -lws2_32.lib -liphlpapi.lib -lopengl32.lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: /failifmismatch: mismatch detected for '_ITERATOR_DEBUG_LEVEL':
>>> CMakeFiles/Persistence.dir/Source/Application.cpp.obj has value 2
>>> Urho3D.lib(Application.obj) has value 0
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
However, I got mine compile_commands.json that works well with windows native clangd.
So, to wrap it up, Ninja generator actually works on Windows, for projects and for Urho3D itself. However, the build files cannot be used to build Urho3D or project. Nevertheless, compile_commands.json is generated in the generate step.