Skip to content

Commit 4992558

Browse files
committed
docs: Update CMake instructions
1 parent d47daa7 commit 4992558

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

README.md

+24-12
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ For more information, see the [Python bindings repository](https://github.com/kr
4242
- **Clean and flexible** code base
4343
- Warning-free even on high warning levels such as `-Wall`, `-Wextra`, `-pedantic`
4444
- Follows [SOLID](https://en.wikipedia.org/wiki/SOLID) design principles
45-
- Extensive unit tests
45+
- Extensive [unit tests](#building-the-unit-tests)
4646
- Linted with [Clang-Tidy](https://clang.llvm.org/extra/clang-tidy/)
4747

4848
For a complete guide, please see the [documentation](docs/index.md#top).
@@ -147,10 +147,10 @@ Steps to compile and run the example:
147147
148148
## Using it with CMake
149149
150-
If you are using CMake, you can use the `FetchContent` module to download and include the library in your project.
151-
Here is an example of how to use AutoDiff in a CMake project:
150+
### Including it in your project with CMake
152151
153-
### Project files
152+
If you are using CMake, you can use the `FetchContent` module to download and include the library in your project.
153+
Here is an example of how to use AutoDiff in a CMake project.
154154
155155
Create a `CMakeLists.txt` file:
156156
@@ -184,23 +184,35 @@ int main()
184184
std::cout << "y(1.0) = " << y() << '\n';
185185
AutoDiff::Function f(y);
186186
f.pushTangentAt(x);
187-
std::cout << "dy/dx = " << d(y) << '\n';
187+
std::cout << "df/dx = " << d(y) << '\n';
188188
}
189189
```
190190
191+
Build the project:
192+
193+
```bash
194+
mkdir build && cd build
195+
cmake .. -DFETCHCONTENT_UPDATES_DISCONNECTED=ON
196+
cmake --build .
197+
```
198+
199+
This will download the repository into your build folder and build the project.
200+
Use the setting `FETCHCONTENT_UPDATES_DISCONNECTED=ON` to avoid downloading the repository every time you configure your project.
201+
191202
### Building the unit tests
192203
193-
Configure CMake for GCC/Clang:
204+
Make sure you have `Catch2` (v3) and `Eigen` (v3.4) installed.
205+
206+
Download the repository and configure CMake/Clang:
194207
195208
```bash
196-
cmake --preset tests-ninja-linux-release -DFETCHCONTENT_UPDATES_DISCONNECTED=ON
209+
git clone https://github.com/krippner/auto-diff.git
210+
cd auto-diff
211+
cmake --preset tests-ninja-linux-release
197212
```
198213
199214
For Visual Studio, you can use the `tests-msvc2022` preset.
200215
201-
This will download the repository into your build folder.
202-
Use the setting `FETCHCONTENT_UPDATES_DISCONNECTED=ON` to avoid downloading the repository every time you configure your project.
203-
204216
Build and run:
205217
206218
```bash
@@ -211,7 +223,7 @@ ctest
211223
212224
## Using it with Conan
213225
214-
### Installation
226+
### Installation with Conan
215227
216228
Download the repository and install the library to your Conan cache:
217229
@@ -223,7 +235,7 @@ conan create . --build=missing
223235
224236
This will also build and run the unit tests, unless your Conan configuration `tools.build:skip_test` is set to `True`.
225237
226-
### Including it in your project
238+
### Including it in your project with Conan
227239
228240
Add the following line to your `conanfile.txt`:
229241

0 commit comments

Comments
 (0)