Build: Simplify CMAKE_PREFIX_PATH

Fangrui Song 2021-01-16 11:14:19 -08:00
parent 83a32f3163
commit d3c20f45f3

@ -93,7 +93,9 @@ for your system, as well as methods of obtaining and locating Clang+LLVM.
* `-DCMAKE_PREFIX_PATH=<path>` * `-DCMAKE_PREFIX_PATH=<path>`
Specify paths where CMake can locate Clang/LLVM headers and libraries. 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)` * `-DUSE_SYSTEM_RAPIDJSON=(ON|OFF)`
@ -288,7 +290,7 @@ ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# Download ccls # Download ccls
cd 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 ninja -C Release
``` ```
@ -324,30 +326,23 @@ Then build ccls with `-DCMAKE_PREFIX_PATH`:
```sh ```sh
cd ~/ccls cd ~/ccls
LLVM=$HOME/llvm-project 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 ninja -C Release
``` ```
`-DCMAKE_PREFIX_PATH=` is a `;`-separated list where you can find: `-DCMAKE_PREFIX_PATH=` is a `;`-separated list. The cmake build system is expected to find these files:
* `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:
``` ```
# generated clang+llvm header files # generated clang+llvm header files
~/llvm/Release/include/llvm/Config/config.h include/llvm/Config/config.h
~/llvm/Release/tools/clang/include/clang/Config/config.h tools/clang/include/clang/Config/config.h
# libclangIndex.so # libclangIndex.so
~/llvm/Release/lib/libclangIndex.so or libclangIndex.a lib/libclangIndex.so or libclangIndex.a
# -resource-dir # -resource-dir
~/llvm/Release/lib/clang/7.0.0 lib/clang/7.0.0
# clang+llvm libraries # clang+llvm libraries
~/llvm/Release/lib/libclangDriver.so lib/libclangDriver.so
~/llvm/Release/lib/libLLVMSupport.so or libLLVMSupport.a lib/libLLVMSupport.so or libLLVMSupport.a
... ...
``` ```