From d3c20f45f3cc2396db277dad58611d8d450fc5d5 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 16 Jan 2021 11:14:19 -0800 Subject: [PATCH] Build: Simplify CMAKE_PREFIX_PATH --- Build.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Build.md b/Build.md index 75cb4fe..2c116b9 100644 --- a/Build.md +++ b/Build.md @@ -93,7 +93,9 @@ for your system, as well as methods of obtaining and locating Clang+LLVM. * `-DCMAKE_PREFIX_PATH=` Specify paths where CMake can locate Clang/LLVM headers and libraries. - CMake searches the paths in `CMAKE_PREFIX_PATH` for `include` and `lib`. + CMake searches the paths in `CMAKE_PREFIX_PATH` for + `lib/cmake/clang/ClangConfig.cmake`, `lib/cmake/llvm/LLVMConfig.cmake`, + `include` and `lib`. * `-DUSE_SYSTEM_RAPIDJSON=(ON|OFF)` @@ -288,7 +290,7 @@ ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang # Download ccls cd ccls -cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_PREFIX_PATH="D:/llvm/Release;D:/llvm/Release/tools/clang;D:/llvm;D:/llvm/tools/clang" +cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_PREFIX_PATH="D:/llvm/Release" ninja -C Release ``` @@ -324,30 +326,23 @@ Then build ccls with `-DCMAKE_PREFIX_PATH`: ```sh cd ~/ccls LLVM=$HOME/llvm-project -cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_PREFIX_PATH="$LLVM/Release;$LLVM/llvm;$LLVM/clang" +cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_PREFIX_PATH="$LLVM/Release" ninja -C Release ``` -`-DCMAKE_PREFIX_PATH=` is a `;`-separated list where you can find: - -* `llvm`: llvm source -* `llvm/tools/clang`: clang source -* `llvm/Release`: build directory. `include/` contains generated llvm header files, e.g. `include/llvm/Config/config.h` -* `llvm/Release/tools/clang`: build directory. `include/` contains generated clang header files, e.g. `include/clang/Config/config.h` - -The cmake build system is expected to find these files: +`-DCMAKE_PREFIX_PATH=` is a `;`-separated list. The cmake build system is expected to find these files: ``` # generated clang+llvm header files -~/llvm/Release/include/llvm/Config/config.h -~/llvm/Release/tools/clang/include/clang/Config/config.h +include/llvm/Config/config.h +tools/clang/include/clang/Config/config.h # libclangIndex.so -~/llvm/Release/lib/libclangIndex.so or libclangIndex.a +lib/libclangIndex.so or libclangIndex.a # -resource-dir -~/llvm/Release/lib/clang/7.0.0 +lib/clang/7.0.0 # clang+llvm libraries -~/llvm/Release/lib/libclangDriver.so -~/llvm/Release/lib/libLLVMSupport.so or libLLVMSupport.a +lib/libclangDriver.so +lib/libLLVMSupport.so or libLLVMSupport.a ... ```