diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f9b0d2..097ab6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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/checkout@v4.1.6 + + - 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 diff --git a/.github/workflows/publish-conan-branch-package.yml b/.github/workflows/publish-conan-branch-package.yml index 2d3b693..1da1678 100644 --- a/.github/workflows/publish-conan-branch-package.yml +++ b/.github/workflows/publish-conan-branch-package.yml @@ -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 }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 34d9790..794d0ab 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index e6eb29e..ccd78d7 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,5 @@ fabric.properties .idea/ test_package/build/ test_package/CMakeUserPresets.json +conan_provider.cmake +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eb85e2..c9ba1d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -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.") @@ -6,19 +6,8 @@ project(dice-sparse-map 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}) diff --git a/conanfile.py b/conanfile.py index 02d0a71..c74577b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -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 @@ -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: @@ -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"):