Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Conan build support #597

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading