From 2bdf098bfcdce31bd53f66e384d645caa84f562e Mon Sep 17 00:00:00 2001 From: mcb Date: Mon, 27 May 2024 14:57:04 +0200 Subject: [PATCH 1/7] conan 2 --- .github/workflows/code_testing.yaml | 48 ++++++++++++------- .../publish-conan-branch-package.yml | 4 +- .github/workflows/publish-release.yml | 4 +- .gitignore | 2 + CMakeLists.txt | 13 +---- conanfile.py | 19 ++++++-- tests/CMakeLists.txt | 10 +--- 7 files changed, 54 insertions(+), 46 deletions(-) diff --git a/.github/workflows/code_testing.yaml b/.github/workflows/code_testing.yaml index 9f1ecfe..5e320b3 100644 --- a/.github/workflows/code_testing.yaml +++ b/.github/workflows/code_testing.yaml @@ -50,7 +50,7 @@ jobs: - name: Install CMake uses: lukka/get-cmake@latest with: - cmakeVersion: 3.27.7 + cmakeVersion: 3.29.3 - name: Install compiler id: install_cc @@ -58,29 +58,43 @@ jobs: with: compiler: ${{ matrix.config.compiler }} - - uses: actions/checkout@v4 - - - name: Install conan - shell: bash - env: - CC: ${{ steps.install_cc.outputs.cc }} - CXX: ${{ steps.install_cc.outputs.cxx }} + - name: Configure conan 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 + pip3 install conan==2.3.0 + + # conan profile update is deprecated (https://github.com/conan-io/conan/issues/13205) + # and they don't want you to use detect because it is unstable + + conan profile detect # Force creation of conan directory structure, will be overwritten + + echo '{% set compiler, version, c_exe = detect_api.detect_default_compiler() %}' > ~/.conan2/profiles/default + echo '[settings]' >> ~/.conan2/profiles/default + echo 'os={{ detect_api.detect_os() }}' >> ~/.conan2/profiles/default + echo 'arch={{ detect_api.detect_arch() }}' >> ~/.conan2/profiles/default + echo 'build_type=Release' >> ~/.conan2/profiles/default + echo 'compiler={{ compiler }}' >> ~/.conan2/profiles/default + echo 'compiler.version={{ detect_api.default_compiler_version(compiler, version) }}' >> ~/.conan2/profiles/default + echo 'compiler.libcxx=libstdc++11' >> ~/.conan2/profiles/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/checkout@v4.1.6 + + - name: Get dependency provider + run: | + sudo apt-get install -y wget + + wget https://github.com/conan-io/cmake-conan/raw/develop2/conan_provider.cmake -O conan_provider.cmake - 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 -G Ninja -B build . env: CC: ${{ steps.install_cc.outputs.cc }} CXX: ${{ steps.install_cc.outputs.cxx }} diff --git a/.github/workflows/publish-conan-branch-package.yml b/.github/workflows/publish-conan-branch-package.yml index 635bc46..354b555 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 463e7d1..0997b1f 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 b50957d..1eadc26 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,5 @@ fabric.properties .idea/ test_package/build/ test_package/CMakeUserPresets.json +/CMakeUserPresets.json +/conan_provider.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b83f1aa..2d65196 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-template-library @@ -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` 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) @@ -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 () - add_library(${PROJECT_NAME} INTERFACE) add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) diff --git a/conanfile.py b/conanfile.py index f151d12..27aa280 100644 --- a/conanfile.py +++ b/conanfile.py @@ -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: @@ -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"): diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 08b1fb2..0ba66b0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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}) @@ -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() From bf4bdf6d36f8996b8ad9155191fc3e38cadbe1c5 Mon Sep 17 00:00:00 2001 From: mcb Date: Fri, 31 May 2024 13:16:15 +0200 Subject: [PATCH 2/7] fix typo --- .github/workflows/code_testing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_testing.yaml b/.github/workflows/code_testing.yaml index 5e320b3..ab1bdf0 100644 --- a/.github/workflows/code_testing.yaml +++ b/.github/workflows/code_testing.yaml @@ -94,7 +94,7 @@ jobs: wget https://github.com/conan-io/cmake-conan/raw/develop2/conan_provider.cmake -O conan_provider.cmake - name: Configure CMake - run: cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DBUILD_EXAMPLES=On --DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G Ninja -B build . + run: cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DBUILD_EXAMPLES=On -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G Ninja -B build . env: CC: ${{ steps.install_cc.outputs.cc }} CXX: ${{ steps.install_cc.outputs.cxx }} From 0c20140e335f1cbde0b372f8afb70109f949b9ce Mon Sep 17 00:00:00 2001 From: mcb Date: Mon, 3 Jun 2024 14:09:54 +0200 Subject: [PATCH 3/7] use actions --- .github/workflows/code_testing.yaml | 42 +++++------------------------ 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/.github/workflows/code_testing.yaml b/.github/workflows/code_testing.yaml index ab1bdf0..7f64200 100644 --- a/.github/workflows/code_testing.yaml +++ b/.github/workflows/code_testing.yaml @@ -31,21 +31,7 @@ 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@feature/conan2_utils - name: Install CMake uses: lukka/get-cmake@latest @@ -59,23 +45,12 @@ jobs: compiler: ${{ matrix.config.compiler }} - name: Configure conan + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan@feature/conan2_utils + with: + conan-version: 2.3.1 + + - name: add conan user run: | - pip3 install conan==2.3.0 - - # conan profile update is deprecated (https://github.com/conan-io/conan/issues/13205) - # and they don't want you to use detect because it is unstable - - conan profile detect # Force creation of conan directory structure, will be overwritten - - echo '{% set compiler, version, c_exe = detect_api.detect_default_compiler() %}' > ~/.conan2/profiles/default - echo '[settings]' >> ~/.conan2/profiles/default - echo 'os={{ detect_api.detect_os() }}' >> ~/.conan2/profiles/default - echo 'arch={{ detect_api.detect_arch() }}' >> ~/.conan2/profiles/default - echo 'build_type=Release' >> ~/.conan2/profiles/default - echo 'compiler={{ compiler }}' >> ~/.conan2/profiles/default - echo 'compiler.version={{ detect_api.default_compiler_version(compiler, version) }}' >> ~/.conan2/profiles/default - echo 'compiler.libcxx=libstdc++11' >> ~/.conan2/profiles/default - conan remote add -f dice-group https://conan.dice-research.org/artifactory/api/conan/tentris - name: Cache conan data @@ -88,10 +63,7 @@ jobs: - uses: actions/checkout@v4.1.6 - name: Get dependency provider - run: | - sudo apt-get install -y wget - - wget https://github.com/conan-io/cmake-conan/raw/develop2/conan_provider.cmake -O conan_provider.cmake + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_provider@feature/conan2_utils - name: Configure CMake run: cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DBUILD_EXAMPLES=On -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G Ninja -B build . From 2d36f29839980e95bf99bac4d31c23e163263e6e Mon Sep 17 00:00:00 2001 From: mcb Date: Mon, 3 Jun 2024 17:09:26 +0200 Subject: [PATCH 4/7] reusable workflow main --- .github/workflows/code_testing.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code_testing.yaml b/.github/workflows/code_testing.yaml index 7f64200..60d71df 100644 --- a/.github/workflows/code_testing.yaml +++ b/.github/workflows/code_testing.yaml @@ -31,7 +31,7 @@ jobs: steps: - name: Add repos for for gcc-13 and clang-16 - uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt@feature/conan2_utils + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt - name: Install CMake uses: lukka/get-cmake@latest @@ -45,7 +45,7 @@ jobs: compiler: ${{ matrix.config.compiler }} - name: Configure conan - uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan@feature/conan2_utils + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan with: conan-version: 2.3.1 @@ -63,7 +63,7 @@ jobs: - uses: actions/checkout@v4.1.6 - name: Get dependency provider - uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_provider@feature/conan2_utils + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_provider - name: Configure CMake run: cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DBUILD_EXAMPLES=On -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G Ninja -B build . From d87aa54ce533fc0001c38a9db46233737a23090f Mon Sep 17 00:00:00 2001 From: mcb Date: Mon, 3 Jun 2024 17:12:16 +0200 Subject: [PATCH 5/7] fix main --- .github/workflows/code_testing.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code_testing.yaml b/.github/workflows/code_testing.yaml index 60d71df..114c369 100644 --- a/.github/workflows/code_testing.yaml +++ b/.github/workflows/code_testing.yaml @@ -31,7 +31,7 @@ jobs: steps: - name: Add repos for for gcc-13 and clang-16 - uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt@main - name: Install CMake uses: lukka/get-cmake@latest @@ -45,7 +45,7 @@ jobs: compiler: ${{ matrix.config.compiler }} - name: Configure conan - uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan + uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan@main with: conan-version: 2.3.1 @@ -63,7 +63,7 @@ jobs: - uses: actions/checkout@v4.1.6 - name: Get dependency provider - uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_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 -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G Ninja -B build . From 4a1faf0708782d460568c4b72d46c08b457aa17a Mon Sep 17 00:00:00 2001 From: mcb Date: Mon, 3 Jun 2024 17:22:32 +0200 Subject: [PATCH 6/7] bump --- .github/workflows/publish-conan-branch-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-conan-branch-package.yml b/.github/workflows/publish-conan-branch-package.yml index 354b555..2e2531a 100644 --- a/.github/workflows/publish-conan-branch-package.yml +++ b/.github/workflows/publish-conan-branch-package.yml @@ -14,7 +14,7 @@ jobs: os: ubuntu-22.04 compiler: clang-14 cmake-version: 3.24.0 - conan-version: 2.3.0 + conan-version: 2.3.1 secrets: CONAN_USER: ${{ secrets.CONAN_USER }} CONAN_PW: ${{ secrets.CONAN_PW }} From 760330b1db84c26b5d11a16c83e80fb269cf2d8b Mon Sep 17 00:00:00 2001 From: mcb Date: Fri, 7 Jun 2024 13:14:14 +0200 Subject: [PATCH 7/7] boost header only --- .github/workflows/code_testing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_testing.yaml b/.github/workflows/code_testing.yaml index 114c369..5e30997 100644 --- a/.github/workflows/code_testing.yaml +++ b/.github/workflows/code_testing.yaml @@ -66,7 +66,7 @@ jobs: 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 -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -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 }}