From dc7fa1758fc7b94fcfc3d25449ca19172dc265bd Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:29:43 +0100 Subject: [PATCH] Feature: conan2 (#25) --- .../publish-conan-branch-package.yml | 6 +-- .github/workflows/publish-release.yml | 6 +-- CMakeLists.txt | 2 +- README.md | 2 +- conanfile.py | 37 +++++++------------ 5 files changed, 21 insertions(+), 32 deletions(-) diff --git a/.github/workflows/publish-conan-branch-package.yml b/.github/workflows/publish-conan-branch-package.yml index 8b43077..7b40fd6 100644 --- a/.github/workflows/publish-conan-branch-package.yml +++ b/.github/workflows/publish-conan-branch-package.yml @@ -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 + 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..6e089ae 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -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 + 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/CMakeLists.txt b/CMakeLists.txt index 25ebb3b..f46d65a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ set(SPARQL_VERSION "1.1" CACHE STRING "SPARQL version" FORCE) mark_as_advanced(SPARQL_VERSION) -set(ANTLR4_TAG "4.10.1" CACHE STRING "Antlr4 version" FORCE) +set(ANTLR4_TAG "4.13.1" CACHE STRING "Antlr4 version" FORCE) mark_as_advanced(ANTLR4_TAG) set(ANTLR4_JAR_LOCATION "${PROJECT_BINARY_DIR}/antlr-${ANTLR4_TAG}-complete.jar") if (NOT EXISTS "${ANTLR4_JAR_LOCATION}") diff --git a/README.md b/README.md index 919990f..b686bc1 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,6 @@ make -j sparql-parser-base `-DSPARQL_VERSION="1.0"/"1.1" [default: "1.1"]`: SPARQL version of the generated parser. -`-DANTLR4_TAG=... [default: "4.10.1"]`: ANTLR4 version to be used. +`-DANTLR4_TAG=... [default: "4.13.1"]`: ANTLR4 version to be used. `-DCONAN_CMAKE=ON/OFF [default: ON]`: If available, use Conan to retrieve dependencies. \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index b3e342f..49a853b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,12 +1,12 @@ import os import re +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake +from conan.tools.files import load, rmdir, copy from conan.tools.microsoft import is_msvc -from conan.tools.files import load, rmdir -from conan import ConanFile, Version -from conan.errors import ConanInvalidConfiguration class Recipe(ConanFile): @@ -28,23 +28,18 @@ class Recipe(ConanFile): "fPIC": True, 'sparql_version': '1.1', } - requires = "antlr4-cppruntime/4.10.1", settings = "os", "compiler", "build_type", "arch" generators = ("CMakeDeps", "CMakeToolchain") exports_sources = "CMakeLists.txt", "antlr4cmake/antlr4-generator.cmake.in", "cmake/*", "SparqlLexer_1.1.g4", "SparqlParser_1.0.g4", "SparqlParser_1.1.g4" + def requirements(self): + self.requires("antlr4-cppruntime/4.13.1", transitive_headers=True) + def set_version(self): if not hasattr(self, 'version') or self.version is None: cmake_file = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt")) self.version = re.search(r"project\([^)]*VERSION\s+(\d+\.\d+.\d+)[^)]*\)", cmake_file).group(1) - compiler_required_cpp17 = { - "Visual Studio": "16", - "gcc": "7", - "clang": "5", - "apple-clang": "9.1" - } - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -55,23 +50,13 @@ def validate(self): # Need to deal with missing libuuid on Arm. # So far ANTLR delivers macOS binary package. - compiler_version = Version(self.settings.compiler.version) + compiler_version = self.settings.compiler.version if is_msvc(self) and compiler_version < "16": raise ConanInvalidConfiguration("library claims C2668 'Ambiguous call to overloaded function'") if self.settings.get_safe("compiler.cppstd"): check_min_cppstd(self, "17") - minimum_version = self.compiler_required_cpp17.get(str(self.settings.compiler), False) - - if minimum_version: - if compiler_version < minimum_version: - raise ConanInvalidConfiguration( - "{} requires C++17, which your compiler does not support.".format(self.name)) - else: - self.output.warn( - "{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) - _cmake = None def _configure_cmake(self): @@ -81,7 +66,7 @@ def _configure_cmake(self): self._cmake.configure( variables= {"USE_CONAN": False, - "ANTLR4_TAG": self.requires['antlr4-cppruntime'].ref.version} + "ANTLR4_TAG": self.dependencies['antlr4-cppruntime'].ref.version} ) self._cmake.configure() return self._cmake @@ -93,9 +78,13 @@ def build(self): def package(self): cmake = self._configure_cmake() cmake.install() - self.copy("LICENSE", src=self.folders.base_source, dst="licenses") + copy(self, "LICENSE", src=self.folders.base_source, dst="licenses") rmdir(self, os.path.join(self.package_folder, "cmake")) rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.libs = ["sparql-parser-base"] + + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_target_name", "sparql-parser-base::sparql-parser-base") + self.cpp_info.set_property("cmake_file_name", "sparql-parser-base")