Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to conan 2 #41

Merged
merged 7 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 17 additions & 31 deletions .github/workflows/code_testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,56 +31,42 @@ jobs:

steps:
- name: Add repos for for gcc-13 and clang-16
run: |
# gcc-13
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y

source /etc/os-release

# clang-16
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

# clang-17
echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-17 main" | sudo tee /etc/apt/sources.list.d/llvm-17.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/llvm-17.gpg > /dev/null

sudo apt-get update -y
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt@main

- name: Install CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.27.7
cmakeVersion: 3.29.3

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

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

- name: Install conan
shell: bash
env:
CC: ${{ steps.install_cc.outputs.cc }}
CXX: ${{ steps.install_cc.outputs.cxx }}
- name: add conan user
run: |
pip3 install "conan==1.62.0"
conan profile new --detect default
conan profile update env.CXX="${CXX}" default
conan profile update env.CC="${CC}" 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@v4
uses: actions/cache@v4.0.2
with:
path: ~/.conan/data
key: tests-${{ matrix.config.os }}-${{ matrix.config.compiler }}-conan
path: ~/.conan2/p
key: ${{ matrix.config.os }}-${{ matrix.config.compiler }}

- 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
run: cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DBUILD_EXAMPLES=On -DUSE_CONAN=On -G Ninja -B build .
run: cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DBUILD_EXAMPLES=On -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -DCONAN_INSTALL_ARGS="--build=missing;-o=boost/*:header_only=True" -G Ninja -B build .
env:
CC: ${{ steps.install_cc.outputs.cc }}
CXX: ${{ steps.install_cc.outputs.cxx }}
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.1
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 @@ -105,3 +105,5 @@ fabric.properties
.idea/
test_package/build/
test_package/CMakeUserPresets.json
/CMakeUserPresets.json
/conan_provider.cmake
13 changes: 1 addition & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

project(
dice-template-library
Expand All @@ -7,7 +7,6 @@ project(
"This template library is a collection of template-oriented code that we, the Data Science Group at UPB, found pretty handy. It contains: `switch_cases` (Use runtime values in compile-time context), `integral_template_tuple` (Create a tuple-like structure that instantiates a template for a range of values), `integral_template_variant` (A wrapper type for `std::variant` guarantees to only contain variants of the form `T<IX>` and `for_{types,values,range}` (Compile time for loops for types, values or ranges))."
HOMEPAGE_URL "https://dice-research.org/")

option(USE_CONAN "If available, use conan to retrieve dependencies." ON)
option(BUILD_TESTING "build tests" OFF)
option(BUILD_EXAMPLES "build examples" OFF)

Expand All @@ -18,16 +17,6 @@ if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CMakeCache.txt)
endif ()
endif ()

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

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

install_packages_via_conan("${CMAKE_SOURCE_DIR}/conanfile.py" "${CONAN_OPTIONS};boost/*:header_only=True")
endif ()
liss-h marked this conversation as resolved.
Show resolved Hide resolved

add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

Expand Down
19 changes: 14 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,25 @@ class DiceTemplateLibrary(ConanFile):
topics = "template", "template-library", "compile-time", "switch", "integral-tuple"
package_type = "header-library"
generators = "CMakeDeps", "CMakeToolchain"
options = {"with_test_deps": [True, False]}
default_options = {"with_test_deps": False}
settings = "os", "compiler", "build_type", "arch"
exports_sources = "include/*", "CMakeLists.txt", "cmake/*", "LICENSE"
no_copy_source = True

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

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 set_name(self):
if not hasattr(self, 'name') or self.version is None:
Expand All @@ -40,7 +50,6 @@ def set_version(self):

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

for dir in ("lib", "res", "share"):
Expand Down
10 changes: 2 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Boost REQUIRED COMPONENTS)

include(FetchContent)
FetchContent_Declare(
DocTest
GIT_REPOSITORY "https://github.com/doctest/doctest.git"
GIT_TAG "v2.4.8"
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(DocTest)
find_package(DocTest REQUIRED)

add_custom_target(build_tests)
add_custom_target(run_tests COMMAND ${CMAKE_CTEST_COMMAND})
Expand All @@ -24,7 +18,7 @@ macro(CUSTOM_ADD_TEST)
endif()
add_test(NAME ${ARGV0} COMMAND ${ARGV0})
target_link_libraries(
${ARGV0} PRIVATE doctest dice-template-library::dice-template-library)
${ARGV0} PRIVATE doctest::doctest dice-template-library::dice-template-library)
add_dependencies(build_tests ${ARGV0})
endmacro()

Expand Down
Loading