diff --git a/.github/workflows/code_testing.yml b/.github/workflows/code_testing.yml index 3a0e9b4..1738512 100644 --- a/.github/workflows/code_testing.yml +++ b/.github/workflows/code_testing.yml @@ -12,8 +12,6 @@ jobs: fail-fast: false matrix: config: - - os: ubuntu-22.04 - compiler: clang-14 - os: ubuntu-22.04 compiler: clang-15 - os: ubuntu-22.04 diff --git a/.github/workflows/publish-conan-branch-package.yml b/.github/workflows/publish-conan-branch-package.yml index 8b43077..593fcc5 100644 --- a/.github/workflows/publish-conan-branch-package.yml +++ b/.github/workflows/publish-conan-branch-package.yml @@ -12,9 +12,9 @@ jobs: with: public_artifactory: true os: ubuntu-22.04 - compiler: clang-14 + compiler: clang-15 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 }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ae225b7..463e7d1 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,7 +19,7 @@ jobs: 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 }} diff --git a/.gitignore b/.gitignore index 1105130..c75364e 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,5 @@ modules.xml # docu folder /docu/ + +test_package/build diff --git a/CMakeLists.txt b/CMakeLists.txt index 1150c99..c47cce7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.22) project( dice-hash @@ -34,13 +34,13 @@ target_include_directories( include(cmake/install_interface_library.cmake) install_interface_library(${PROJECT_NAME} "include") -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) +if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING) include(CTest) enable_testing() add_subdirectory(tests) endif() option(BUILD_EXAMPLES "Build example programs" OFF) -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_EXAMPLES) +if(PROJECT_IS_TOP_LEVEL AND BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/conanfile.py b/conanfile.py index d570e4d..fa161ad 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,4 +1,5 @@ -import re, os +import re +import os from conan import ConanFile from conan.tools.cmake import CMake, cmake_layout @@ -32,16 +33,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 package_id(self): - self.info.header_only() - def package(self): cmake = CMake(self) cmake.configure() cmake.install() + for dir in ("lib", "res", "share"): rmdir(self, os.path.join(self.package_folder, dir)) + copy(self, pattern="LICENSE*", dst="licenses", src=self.folders.source_folder) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_target_name", "dice-hash::dice-hash") + self.cpp_info.set_property("cmake_file_name", "dice-hash") diff --git a/test_package/conanfile.py b/test_package/conanfile.py index c7d1297..355d54e 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -1,7 +1,7 @@ import os from conan import ConanFile -from conan.tools.cmake import CMake -from conan.tools.layout import cmake_layout +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout required_conan_version = ">=1.59" @@ -10,6 +10,9 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps", "CMakeToolchain" + def requirements(self): + self.requires(self.tested_reference_str) + def layout(self): cmake_layout(self) @@ -19,4 +22,6 @@ def build(self): cmake.build() def test(self): - self.run(os.path.join(self.cpp.build.bindirs[0], "example"), run_environment=True) + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun")