Building your first project
Now, it’s time to get your hands dirty and see if your installation worked. We have provided an example of a simple hello world
project that you can download and build right away. Open a console, type in the following, and you’ll be ready to go:
git clone https://github.com/PacktPublishing/CMake-Best-Practices---2nd-Edition.git cd CMake-Best-Practices---2nd-Edition/chapter01/simple_executable cmake -S . -B build cmake -–build ./build
This will result in an executable called ch_simple_executable
that prints out Welcome to CMake Best Practices
on the console.
Let’s have a detailed look at what happened here:
First, the example repository is checked out using Git. The file structure of the example CMake project located in the chapter01/simple_executable
subfolder will look like this before the build:
. ├── CMakeLists.txt └── src └...