Skip to content

Commit 35cc2cc

Browse files
committed
Added FetchContent integration example
1 parent f5f5b58 commit 35cc2cc

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(demo_fc)
3+
4+
set(CMAKE_CXX_STANDARD 17) # C++17 or newer is required
5+
6+
include(FetchContent)
7+
FetchContent_Declare(BitmapPlusPlus
8+
GIT_REPOSITORY "https://github.com/baderouaich/BitmapPlusPlus"
9+
GIT_TAG "master"
10+
)
11+
FetchContent_MakeAvailable(BitmapPlusPlus)
12+
13+
add_executable(${PROJECT_NAME}
14+
"${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp"
15+
)
16+
17+
target_link_libraries(${PROJECT_NAME} LINK_PRIVATE bmp::BitmapPlusPlus)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <BitmapPlusPlus.hpp>
2+
3+
int main()
4+
{
5+
bmp::Bitmap bitmap(512, 512);
6+
for (auto& pixel : bitmap)
7+
{
8+
pixel = bmp::Pixel(42, 69, 96);
9+
}
10+
11+
bitmap.save("demo.bmp");
12+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Integration example using CPM
2+
3+
CPM stands for [CMake Package Manager](https://github.com/cpm-cmake) which is a convenience wrapper over CMake's
4+
FetchContent module. You can download the CPM.cmake from the
5+
project [releases page](https://github.com/cpm-cmake/CPM.cmake/releases/latest).
6+
7+
With CPM enabled, you can bring this library in using the following command:
8+
9+
```
10+
CPMAddPackage ( "gh:baderouaich/BitmapPlusPlus#master" )
11+
```
12+
13+
And link it to your target using:
14+
15+
```
16+
target_link_libraries( ${TARGET} LINK_PRIVATE bpp::BitmapPlusPlus )
17+
```
18+
19+
Note that your target needs to compile with C++17 or newer. After that, you can simply include the library in your code:
20+
21+
```cpp
22+
#include <BitmapPlusPlus.hpp>
23+
```

0 commit comments

Comments
 (0)