Open rob2244 opened 4 days ago
So I think I misunderstood how the build was working. Based on the duckdb docs it seems like the makefile is calling into the CMakeFile and adding the duckdb cmake functions. Is that correct? So how would I generate a compile_commands.json that includes my extra deps?
yea that is correct, so if you run make debug
for example, you will see how CMake is invoked:
mkdir -p build/debug
cmake -G "Ninja" -DFORCE_COLORED_OUTPUT=1 -DEXTENSION_STATIC_BUILD=1 -DDUCKDB_EXTENSION_CONFIGS='/Users/sam/Development/extension-template/extension_config.cmake' -DOSX_BUILD_ARCH= -DDUCKDB_EXPLICIT_PLATFORM='' -DCUSTOM_LINKER= -DCMAKE_BUILD_TYPE=Debug -S "./duckdb/" -B build/debug
So note that the duckdb submodule is the root of the CMake build, with the directory to the extension being passed through the DUCKDB_EXTENSION_CONFIGS
path
How to configure this in your IDE will vary, the instructions for CLion are in the readme of the template: https://github.com/duckdb/extension-template?tab=readme-ov-file#setting-up-clion
Thank you @samansmink for your insight.
Personally, the CLion instructions never worked for me. I don't see what else I should do beside starting CLion in the duckdb
directory directly as a CMake project, then change the root project to the actual extension root directory and reload the project. It doesn't change anything and CLion still complains about missing headers even if I can build my extension successfully.
It's more an annoyance than anything as the extension-template is a real timesaver otherwise. Having say that I'm curious to know if anyone actually managed to setup CLion successfully.
@YoEight not sure if this helps but it looks like CLion primarily uses clangd as it's language server which is what I'm using with neovim as well. You might try generating a compile_commands.json [(clion instructions)] (https://www.jetbrains.com/help/clion/compilation-database.html) (although I used bear) and seeing if that fixes the missing header issues. @samansmink btw I just added the paths to the snowflake header file locations manually to the compile_commands.json and that seemed to fix the issues. At some point in the future I might try to figure out how to auto generate with the external deps included.
This is my config for my local clone of the template. The root of the repository is at /Users/sam/Development/extension-template
with my Clion being opened as a CMake project by opening the CMakeLists.txt
file of the submodule (so /Users/sam/Development/extension-template/duckdb/CMakelists.txt
), then changing the project root to 1 directory up.
Does your Clion seem to recognize the files as part of the project? Generally when a file is not included in the CMake build of CLion it will complain that a file is not part of the project when you view the contents
I'm new to the C/C++ ecosystem so I apologize if I'm doing something wrong, but it seems like when I try to run CMake I get an error that the build_static_extension command is missing.
I see that the function exists in the duckdb CMake files, do I have to copy it over or somehow include that file?
The reason that I'm trying to run cmake is that I'm trying to write a snowflake extension and I statically linked in the snowflake c library in CMakeLists.txt. When I run make it seems to be picking up the library, but when I run bear to generate the compile_commands.json file it doesn't seem to be picking up the snowflake lib paths and my editor doesn't pick up the header files.