Skip to content

Commit 9a2d22a

Browse files
authored
Update README.md
Add description of FetchContent mechanism
1 parent 18202be commit 9a2d22a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,25 @@ The ```sudo``` is there to give you the required permissions to install into you
3535
We have moved the tutorials to a different repository https://github.com/dacelib/dace-tutorials to keep the main repository clean. You can clone the tutorials repository and follow the instructions there to get started with DACE.
3636

3737
Also have a look at the [DACE Wiki pages](https://github.com/dacelib/dace/wiki) if you have further questions.
38+
39+
## Embedding the DACE in other projects
40+
To use the DACE library without installing it locally, use the [FetchContent](https://cmake.org/cmake/help/v3.19/module/FetchContent.html) mechanism of CMake.
41+
42+
Include this code at the start of your CMakeList.txt file to have CMake automatically clone and build the DACE within your project and make the resulting libraries available as the `dace::dace_s` (static) and `dace::dace` (dynamic) targets.
43+
```
44+
include(FetchContent)
45+
FetchContent_Declare(
46+
DACE
47+
GIT_REPOSITORY https://github.com/dacelib/dace.git
48+
GIT_TAG v2.1.0
49+
)
50+
FetchContent_MakeAvailable(DACE)
51+
add_library(dace::dace ALIAS dace)
52+
add_library(dace::dace_s ALIAS dace_s)
53+
```
54+
55+
To build against the DACE, simply add your own executable and link it with one of these targets:
56+
```
57+
add_executable(my-code my-code.cpp)
58+
target_link_libraries(my-code PUBLIC dace::dace_s)
59+
```

0 commit comments

Comments
 (0)