ycm-core/YouCompleteMe

CMake fails on second run if directory is not emptied

nagisa opened this issue · 11 comments

Lets say I run cmake for a first time with cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/usr/lib/llvm . ~/local/share/vim/bundle/YouCompleteMe/cpp/ and it generates everything fine. Then I realize there's another flag for that and I run cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/lib/llvm/libclang.so . ~/local/share/vim/bundle/YouCompleteMe/cpp/. It fails with following message

Your C++ compiler supports C++11, compiling in that mode.
Using libclang to provide semantic completion for C/C++/ObjC
Using external libclang: TEMP-NOTFOUND
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TEMP
    linked by target "ycm_core" in directory /home/nagisa/local/share/vim/bundle/YouCompleteMe/cpp/ycm

-- Configuring incomplete, errors occurred!

After a rm -rf ./* ($PWD is build directory) and cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/lib/llvm/libclang.so . ~/local/share/vim/bundle/YouCompleteMe/cpp/ works fine.

I'll take a look, thanks.

a) This is specific to the flag changes you made.
b) One should always clean the build directory first before calling cmake again, if one wants to change any cmake vars.

Still, thanks for the report!

Ivoz commented

Hi there. I got this in an empty folder, first time trying to build YCM. Using Arch. Here is a second build that failed exactly the same:

[ivo@ivosung ycm]$ ls
BoostParts  CMakeCache.txt  CMakeFiles  ycm
[ivo@ivosung ycm]$ rm -rf ./*
[ivo@ivosung ycm]$ ls
[ivo@ivosung ycm]$ cmake -G "Unix Makefiles" -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/cpp
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Your C++ compiler supports C++11, compiling in that mode.
-- Found PythonLibs: /usr/lib64/libpython2.7.so (found suitable version "2.7.3", minimum required is "2.5") 
Using libclang to provide semantic completion for C/C++/ObjC
Using external libclang: TEMP-NOTFOUND
-- Found PythonInterp: /usr/bin/python (found version "3.3") 
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TEMP
    linked by target "ycm_core" in directory /home/ivo/.vim/bundle/YouCompleteMe/cpp/ycm

-- Configuring incomplete, errors occurred!

Arch provides clang 3.2:

[ivo@ivosung ycm]$ pkgfile -v libclang.so
extra/clang 3.2-4   /usr/lib/llvm/libclang.so

I don't know what to tell you; if TEMP is set to TEMP-NOTFOUND that means that cmake's find_library call couldn't find your libclang. The call looks like this: find_library( TEMP clang ). Very vanilla. See here for docs on the call.

@Ivoz, you want to sudo ln -s /usr/lib/llvm/libclang.so /usr/lib/. Like somebody already mentioned in some ticket it would be cool if we could search /usr/lib/llvm/ along with /usr/lib/. It seems that Arch puts it into /usr/lib/llvm/ intentionally, so this fix may be specific to Arch family of distributions.

@simukis Now that is doable. Are you sure adding /usr/lib/llvm/ to the search path would find it? I don't have an Arch linux machine available to test it out.

I just pushed a commit for the can't-find-system-libclang-on-Arch issue; if someone with an Arch system could test this out, that would be great.

@Valloric, Yes, it works:

System libclang seems good enough, using it.
Using libclang to provide semantic completion for C/C++/ObjC
Using external libclang: /usr/lib64/llvm/libclang.so
Ivoz commented

Just a note, it seems that libclang.so on ArchLinux is back in /usr/lib, not sure why or when... I do know the arch way is to usually try to install packages with as little changes (as vanilla) as possible, maybe that was improved here.

on Ubuntu 14.04.1 LTS after sudo apt-get install clang, there is no libclang.so but only libclang.so.1 point to libclang-3.4.so.1 in /usr/lib/llvm-3.4/lib/ directory. i exec the command below solve this problem
cd /usr/lib/llvm-3.4/lib/ && sudo ln -s libclang.so.1 libclang.so

I can confirm a similar problem on OpenSUSE (13.2) - the system wide clang provides /usr/lib64/libclang.so.3.5, so the following fixed the problem:

sudo ln -s /usr/lib64/libclang.so.3.5 /usr/lib64/libclang.so
./install.sh --clang-completer --system-libclang