Skip to content

Commit 2ad90a2

Browse files
committed
CMake post
1 parent f45f7a0 commit 2ad90a2

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

content/posts/cmake-learning.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
author: "Phong Nguyen"
3+
title: "CMake Guide"
4+
date: "2025-08-21"
5+
description: "CMake Learning."
6+
tags: ["cmake"] #tags search
7+
FAcategories: ["syntax"] #The category of the post, similar to tags but usually for broader classification.
8+
FAseries: ["Themes Guide"] #indicates that this post is part of a series of related posts
9+
aliases: ["migrate-from-jekyl"] #Alternative URLs or paths that can be used to access this post, useful for redirects from old posts or similar content.
10+
ShowToc: true # Determines whether to display the Table of Contents (TOC) for the post.
11+
TocOpen: true # Controls whether the TOC is expanded when the post is loaded.
12+
weight: 2 # The order in which the post appears in a list of posts. Lower numbers make the post appear earlier.
13+
---
14+
## 1. Introduction
15+
- It's a meta-build system generator.
16+
- How it works:
17+
- We write high-level instructions in a CMakeLists.txt file (platform-agnostic).Then CMake generates build system files for the platform we choose:
18+
- On Linux/Unix → generates Makefile (for make) or build.ninja (for ninja).
19+
- On Windows → generates Visual Studio solutions (.sln).
20+
- On macOS → can generate Xcode projects.
21+
22+
## 2. Setup
23+
- Linux: Install: `sudo apt install cmake` , Verify: `cmake --version`
24+
25+
## 3. How to work with CMake
26+
27+
1. Create CMakeLists.txt and resources file
28+
2. Run `cmake <dir-contain-CMakeLists.txt>` to set up & generate build system.
29+
3. Run `cmake --build <dir-contain-buildsystem>` to actually build/compile the project.
30+
4. Run the target build (e.g. `./targetName`)
31+
32+
33+
### 3.1.
34+
> CMakeLists.txt
35+
```makefile
36+
cmake_minimum_required(VERSION 3.0) // specifying a minimum CMake version
37+
project(CmakeprojectName) // set the project name
38+
add_executeable(targetName "headerfile.h" "sourcefile1.cpp" "sourcefile2.cpp") // specified source code files
39+
```

content/posts/makefile-learning.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ TocOpen: true # Controls whether the TOC is expanded when the post is loaded.
1212
weight: 2 # The order in which the post appears in a list of posts. Lower numbers make the post appear earlier.
1313
---
1414
## Introduction
15+
>It's a build tool (specifically, make is a build automation utility).
16+
How it works: Reads a file called Makefile that describes rules for how to build source files into targets (executables, libraries, etc.).
17+
1518
GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files.
1619
Make get its knowledge of how to build your program from a file called the `makefile`, which lists each of the non-source files and how to compute it from the other files.
1720
When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program.

0 commit comments

Comments
 (0)