Skip to content

Commit

Permalink
Feature: conan2 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
liss-h authored Nov 14, 2023
1 parent e7606b5 commit c07609f
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 200 deletions.
166 changes: 79 additions & 87 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,96 @@
name: CI

on: [push, pull_request, release]
on: [pull_request]

jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- {
name: linux-x64-clang-9,
os: ubuntu-18.04,
cxx: clang++-9,
cmake-build-type: Release
}
- {
name: macos-x64-gcc,
os: macos-10.15,
cxx: g++,
cmake-build-type: Release
}
- {
name: macos-x64-clang,
os: macos-10.15,
cxx: clang++,
cmake-build-type: Release
}
- {
name: linux-x64-clang-12-sanitize,
os: ubuntu-20.04,
cxx: clang++-12,
cxx-flags: "-fsanitize=address,undefined",
cmake-build-type: Release
}
- {
name: linux-x64-gcc-10-coverage,
os: ubuntu-20.04,
cxx: g++-10,
cxx-flags: --coverage,
gcov-tool: gcov-10,
cmake-build-type: Debug
}
- {
name: linux-x64-clang-11,
os: ubuntu-20.04,
cxx: clang++-11,
cmake-build-type: Release
}
- {
name: linux-x64-clang-12,
os: ubuntu-22.04,
cxx: clang++-12,
cmake-build-type: Release
}
- {
name: linux-x64-clang-13,
os: ubuntu-22.04,
cxx: clang++-13,
cmake-build-type: Release
}
- {
name: linux-x64-clang-14,
os: ubuntu-22.04,
cxx: clang++-14,
cmake-build-type: Release
}
- {
name: linux-x64-gcc-11,
os: ubuntu-22.04,
cxx: g++-11,
cmake-build-type: Release
}
- name: linux-x64-clang-15
os: ubuntu-22.04
cxx: clang++-15
- name: linux-x64-clang-16-sanitize
os: ubuntu-20.04
cxx: clang++-16
cxx-flags: "-fsanitize=address,undefined"

- name: linux-x64-gcc-12
os: ubuntu-22.04
cxx: g++-12
- name: linux-x64-gcc-13-coverage
os: ubuntu-22.04
cxx: g++-13
cxx-flags: -Werror --coverage
gcov-tool: gcov-10

name: ${{matrix.config.name}}
runs-on: ${{matrix.config.os}}
steps:
- uses: actions/checkout@v2
# 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
- name: Install tools
run: |
sudo apt-get install -y python3 python3-pip
- name: Get minimum cmake version
uses: lukka/[email protected]
with:
cmakeVersion: 3.22.6

- name: Install compiler
id: install_cc
uses: rlalik/[email protected]
with:
compiler: ${{ matrix.config.cxx }}

- name: Install mold
uses: rui314/setup-mold@v1

- name: Configure conan
run: |
pip3 install "conan==1.60.1"
conan profile new --detect default
conan profile update settings.compiler.libcxx=libstdc++11 default
- name: Cache conan data
id: cache-conan
uses: actions/cache@v3
with:
path: ~/.conan/data
key: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-conan

# Linux or macOS
- name: Install boost (Linux or macOS)
run: vcpkg install boost-test boost-container boost-interprocess
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Check out sources
uses: actions/checkout@v3

- name: Configure CMake (Linux or macOS)
run: cmake -DCMAKE_BUILD_TYPE=${{matrix.config.cmake-build-type}} -DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -S ${{github.workspace}}/tests -B ${{github.workspace}}/build
env:
CXX: ${{matrix.config.cxx}}
CXXFLAGS: ${{matrix.config.cxx-flags}}
if: runner.os == 'Linux' || runner.os == 'macOS'
- 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

- name: Build (Linux or macOS)
run: cmake --build ${{github.workspace}}/build --verbose
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Build
working-directory: build_dir
run: cmake --build . --parallel 2

- name: Test (Linux or macOS)
run: ${{github.workspace}}/build/tsl_sparse_map_tests
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Run tests
working-directory: build_dir
run: ctest --parallel 2 --verbose

- name: Coverage
run: |
sudo apt-get install -y lcov
lcov -c -b ${{github.workspace}}/include -d ${{github.workspace}}/build -o ${{github.workspace}}/coverage.info --no-external --gcov-tool ${{matrix.config.gcov-tool}}
bash <(curl -s https://codecov.io/bash) -f ${{github.workspace}}/coverage.info
if: ${{matrix.config.name == 'linux-x64-gcc-10-coverage'}}
#- name: Coverage
# run: |
# sudo apt-get install -y lcov
# lcov -c -b ${{github.workspace}}/include -d ${{github.workspace}}/build -o ${{github.workspace}}/coverage.info --no-external --gcov-tool ${{matrix.config.gcov-tool}}
# bash <(curl -s https://codecov.io/bash) -f ${{github.workspace}}/coverage.info
# if: ${{matrix.config.name == 'linux-x64-gcc-13-coverage'}}
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 @@ -7,14 +7,14 @@ concurrency:
cancel-in-progress: true

jobs:
publish-release:
publish-conan-branch-package:
uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/publish-conan-branch-package.yml@main
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
cmake-version: 3.22.6
conan-version: 1.59
conan-version: 2.0.13
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 @@ -12,14 +12,14 @@ concurrency:
group: publish-release-${{ github.workflow }}-${{ github.ref }}

jobs:
publish-conan-branch-package:
publish-release:
uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/publish-release.yml@main
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
cmake-version: 3.22.6
conan-version: 1.59
conan-version: 2.0.13
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
67 changes: 5 additions & 62 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,55 +75,9 @@ deactivate_run.sh
environment_run.ps1.env
environment_run.sh.env

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

Expand All @@ -148,23 +102,12 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### Ninja ###
.ninja_deps
.ninja_log

# End of https://www.toptal.com/developers/gitignore/api/c++,ninja,cmake,intellij+all,conan
# End of https://www.toptal.com/developers/gitignore/api/c++,ninja,cmake,intellij+all,conan

.idea/
test_package/build/
test_package/CMakeUserPresets.json
41 changes: 28 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.22)
project(dice-sparse-map
VERSION 0.2.4
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()

find_package(Boost REQUIRED)
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}")
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME}
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")

target_link_libraries(${PROJECT_NAME} INTERFACE
Boost::headers
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
)

if(MSVC)
target_sources(${PROJECT_NAME} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tsl-sparse-map.natvis>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_DATAROOTDIR}/tsl-sparse-map.natvis>")
target_sources(${PROJECT_NAME}
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tsl-sparse-map.natvis>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_DATAROOTDIR}/tsl-sparse-map.natvis>")
endif()

if (IS_TOP_LEVEL)
if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
message("Tests are configured to be build.")
include(CTest)
enable_testing()
add_subdirectory(tests)
endif ()

if (PROJECT_IS_TOP_LEVEL)
include(cmake/install_interface_library.cmake)
install_interface_library("${PROJECT_NAME}" "${PROJECT_NAME}" "${PROJECT_NAME}" "include")
endif ()


Loading

0 comments on commit c07609f

Please sign in to comment.