Question

I'm using CMake to genenerate my Makefile's however I cannot generate the .clang_complete using the standard

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

nothing gets generated...

the tree structure looks like so

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

CMakeLists.txt (1) file:

 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)

CMakeLists.txt (2) file:

subdirs(src)

CMakeLists.txt (3) file:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(Dunkel)
SUBDIRS(core)

set(CMAKE_CXX_FLAGS "-g")

What am I doing wrong here?

Was it helpful?

Solution

Looks like contrary to make cmake doesn't expand tilde, hence it treats is as part of the path. To make it work as expected either use absolute path to the cc_args.py script or do two simple changes in the command:

  1. Replace the tilde with $HOME.
  2. 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.

OTHER TIPS

You should 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 build the project with make, if you want to disable this, re-run cmake again.

The file .clang_complete will be created in the build directory, move it if needed.

See also Vim: Creating .clang_complete using CMake

It is important to use $HOME/.vim/bin/cc_args.py and not ~/.vim/bin/cc_args.py, because ~ might not get expanded when quoted.

Also, verify the presence of the 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 necessary.

Run make clean in the build dir.

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

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

followed by:

make

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

However this part for me is failing to work, and no .clang_complete file is created in the build directory or anywhere else.

In fact, there is no occurrence of "cc_args" in the generated CMakeCache.txt / Makefile, so I suspect CXX is not the correct variable name to pass to cmake.

When finished, copy .clang_complete to the parent dir.

Here is 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top