Archive for the ‘CMake’ tag
The clang_complete plugin for Vim, offers superior code completion. If your project is anything but trivial, it will only do so if you provide
.clang_compelete file with the right compilation argument. The easy way to do so is by using the
cc_args.py script that comes with it to record the options directly into the
.clang_compelete file. Usually one does
make CXX='~/.vim/bin/cc_args.py clang++'
However, the makefile generated by CMake doesn’t support the CXX configuration.
The solution is to call CMake with the CXX environment variable set:
CXX='~/.vim/bin/cc_args.py clang++' cmake .. make
Note that this will create the
clang_complete file in the build directory (I’ve assumed out-of-place build), so just copy over the file to the working dir of your vim so it can find it. You’ll need to re-run cmake again (without the
CXX, to disable re-creating the
.clang_complete file each time.
While looking for this solution, I’ve first tried solving it by setting the CMAKE_CXX_COMPILER variable in CMake, however for some strange reason it didn’t like it, saying that the compiler wasn’t found (it shuns command line arguments given in the compiler command).
The more I use clang_compelete the more awesome I find it. It has it quirks but nonetheless it’s much simpler and better than manually creating tag files for each library.
CMake (via CPack) as a great feature that allows you to automatically generate Debian/Ubuntu (
.deb) packages. One of the annoying things to do when you create a package is listing its dependencies. CMake asks you do it via the
CPACK_DEBIAN_PACKAGE_DEPENDS variable. For example:
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>=2.7-18)")
But what happens when you work on a more complex project? Keeping track of all the dependencies by hand is a tedious task. Debian provides a tool named
dpkg-shlibdeps which makes this task easier by updating the
debian/control file with dependencies extracted from the dynamic libraries needed by a given executable. Luckily since CMake 2.8.3, CMake also supports running this tool automatically to figure out the required dependencies. The documentation is sparse, and I had hard time finding how to do so (I actually found it via a bug report and a commit message, but afterwards I’ve seen it the official documentation too). To enable it, you need to add the following line to your
# autogenerate dependency information set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)