CMake internal flag -H is replaced by -S officially since 3.13

LdBeth 2024-08-17 18:10:22 -05:00
parent d6aea8f6d1
commit 761a47702a

@ -20,13 +20,13 @@ cd ccls
# Do not unpack to a temporary directory, as the clang resource directory is hard-coded # Do not unpack to a temporary directory, as the clang resource directory is hard-coded
# into ccls at compile time! # into ccls at compile time!
# See https://github.com/MaskRay/ccls/wiki/FAQ#verify-the-clang-resource-directory-is-correct # See https://github.com/MaskRay/ccls/wiki/FAQ#verify-the-clang-resource-directory-is-correct
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/path/to/clang+llvm-xxx cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/path/to/clang+llvm-xxx
cmake --build Release cmake --build Release
``` ```
As of 2020-06-23 no pre-built binaries exist for Ubuntu 20.04. `sudo apt-get install clang libclang-10-dev` and all the other dependencies listed here **excluding** rapidjson-dev (it is vendored in this repo), then run As of 2020-06-23 no pre-built binaries exist for Ubuntu 20.04. `sudo apt-get install clang libclang-10-dev` and all the other dependencies listed here **excluding** rapidjson-dev (it is vendored in this repo), then run
```sh ```sh
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \ cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr/lib/llvm-10 \ -DCMAKE_PREFIX_PATH=/usr/lib/llvm-10 \
-DLLVM_INCLUDE_DIR=/usr/lib/llvm-10/include \ -DLLVM_INCLUDE_DIR=/usr/lib/llvm-10/include \
-DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-10/ -DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-10/
@ -42,7 +42,7 @@ You may replace the last two **cmake** commands with:
```sh ```sh
wget -c http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz wget -c http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar xf clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz tar xf clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04
cmake --build Release cmake --build Release
``` ```
@ -106,7 +106,7 @@ If your system Clang+LLVM is sufficiently new, consider using them. If they
are installed into the standard locations for our system, `CMAKE_PREFIX_PATH` are installed into the standard locations for our system, `CMAKE_PREFIX_PATH`
is not required. is not required.
A simple `cmake -GNinja -H. -BRelease` (remove `-GNinja` if you don't use A simple `cmake -GNinja -S. -BRelease` (remove `-GNinja` if you don't use
Ninja) works for many distributions. The required system packages are: Ninja) works for many distributions. The required system packages are:
* Arch Linux: `clang` `llvm` * Arch Linux: `clang` `llvm`
@ -119,7 +119,7 @@ Ninja) works for many distributions. The required system packages are:
Pick the one on https://releases.llvm.org/download.html that suits your system. Pick the one on https://releases.llvm.org/download.html that suits your system.
Note, the Ubuntu 16.04 prebuit binaries are actually suitable for many non-Ubuntu distributions. Note, the Ubuntu 16.04 prebuit binaries are actually suitable for many non-Ubuntu distributions.
After unpacking, `cmake -GNinja -H. -BRelease -DCMAKE_PREFIX_PATH=/path/to/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04` After unpacking, `cmake -GNinja -S. -BRelease -DCMAKE_PREFIX_PATH=/path/to/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04`
The Windows prebuilt binaries lack C++ header files, thus they cannot be used. The Windows prebuilt binaries lack C++ header files, thus they cannot be used.
@ -133,7 +133,7 @@ On GNU/Linux distributions with older versions of glibc (older than
apk add alpine-sdk cmake make clang clang-static clang-dev llvm-dev llvm-static \ apk add alpine-sdk cmake make clang clang-static clang-dev llvm-dev llvm-static \
&& git clone --depth=1 --recursive https://github.com/MaskRay/ccls \ && git clone --depth=1 --recursive https://github.com/MaskRay/ccls \
&& cd ccls \ && cd ccls \
&& cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \ && cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release \
&& cmake --build Release --target install && cmake --build Release --target install
``` ```
@ -160,7 +160,7 @@ sudo apt install ccls
```sh ```sh
# build from source # build from source
sudo apt install clang cmake libclang-dev llvm-dev rapidjson-dev sudo apt install clang cmake libclang-dev llvm-dev rapidjson-dev
cmake -H. -BRelease cmake -S. -BRelease
cmake --build Release cmake --build Release
``` ```
@ -192,7 +192,7 @@ On Ubuntu 16.04 install g++-7 via [these directions](https://gist.github.com/jlb
To build with system Clang+LLVM: `sudo apt install clang libclang-dev` To build with system Clang+LLVM: `sudo apt install clang libclang-dev`
```sh ```sh
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \ cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr/lib/llvm-7 \ -DCMAKE_PREFIX_PATH=/usr/lib/llvm-7 \
-DLLVM_INCLUDE_DIR=/usr/lib/llvm-7/include \ -DLLVM_INCLUDE_DIR=/usr/lib/llvm-7/include \
-DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-7/ -DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-7/
@ -238,7 +238,7 @@ exec /opt/homebrew/bin/ccls --init='{"clang":{"extraArgs":[
To build from source: To build from source:
```sh ```sh
brew info llvm brew info llvm
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(brew --prefix llvm)/lib/cmake" cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(brew --prefix llvm)/lib/cmake"
cmake --build Release cmake --build Release
``` ```
@ -252,7 +252,7 @@ cmake --build Release
```sh ```sh
guix package -i cmake clang gcc-toolchain guix package -i cmake clang gcc-toolchain
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/home/$USER/.guix-profile/bin/clang cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/home/$USER/.guix-profile/bin/clang
cmake --build Release cmake --build Release
``` ```
@ -272,12 +272,12 @@ these releases. You must either:
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
cd llvm-project cd llvm-project
cmake -Hllvm -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang 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 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_C_COMPILER=clang-c -DCMAKE_PREFIX_PATH="D:/llvm-project/Release" cmake -S. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-c -DCMAKE_PREFIX_PATH="D:/llvm-project/Release"
ninja -C Release ninja -C Release
``` ```
@ -291,7 +291,7 @@ pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-clang-tools-extra mingw64/ming
pacman -S cmake ninja clang pacman -S cmake ninja clang
# Download ccls # Download ccls
cd ccls cd ccls
cmake -H. -BRelease -G Ninja -DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS cmake -S. -BRelease -G Ninja -DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS
ninja -C Release ninja -C Release
``` ```
@ -313,7 +313,7 @@ cp /mingw64/bin/libclang.dll /mingw64/bin/libstdc++-6.dll ~/ccls/Release/
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
cd llvm-project cd llvm-project
cmake -Hllvm -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang cmake -Sllvm -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang
ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# built Release/bin/clang # built Release/bin/clang
``` ```
@ -327,7 +327,7 @@ 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" cmake -S. -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
``` ```
@ -355,7 +355,7 @@ Similar to the instructions to build Clang+LLVM from the git monorepo:
# Download "LLVM source code" and rename the extracted directory to llvm # Download "LLVM source code" and rename the extracted directory to llvm
# Download "Clang source code" and rename the extracted directory to llvm/tools/clang # Download "Clang source code" and rename the extracted directory to llvm/tools/clang
cd llvm cd llvm
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang cmake -S. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang
ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# built Release/bin/clang # built Release/bin/clang
``` ```