Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
To get started building cquery, first install the required dependencies:
- CMake 3.1 or higher
- C++ Compiler with C++14 support:
- Clang 3.6 or higher
- GCC 5 or higher
- MSVC 2017 or higher (included with VS2017 Build Tools)
After installing the required dependencies, open your terminal and run the following commands:
git clone --recursive https://github.com/cquery-project/cquery.git cd cquery git submodule update --init mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release -DCMAKE_EXPORT_COMPILE_COMMANDS=YES cmake --build . cmake --build . --target install
-DCMAKE_INSTALL_PREFIX=<dir to your choice> to install the binary to a place you want.
This command generates project files for your system's default generator (Linux: make, Windows: MSBuild). CMake defaults to a Release build and links cquery against the libclang library which it downloads from https://releases.llvm.org.
On Windows you have to explicitly tell CMake to target 64-bit
architecture by adding the
-DCMAKE_GENERATOR_PLATFORM=x64 option to the cmake
cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..). 32-bit builds are not
After CMake configuration cquery can be built from the root of the source tree
by executing the corresponding generator command (Linux:
MSBuild.exe) or the generic CMake build command (
cmake --build .).
Due to how MSBuild works you it is impossible to default to a
release build when MSBuild is used as the CMake generator. Instead the config
has to be specified to MSBuild when building the project (after the configure
step). The command to build then becomes:
cmake --build . --config release
Finally, install cquery by executing the install target
cmake --build . --target install). This step is not optional and cquery might
not work completely or at all if it is executed from the build directory. By
default CMake installs to a directory that requires admin privileges to install
to but this can be avoided by explicitly specifying the install directory with
When using MSBuild we have to add the release config when
installing as well:
cmake --build . --target install --config release
Cquery CMake Options
CMake options can be specified when running CMake to change its behaviour.
Options are passed to CMake via the command line by prepending them with -D. For
cmake -DCMAKE_BUILD_TYPE=Debug .. configures cquery to be built in
CMAKE_BUILD_TYPE can be used to set the build type. There are a few possible
options, but the most important ones are Debug and Release. Generally you want
-DCMAKE_BUILD_TYPE=Release to CMake to get the best performance out of
cquery. Debug is recommended when debugging cquery with a debugger. Since cquery
defaults to a Release build it usually isn't necessary to define this option
unless you're debugging an issue in cquery with a debugger.
SYSTEM_CLANG if you want to link cquery against a system installation
of Clang instead of downloading Clang during the configure process.
Using a system-installed Clang is NOT recommended. Using cquery with a modified or earlier release of Clang will lead to bugs and errors when using cquery.
When you want to use a system installed Clang but it is not installed into any
default CMake search location (for example if you built LLVM from source) you
can tell CMake where to search by adding search paths to
CMake searches the paths in
CMAKE_PREFIX_PATH for 'include' and 'lib'
subdirectories containing the required Clang headers and libraries. For example,
to use a system installation of Clang on Windows you can add the following
If the 'include' and 'lib' directories reside in two different parent
directories (possible when building LLVM from source) you will have to add both
these directories to CMAKE_PREFIX_PATH separated by a ';'