Skip to content

Commit

Permalink
Add Conan build support (#597)
Browse files Browse the repository at this point in the history
* Add Conan build support

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Define GCC-13 as default

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Conan build missing

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Simplify build name

Signed-off-by: Uilian Ries <uilianries@gmail.com>

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed May 27, 2024
1 parent 0df41df commit 80c9ae6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 31 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/linux-conan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: conan

on:
push:
branches:
- 'main'
workflow_dispatch:
pull_request:

env:
CC: gcc-13
CXX: g++-13

jobs:
conan:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install conan and ninja
run: pip install conan ninja
- name: Configure Conan profile
run: |
conan profile detect
- name: Install dependencies
run: conan install conanfile.txt -r conancenter -s compiler.cppstd=20 --build=missing
- name: CMake configure
run: |
cmake -G Ninja \
-DUSE_SYSTEM_DEPENDENCIES:BOOL=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_CXX_COMPILER=g++-13 \
-DCMAKE_C_COMPILER=gcc-13 \
-DBUILD_TESTING:BOOL=ON \
--preset=conan-release
- name: CMake Build
run: cmake --build --preset=conan-release
- name: Run unit tests
working-directory: ${{github.workspace}}/build/Release/tests
run: ctest --print-output-on-failure
31 changes: 0 additions & 31 deletions .github/workflows/linux-gxx-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,3 @@ jobs:

- name: Run docker container
run: docker run test

external_dependencies:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install conan and ninja
run: pip install conan ninja
- name: Install libraries dependencies
run: |
CC=gcc-13 CXX=g++-13 conan profile detect && \
conan install -r conancenter -s compiler.cppstd=20 \
--requires=fmt/10.2.1 --requires=gtest/1.14.0 \
-g CMakeToolchain -g CMakeDeps \
--build=missing -of conan \
-c tools.build:compiler_executables='{"c": "gcc-13", "cxx": "g++-13"}'
- name: CMake build
run: |
cmake -B build -S . -G Ninja \
-DUSE_SYSTEM_DEPENDENCIES=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=g++-13 \
-DCMAKE_C_COMPILER=gcc-13 \
-DBUILD_TESTING:BOOL=ON \
-DCMAKE_TOOLCHAIN_FILE=conan/conan_toolchain.cmake && \
cmake --build build
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ If you have any confusion please refer to the respective guides.
In order to use external dependencies installed in your system, you can set the `USE_SYSTEM_DEPENDENCIES` CMake flag
to `ON`.

## Building the library with [Conan](https://conan.io/)

The library can be built using Conan package manager to solve external dependencies.
To build the library with Conan, follow the steps below:

1. Install required dependencies:

```bash
conan install conanfile.txt --build=missing
```

2. Build the library:

```bash
cmake --preset=conan-release -DUSE_SYSTEM_DEPENDENCIES:BOOL=ON
cmake --build --preset=conan-release
```

## ✨ Contributing

We would love it if you contributed to Faker C++! 🚀
Expand Down
12 changes: 12 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[requires]
fmt/10.2.1

[test_requires]
gtest/1.14.0

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout

0 comments on commit 80c9ae6

Please sign in to comment.