Tag Archives: CMake

Adding Qt UI files to your CMake

Qt uses qmake  to generate classes from UI files and compile everything in the project, luckily there are some macros in CMake that allows you to bring everything into your CMake and build everything there, here is what you need to do:

you can find the full project at my Github


Send CMake param to catkin

It quite often happens that you need to send a CMake parameter to your catkin project, for instance, you need to build your code for debugging mode. The correct syntax is:

another example:

read more: http://wiki.ros.org/catkin/Tutorials/using_a_workspace


pkg-config and CMake

The environmental variable:
PKG_CONFIG_PATH is the place that you should place all of your “.pc” files.

Type in the shell:

Then you can type:

Now how to print environmental variable in CMake file:

How to set environmental variable in CMake file:

After setting environmental variable PKG_CONFIG_PATH pointing to your .pc file you can call


How to find CMake from arbitrary installed locations

In my other tutorial, I showed you how to install your code in an arbitrary location in Unix/ Linux systems. In this tutorial, I’m gonna show you how to find them after installation. Here I have two examples: OpenCV, PCL point cloud

I can assume that you have compiled and installed them using the following command:

1)PCL point cloud

put this line in your CMake file:

and check if everything is correct:


put this line in your CMake file:

and check if everything is correct:

if you don’t want to make changes to your CMakeList.txt file you can send <>__DIR as CMake parameter. Example:


Installing programs into arbitrary location in Unix/ Linux systems

After you compiled and built your code, you should install it by calling sudo install to put headers and shared libraries into /usr/include/ and /usr/lib/ and configuration files into /usr/local and /usr/share

usually, I don’t like to touch my system binaries and I prefer to install my compiled code into my home directory so I can safely delete them anytime. If you using CMake use the following parameters to install everything in “/home/<user_name>/usr” instead of “/usr

if you are just using make, use the following: