Closed Qix- closed 5 years ago
Yeah I think that assumption is what leads to the bug. I even tried prefixing all of my include directories with ${CMAKE_CURRENT_SOURCE_DIR} and Cmake decided to relativize them anyway.
Could you show me a small cmake based project that ncm2-pyclang fails to do header completion?
CMakeLists.txt
project (foo)
cmake_minimum_required (VERSION 3.8)
include_directories ("includes")
add_executable (foo src/foo.cc)
src/foo.cc
#include <iostream>
#include <bar.hh>
// ^ filename auto-completes fine, but symbols don't show.
using namespace std;
int main() {
cout << get_bar<1337>() << endl;
// ^ try to auto-complete `get_bar`
return 0;
}
includes/bar.hh
#ifndef BAR_HH__
#define BAR_HH__
#pragma once
template <int a>
int get_bar() {
return a;
}
#endif
Worth mentioning:
MacOS 10.14
clang version 7.0.1 (tags/RELEASE_701/final)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
NVIM v0.3.3
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190105-188-1grgj0y/neovim-0.3.3/build/config -I/tmp/neovim-20190105-188-1grgj0y/neovim-0.3.3/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20190105-188-1grgj0y/neovim-0.3.3/build/src/nvim/auto -I/tmp/neovim-20190105-188-1grgj0y/neovim-0.3.3/build/include
Compiled by brew@Mojave.local
Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.3/share/nvim"
Run :checkhealth for more info
It works fine on my local...
compile_commands.json generated by cmake:
[
{
"directory": "/home/roxma/work/ncm2-ws/issues/ncm2-pyclang-22/build",
"command": "/usr/bin/c++ -I/home/roxma/work/ncm2-ws/issues/ncm2-pyclang-22/includes -o CMakeFiles/foo.dir/src/foo.o -c /home/roxma/work/ncm2-ws/issues/ncm2-pyclang-22/src/foo.cc",
"file": "/home/roxma/work/ncm2-ws/issues/ncm2-pyclang-22/src/foo.cc"
}
]
There has to be some difference introduced somewhere by CMake. I can't get CMake to generate absolute paths with includes.
Asciinema: https://asciinema.org/a/UBeEptH16V0pAU6HCKZLyC49B
[
{
"directory": "/tmp/test-cmake-fail/build",
"command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I../includes -g -o CMakeFiles/foo.dir/src/foo.cc.o -c /tmp/test-cmake-fail/src/foo.cc",
"file": "/tmp/test-cmake-fail/src/foo.cc"
}
]
I see you're in /home
- perhaps this is a Linux vs MacOS thing.
At any rate, all this PR does is absolute-ize all of the include paths, which seems to be the only thing that gets Clang to be happy :| seems like bugs from both sides TBH.
Ok. Now I understand.
But ncm2-pyclang should still work for -I../includes
This is probably a bug. I'll confirm this when I have free time.
Fixes #19.
Not entirely sure what happened to #21. 8 years of Github and I've never seen that happen.
Sorry for the noise.
I fixed this: https://github.com/ncm2/ncm2-pyclang/pull/21#discussion_r252094114
WRT https://github.com/ncm2/ncm2-pyclang/pull/21#discussion_r252097918:
Yeah I think that assumption is what leads to the bug. I even tried prefixing all of my include directories with
${CMAKE_CURRENT_SOURCE_DIR}
and Cmake decided to relativize them anyway.