Skip to content

Commit

Permalink
upgrade to conan2 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcb5637 authored Jun 4, 2024
1 parent 60c6817 commit 9cfd536
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,16 @@ jobs:
steps:
# setup env
- name: Add repos for for gcc-13 and clang-16
run: |
# gcc-13
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
# clang-16
source /etc/os-release
echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-16 main" | sudo tee /etc/apt/sources.list.d/llvm-16.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/llvm-16.gpg > /dev/null
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt@main

- name: Install tools
run: |
sudo apt-get install -y python3 python3-pip
- name: Get minimum cmake version
uses: lukka/get-cmake@v3.24.3
uses: lukka/get-cmake@v3.29.3
with:
cmakeVersion: 3.22.6
cmakeVersion: 3.24

- name: Install compiler
id: install_cc
Expand All @@ -58,27 +51,33 @@ jobs:
uses: rui314/setup-mold@v1

- name: Configure conan
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan@main
with:
conan-version: 2.3.1

- name: add conan user
run: |
pip3 install "conan==1.60.1"
conan profile new --detect default
conan profile update settings.compiler.libcxx=libstdc++11 default
conan remote add -f dice-group https://conan.dice-research.org/artifactory/api/conan/tentris
- name: Cache conan data
id: cache-conan
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: ~/.conan/data
path: ~/.conan2/p
key: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-conan

- name: Check out sources
uses: actions/checkout@v3
uses: actions/[email protected]

- name: Get dependency provider
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_provider@main

- name: Configure CMake
env:
CC: ${{ steps.install_cc.outputs.cc }}
CXX: ${{ steps.install_cc.outputs.cxx }}
CXXFLAGS: ${{ matrix.config.cxx-flags }}
run: cmake -B build_dir -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
run: cmake -B build_dir -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake

- name: Build
working-directory: build_dir
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-conan-branch-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
cmake-version: 3.22.6
conan-version: 2.0.13
cmake-version: 3.24.0
conan-version: 2.3.0
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
4 changes: 2 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
cmake-version: 3.22.6
conan-version: 2.0.13
cmake-version: 3.24.0
conan-version: 2.3.0
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ fabric.properties
.idea/
test_package/build/
test_package/CMakeUserPresets.json
conan_provider.cmake
CMakeUserPresets.json
13 changes: 1 addition & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(dice-sparse-map
VERSION 0.2.5
DESCRIPTION "C++ implementation of a memory efficient hash map and hash set based on [tsl::sparse_map](https://github.com/Tessil/sparse-map). We added support for fancy pointers.")

include(cmake/boilerplate_init.cmake)
boilerplate_init()

option(USE_CONAN "Use conan to fetch dependencies" ON)
option(BUILD_TESTING "Build tests" OFF)

if (PROJECT_IS_TOP_LEVEL AND USE_CONAN)
include(cmake/conan_cmake.cmake)

if (BUILD_TESTING)
set(CONAN_OPTIONS "with_test_deps=True")
endif ()

install_packages_via_conan("${CMAKE_SOURCE_DIR}/conanfile.py" "${CONAN_OPTIONS}")
endif ()

add_library(${PROJECT_NAME} INTERFACE)
# Use dice::sparse_map as target, more consistent with other libraries conventions (Boost, Qt, ...)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
Expand Down
20 changes: 14 additions & 6 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re

from conan import ConanFile
from conan.tools.cmake import CMake
from conan.tools.cmake import cmake_layout, CMake
from conan.tools.files import rmdir, copy, load


Expand All @@ -14,12 +14,9 @@ class Recipe(ConanFile):
package_type = "header-library"
generators = "CMakeDeps", "CMakeToolchain"
no_copy_source = True
options = {"with_test_deps": [True, False]}
default_options = {"with_test_deps": False}

def requirements(self):
if self.options.with_test_deps:
self.requires("boost/1.83.0")
self.test_requires("boost/1.83.0")

def set_name(self):
if not hasattr(self, 'name') or self.version is None:
Expand All @@ -34,9 +31,20 @@ def set_version(self):
cmake_file = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt"))
self.description = re.search(r"project\([^)]*DESCRIPTION\s+\"([^\"]+)\"[^)]*\)", cmake_file).group(1)

def layout(self):
cmake_layout(self)

def build(self):
if not self.conf.get("tools.build:skip_test", default=False):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package_id(self):
self.info.clear()

def package(self):
cmake = CMake(self)
cmake.configure(variables={"USE_CONAN": False})
cmake.install()

for dir in ("lib", "res", "share"):
Expand Down

0 comments on commit 9cfd536

Please sign in to comment.