Configure a CLion project

Use the CLion IDE with YugabyteDB

Configure a project in the CLion C/C++ IDE.

Configure a CLion compilation database project

For best performance, configure the project as a compilation database project:

  1. Run ./yb_build.sh compilecmds to generate the compile_commands.json file in the yugabyte-db directory.

  2. Verify that compile_commands.json is present in the yugabyte-db folder. From the yugabyte-db folder, run the following command:

    $ find . -name "compile_commands.json"
    

    You should see output similar to the following:

    ./compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/combined_raw/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/yb_postprocessed/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/yb_raw/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/combined_postprocessed/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/pg_raw/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/pg_postprocessed/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/postgres_build/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/postgres_build/contrib/compile_commands.json
    ./build/compilecmds-clang-dynamic-arm64-ninja/postgres_build/third-party-extensions/compile_commands.json
    
  3. If ./compile_commands.json is not there, then make a symlink to the one in the build folder as follows:

    ln -s build/compilecmds-clang-dynamic-arm64-ninja/compile_commands/combined_postprocessed/compile_commands.json compile_commands.json
    

    Replace compilecmds-clang-dynamic-arm64-ninja as appropriate.

  4. Close the CLion project.

  5. If you previously opened the folder in CLion, delete the .idea folder in the yugabyte-db folder:

    rm -r .idea
    
  6. Re-open the yugabyte-db folder in CLion.

  7. When prompted to open the folder as a CMake project or as a Compilation Database project, choose Compilation Database project.