Skip to content

Commit 5d069c9

Browse files
Add Make to CMake migration section
Signed-off-by: Ronald Cron <[email protected]>
1 parent 79a2631 commit 5d069c9

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

docs/4.0-migration-guide/repo-split.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,54 @@ The previous `.sln` and `.vcxproj` files are no longer distributed or generated.
77
See the `Compiling` section in README.md for instructions on building the Mbed TLS libraries and tests with CMake.
88
If you develop in Microsoft Visual Studio, you could either generate a Visual Studio solution using a CMake generator, or open the CMake project directly in Visual Studio.
99

10+
### Translating Make commands to CMake
11+
12+
With the removal of GNU Make support, all build, test, and installation operations must now be performed using CMake.
13+
This section provides a quick reference for translating common `make` commands into their CMake equivalents.
14+
15+
#### Basic build workflow
16+
17+
Run `cmake -S . -B build` once before building to configure the build and generate native build files (e.g., Makefiles) in the `build` directory.
18+
This sets up an out-of-tree build, which is recommended.
19+
20+
| Make command | CMake equivalent | Description |
21+
|----------------|------------------------------------------------|--------------------------------------------------------------------|
22+
| `make` | `cmake --build build` | Build the libraries, programs, and tests in the `build` directory. |
23+
| `make test` | `ctest --test-dir build` | Run the tests produced by the previous build. |
24+
| `make clean` | `cmake --build build --target clean` | Remove build artifacts produced by the previous build. |
25+
| `make install` | `cmake --install build --prefix build/install` | Install the built libraries, headers, and tests to `build/install`. |
26+
27+
#### Building specific targets
28+
29+
Unless otherwise specified, the CMake command in the table below should be preceded by a `cmake -S . -B build` call to configure the build and generate build files in the `build` directory.
30+
31+
| Make command | CMake equivalent | Description |
32+
|-----------------|---------------------------------------------------------------------|---------------------------|
33+
| `make lib` | `cmake --build build --target lib` | Build only the libraries. |
34+
| `make tests` | `cmake -S . -B build -DENABLE_PROGRAMS=Off && cmake --build build` | Build test suites. |
35+
| `make programs` | `cmake --build build --target programs` | Build example programs. |
36+
| `make apidoc` | `cmake --build build --target mbedtls-apidoc` | Build documentation. |
37+
38+
Target names may differ slightly; use `cmake --build build --target help` to list all available CMake targets.
39+
40+
There is no CMake equivalent for `make generated_files` or `make neat`.
41+
Generated files are automatically created in the build tree with `cmake --build build` and removed with `cmake --build build --target clean`.
42+
If you need to build the generated files in the source tree without involving CMake, you can call `framework/scripts/make_generated_files.py`.
43+
44+
There is no CMake equivalent for `make uninstall`.
45+
To remove an installation, simply delete the directory specified as the installation prefix.
46+
47+
#### Common build options
48+
49+
| Make usage | CMake usage | Description |
50+
|----------------------------|-------------------------------------------------------|----------------------|
51+
| `make DEBUG=1` | `cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug` | Build in debug mode. |
52+
| `make SHARED=1` | `cmake -S . -B build -DUSE_SHARED_MBEDTLS_LIBRARY=On` | Also build shared libraries. |
53+
| `make GEN_FILES=""` | `cmake -S . -B build -DGEN_FILES=OFF` | Skip generating files (not a strict equivalent). |
54+
| `make DESTDIR=install_dir` | `cmake --install build --prefix install_dir` | Specify installation path. |
55+
| `make CC=clang` | `cmake -S . -B build -DCMAKE_C_COMPILER=clang` | Set the compiler. |
56+
| `make CFLAGS='-O2 -Wall'` | `cmake -S . -B build -DCMAKE_C_FLAGS="-O2 -Wall"` | Set compiler flags. |
57+
1058
## Repository split
1159
In Mbed TLS 4.0, the project was split into two repositories:
1260
- [Mbed TLS](https://github.com/Mbed-TLS/mbedtls): provides TLS and X.509 functionality.

0 commit comments

Comments
 (0)