-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
null
committed
Oct 9, 2023
1 parent
5cba84a
commit 77ee410
Showing
4 changed files
with
27 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# Set C/C++ standard | ||
|
||
<<< ./CMakeLists.txt{cmake} | ||
|
||
::: code-group | ||
|
||
<<< ./src/main1.c | ||
|
||
<<< ./src/main2.cpp | ||
|
||
::: | ||
|
||
```sh | ||
cmake -B build | ||
cmake --build build | ||
``` | ||
|
||
<iframe frameborder="0" height="500" style="width: 100%" src="https://replit.com/@jcbhmr/cmakebyexampledev-set-standard?embed=1#CMakeLists.txt"></iframe> | ||
# Set C/C++ standard | ||
|
||
<<< ./CMakeLists.txt{cmake} | ||
|
||
::: code-group | ||
|
||
<<< ./src/main1.c | ||
|
||
<<< ./src/main2.cpp | ||
|
||
::: | ||
|
||
```sh | ||
cmake -B build | ||
cmake --build build | ||
``` | ||
|
||
<iframe frameborder="0" height="500" style="width: 100%" src="https://replit.com/@jcbhmr/cmakebyexampledev-set-standard?embed=1#CMakeLists.txt"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(myproject) | ||
add_library(mylib STATIC lib.c) | ||
add_library(mylib STATIC mylib.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# Build a static library | ||
|
||
We can use the `add_library()` function to define a `STATIC` library (`.a`) or [a `SHARED` library (`.so`)]. | ||
We can use the `add_library()` function to define a `STATIC` library (`.a` or | ||
`.lib`) ora `SHARED` library (`.so` or `.dll`). Check out the [build a shared | ||
library] example for the `SHARED` counterpart. | ||
|
||
<<< ./CMakeLists.txt{cmake} | ||
<<< ./CMakeLists.txt{3 cmake} | ||
|
||
<<< ./lib.c | ||
<<< ./mylib.c | ||
|
||
<iframe frameborder="0" style="width: 100%; height: 500px" src="https://replit.com/@jcbhmr/cmakebyexampledev-static?embed=1"></iframe> | ||
|
||
[build a shared library]: /shared/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include <mylib.h> | ||
int add(int a, int b) { | ||
return a + b; | ||
} |