MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.78k stars 260 forks source link

Building on windows does not work as described in wiki #964

Open Frederico-Esch opened 6 months ago

Frederico-Esch commented 6 months ago

The build steps described here: wiki/Project-Setup do not work anymore.

Somethings I did to actually build it.

  1. Make sure you do not have any clang in your path, be it from Visual Studio or llvm-binaries (I don't know if this step is necessary, but for me it was causing some conflict)
  2. Build llvm with:
git clone https://github.com/llvm/llvm-project.git --depth=1
cd llvm-project
cmake -Sllvm -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang
ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang

Somethings to take note, the -H flag does not exist anymore, it is now -S, building llvm was pretty straight-forward if you knew about the flag deprecation.

  1. Build ccls with:
git clone https://github.com/MaskRay/ccls.git
cd ccls

git submodule init
git submodule update

cmake -S. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_PREFIX_PATH="E:/Aplicativos/llvm-project/Release"
ninja -C Release

I had to initialize and update the submodule to actually make it work. About the cmake call, I had to change the -H to -S as stated before, and another relevant thing was setting both the CXX and C compiler to clang, since if you don't define CMAKE_C_COMPILER it will automatically use MSVC and it will conflict and abort the build.

I don't know how to push a fix to wiki so I'm just submitting a issue with the fix that worked for me, if anyone wants to validate by trying to replicate it and update the wiki I'd be thankful.

LdBeth commented 3 months ago

The Wiki is open for editing, so I have fixed that for you.