From fad7a8c9b8847f470ccdfbcc975e7dffba3f1b8f Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 27 May 2024 17:51:35 +0200 Subject: [PATCH 1/4] Add Conan build support Signed-off-by: Uilian Ries --- .github/workflows/linux-conan.yml | 41 +++++++++++++++++++++++++++ .github/workflows/linux-gxx-build.yml | 31 -------------------- README.md | 18 ++++++++++++ conanfile.txt | 12 ++++++++ 4 files changed, 71 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/linux-conan.yml create mode 100644 conanfile.txt diff --git a/.github/workflows/linux-conan.yml b/.github/workflows/linux-conan.yml new file mode 100644 index 000000000..d21bda402 --- /dev/null +++ b/.github/workflows/linux-conan.yml @@ -0,0 +1,41 @@ +name: Build using external dependencies with Conan + +on: + push: + branches: + - 'main' + - 'conan-build' + workflow_dispatch: + pull_request: + +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: | + CC=gcc-13 CXX=g++-13 conan profile detect + - name: Install dependencies + run: conan install -r conancenter -s compiler.cppstd=20 conanfile.txt + - 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 diff --git a/.github/workflows/linux-gxx-build.yml b/.github/workflows/linux-gxx-build.yml index 3dd8ea6fc..c50c37ffb 100644 --- a/.github/workflows/linux-gxx-build.yml +++ b/.github/workflows/linux-gxx-build.yml @@ -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 diff --git a/README.md b/README.md index 62dc09cbc..ad6d61fd7 100644 --- a/README.md +++ b/README.md @@ -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++! 🚀 diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 000000000..09232bf9a --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,12 @@ +[requires] +fmt/10.2.1 + +[test_requires] +gtest/1.14.0 + +[generators] +CMakeDeps +CMakeToolchain + +[layout] +cmake_layout From 164f854817b715e6b72063a21482acd36f92d062 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 27 May 2024 17:52:55 +0200 Subject: [PATCH 2/4] Define GCC-13 as default Signed-off-by: Uilian Ries --- .github/workflows/linux-conan.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-conan.yml b/.github/workflows/linux-conan.yml index d21bda402..c993d3966 100644 --- a/.github/workflows/linux-conan.yml +++ b/.github/workflows/linux-conan.yml @@ -4,10 +4,13 @@ on: push: branches: - 'main' - - 'conan-build' workflow_dispatch: pull_request: +env: + CC: gcc-13 + CXX: g++-13 + jobs: conan: runs-on: ubuntu-24.04 @@ -22,7 +25,7 @@ jobs: run: pip install conan ninja - name: Configure Conan profile run: | - CC=gcc-13 CXX=g++-13 conan profile detect + conan profile detect - name: Install dependencies run: conan install -r conancenter -s compiler.cppstd=20 conanfile.txt - name: CMake configure From 3dcfd49b9d7cd1a52c495fd899609f1122d4f471 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 27 May 2024 17:54:51 +0200 Subject: [PATCH 3/4] Conan build missing Signed-off-by: Uilian Ries --- .github/workflows/linux-conan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-conan.yml b/.github/workflows/linux-conan.yml index c993d3966..b7f0f183c 100644 --- a/.github/workflows/linux-conan.yml +++ b/.github/workflows/linux-conan.yml @@ -27,7 +27,7 @@ jobs: run: | conan profile detect - name: Install dependencies - run: conan install -r conancenter -s compiler.cppstd=20 conanfile.txt + run: conan install conanfile.txt -r conancenter -s compiler.cppstd=20 --build=missing - name: CMake configure run: | cmake -G Ninja \ From 4d979f27d483b2e3c60d18992408e73c296a6ddd Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 27 May 2024 17:55:59 +0200 Subject: [PATCH 4/4] Simplify build name Signed-off-by: Uilian Ries --- .github/workflows/linux-conan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-conan.yml b/.github/workflows/linux-conan.yml index b7f0f183c..12c6c0ef6 100644 --- a/.github/workflows/linux-conan.yml +++ b/.github/workflows/linux-conan.yml @@ -1,4 +1,4 @@ -name: Build using external dependencies with Conan +name: conan on: push: