From 80c9ae659783b54cc32f205ae585b13951efbcb5 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 27 May 2024 18:27:24 +0200 Subject: [PATCH] Add Conan build support (#597) * Add Conan build support Signed-off-by: Uilian Ries * Define GCC-13 as default Signed-off-by: Uilian Ries * Conan build missing Signed-off-by: Uilian Ries * Simplify build name Signed-off-by: Uilian Ries --------- Signed-off-by: Uilian Ries --- .github/workflows/linux-conan.yml | 44 +++++++++++++++++++++++++++ .github/workflows/linux-gxx-build.yml | 31 ------------------- README.md | 18 +++++++++++ conanfile.txt | 12 ++++++++ 4 files changed, 74 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 00000000..12c6c0ef --- /dev/null +++ b/.github/workflows/linux-conan.yml @@ -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 diff --git a/.github/workflows/linux-gxx-build.yml b/.github/workflows/linux-gxx-build.yml index 3dd8ea6f..c50c37ff 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 62dc09cb..ad6d61fd 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 00000000..09232bf9 --- /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