I am still learning Nim, so may have missed something obvious. I have a project whose root is laid out as follows:
├── config.nims
├── funim_glfw.nimble
├── nimble.paths
├── src
│ ├── build.md
│ ├── examples
│ │ └── glfw
│ │ └── minimal.nim
│ ├── funim_glfw.nim
│ ├── glad
│ │ ├── include
│ │ └── src
│ ├── glfw
│ │ ├── ...
│ │ ├...
│ │ ├── src
│ │ └── tests
│ ├── glfw3_api.nim
│ └── settings.nims
In the src/examples/glfw folder I have a minimal.nim file that has the following pragmas:
{.passC: "-Isrc/glad/include".}
{.compile: "src/glad/src/gl.c".} In this case nimsuggest reports:
cannot find: src/glad/src/gl.c
In the path src path I have the file funim_glfw.nim with the exact same set of pragmas. In this case no nimsuggest message is generated.
Compilation and execution works in both cases. I am assuming the path is relative to the project root (relative to the Nimble script), so the pragma path seems to be correct. I also tried setting the minimal.nim pragma path relative to this file itself, but this also failed. So my question is, how do I correct or get rid of the nimsuggest error?
TIA
I am assuming the path is relative to the project root (relative to the Nimble script)
Nim uses paths relative to current file by default. But you can add project root to paths, by adding this line in your config.nims:
--path:"." @janAkali thanks for the information. So I went back to the code and corrected the path to:
{.passC: "-Isrc/glad/include".}
{.compile: "../../glad/src/gl.c".}
And indeed this works as explained. However, I only have the following in my config.nims:
--threads:on
--out:"./bin/"
And if I use the path starting from the project root, as indicated in the initial post, it still compiles correctly. My nimble build script outputs, among other things, these 2 lines:
Executing task runthis in /home/hmf_x/VSCodeProjects/nim_learn/funim_glfw/funim_glfw.nimble
....
/home/hmf/.nimble/bin/nim c --colors:on --noNimblePath -d:NimblePkgVersion=0.1.0 --path:/home/hmf/.nimble/pkgs2/macroutils-1.2.0-1759c705ba1fe48426ee7ca2d0c7fa265e91806b --path:/home/hmf/.nimble/pkgs2/futhark-0.15.0-50ab2e44c9d5cc99ba1c85032b63c1086c71371c --path:/home/hmf/.nimble/pkgs2/nimbleutils-0.3.3-9cce152f371ed2277db0bb5853dfe7543c38ac66 --path:/home/hmf/.nimble/pkgs2/termstyle-0.1.0-4641c9f9e587d5cf04ccd3ce0bf1ef0263a16299 -o:/home/hmf_x/VSCodeProjects/nim_learn/funim_glfw/bin/examples/glfw/minimal /home/hmf_x/VSCodeProjects/nim_learn/funim_glfw/src/examples/glfw/minimal.nim
So something must be allowing the nim compiler to pick the correct path.
Anyway, I will stick to the relative path as it removes that pesky red from my IDE.
Thanks again.