Listado de la etiqueta: Started

“CMake is a popular and helpful cross-platform, open-source set of tools that utilize compiler and platform-independent configuration files to build, test, and package projects. CMake was developed as the solution for a cross-platform build space for open-source projects.

CPack is a packaging tool that is cross-platform and distributed by CMake. However, it can be used independently of CMake, but it uses generator concepts from the CMake suite tool.

This guide covers the installation and usage of CMake and CPack.”

How to Install CMake

You can install CMake via the command line or the Ubuntu Software Centre. In this case, we will install it via the command line, but you can check the complete CMake installation methods for more details.

First, update your repository.

Next, enter the command below to install CMake.

$ sudo snap install cmake –classic

You can confirm the installation by checking its version.

Using CMake to Configure, Build, and Debug a C++ Project on Linux

CMake is popular for managing code builds for C++ projects, and it does so with the help of the CMakeLists.txt files for each directory. They define the tasks the build system should undertake.

In our case, we will write a simple C++ program using Visual Studio Code and build it using CMake.

Ensure you have the C++ Visual Studio extension installed, a debugger, preferably gcc, and CMake.

You can install gcc using the command:

$ sudo apt-get install build-essential gdb

To start, create a working folder and open it in Visual Studio Code.

$ mkdir cmakedemo
$ cd cmakedemo

Open Visual Studio Code

Merienda Visual Studio Code opens, open the Palette by typing ctrl + shift + p

To quickly create the needed CMake files, type CMake: Quick Start and choose the option like in the image below.

If prompted to choose between Library and Executable, choose Executable. You will notice two files, the main function and the CMakeLists.txt will be created.

You also need to select a Kit to inform CMake which compiler to use.

First, check your gcc version on the terminal. On the Palette, search for Kit and choose the one that matches your version.

At the bottom of the window, you will see the selected kit. In our case, it’s GCC 9.4.0 x86_64-linux-gnu.

CMake also uses a variant that contains instructions on building the project. Still on the Palette, type CMake: Select Variant. There are four variants to choose from.

  • Debug: it includes the debug details, but it disables optimizations.
  • Release: no debug details, but optimization gets included.
  • RelWithDebInfo: it includes debug info and optimizes for size.
  • MinSizeRel: it doesn’t include the debug details, but it optimizes for size.

In our case, we need optimization and debugging information. So, we will choose Debug.


Everything is set. Open the Palette and type CMake: Configure, click the enter button, and CMake will generate the build files and configure the project.

The final step is to build the project. You can do so by clicking the Build at the bottom of the screen or running CMake: Build.

That’s it! You’ve successfully used the CMake tool to configure and build the project.

In case of any error with the project, simply run the CMake: Debug, and it will show where the error is on the code.

CMake With CPack

Merienda you have a project configured and built as we did with CMake, you need a way to build the software to make it installable. What you need is a way or tool that lets you build the project on your development machine and create a form that can be transferred and installed on another device. That’s what CPack does.

CPack will create an installer and a package for the project. It can create binary and source packages. The good thing is that CPack supports the creation of installers for OS X, RPMs, zip files, .tar.gz, Debian packages, Windows, and .sh.

CPack works to create a duplicate of the source tree for the project and tar or zip file, and you can transfer the file to another machine and store them in the correct directory and have your project up and running. CPack does most of the work, including creating a temporary directory for the project and copying the install tree in a suitable format for the packaging tool.

Using CPack With CMake

Since CPack is part of CMake, combining the two is pretty easy. In our C++ project using CMake, we had a CMakeLists.txt file created. Inside the file, there is support for CPack that comes auto-generated, as shown.

Therefore, the remaining part is to generate the installers and packages.

To do so, first, navigate to the build directory inside the project directory. In our example, it will be:

You can list the different files in the directory.

To generate the installers, run the command:

$ cpack -C CPackConfig.cmake

You can note the different generators from the output below, including .tar.gz, .sh, and .tar.z.

Alternatively, you can run the command:

$ cpack -C CPackSourceConfig.cmake

You now have the needed packages for your project.


CMake and CPack are helpful tools for generating configuration files, building, testing, and packaging projects. There are tons of options that you can use with the commands to achieve different things. This guide covered what CPack and CMake are, then went ahead to show an example usage that configures and builds a C++ project with CMake and packages it with CPack.

Source link

Photo: Recent family gathering in Korea celebrating ‘Parents Day’ on May 8th 2022.

I feel bad that I haven’t given them this opportunity yet – an opportunity to have days filled with fun, noisy family gatherings over the holidays. An opportunity to have a fight with cousins and rumble around the house screaming.

This is why, I am taking my kids to Korea this summer. It’s a little challenging as COVID is still a bad situation there but this will be a short trip. I hope I can give some of those ‘extended family’ memories to my kids as we visit with family.

I want to spend more time with my dad – I hope I can ask him how he felt when I was growing up. I want to ask him if he was worried like me. I want to ask him if it was hard for him sending me abroad and not being able to see me for many years.

Although I chose this career path and I love it – I don’t think I had enough thoughts about what my (and my own family’s) life would be like if I live abroad. I don’t regret on any of my choices – I rather feel I am truly blessed. However, growing up with the culture where ‘Hyo(filial duty)’ is one of the most important virtue in Korea – I am not doing it right as I can’t live near my parents and help them when they needed me.

I think many Asian cultures have this deep rooted family foundation in which the children take care of the parents when they get older. But for those of us who dreamed big and moved out of the countries we grew up in to search for a new life, an opportunity to build a better life, this is hard.

Yesterday I was talking to my mom and she told me my dad fell on the steps outdoor and hurt his leg. I wished I could run back to their house and help him visit a doctor’s office – but I can’t.  All I could do was make a few phone calls.

These thoughts and feelings never came up when I was younger. They were probably planted in my heart long ago when I was a still kid – but it took more than 30 years to grow and finally bloom into a more mature, grown-up heart.

Source link