.clang_complete and CMake?

I use CMake to generate my Makefile, but I cannot create .clang_complete using standard

make CC='~/.vim/bin/cc_args.py gcc' CXX='~/.vim/bin/cc_args.py g++' -B 

nothing is generated ...

tree structure looks like this

 Root | |_core | |_src | | |_main.cpp | | |_CMakeLists.txt (1) | |_inc | |_CMakeLists.txt (2) | |_lib | |_rtaudio | |_CMakeLists.txt (3) 

File CMakeLists.txt (1):

  include_directories("${Dunkel_SOURCE_DIR}/core/inc") include_directories("${Dunkel_SOURCE_DIR}/lib/") link_directories("${Dunkel_SOURCE_DIR}/lib/rtaudio") add_executable(Dunkel main.cpp) target_link_libraries(Dunkel rtaudio) 

File CMakeLists.txt (2):

 subdirs(src) 

File CMakeLists.txt (3):

 CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(Dunkel) SUBDIRS(core) set(CMAKE_CXX_FLAGS "-g") 

What am I doing wrong here?

+4
source share
4 answers

It seems that contrary to make cmake , the tilde does not expand, so it is considered as part of the path. To make it work as expected, either use the absolute path to the cc_args.py script, or make two simple changes to the command:

  • Replace the tilde with $HOME .
  • Replace single quotes with double quotes.

After the changes, your command should look like this:

 CXX="$HOME/.vim/bin/cc_args.py g++" cmake .. 

And it should work.

+3
source

You must run (in your build directory)

 CXX='~/.vim/bin/cc_args.py g++' cmake .. 

and then run make , as usual. Note that this will run the cc_args.py script every time you create a project using make , if you want to disable it, run cmake again.

The .clang_complete file will be created in the assembly directory, move it if necessary.

See also Vim: Creating .clang_complete Using CMake

+2
source

It is important to use $HOME/.vim/bin/cc_args.py , rather than ~/.vim/bin/cc_args.py , because ~ may not expand when quoting.

Also check for python script with

 $ ls -l $HOME/.vim/bin/cc_args.py -rwxr-xr-x 1 myself staff 2270 Sep 19 16:11 /home/myself/.vim/bin/cc_args.py 

if not found, adjust the python script path as needed.

Run make clean in the build directory.

As @xaizek suggested, start with an empty build directory (assuming the build directory is a subdirectory of the source directory):

 CXX="$HOME/.vim/bin/cc_args.py g++" cmake .. 

and then:

 make 

at this point, make will build the project, but calls cc_args.py (which will call g++ ) instead of directly calling g++ .

However, this part does not work for me, and the .clang_complete file is created in the assembly directory or elsewhere.

In fact, β€œcc_args” does not appear in the generated CMakeCache.txt / Makefile, so I suspect that CXX not a valid variable name for going to cmake.

When finished, copy .clang_complete to the parent directory.

+1
source

Here's what worked for me

 sudo chmod a+x $HOME/.vim/bin/cc_args.py CXX="$HOME/.vim/bin/cc_args.py g++" sudo cmake .. sudo make 

and then ls -a shows my .clang_complete file, but still emtyp, though.

0
source

All Articles