Skip to content

Commit

Permalink
v0.3.1 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigerl authored Feb 9, 2023
2 parents bcbf40e + 689ca28 commit 9bb9b11
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.21)

project(sparql-parser-base VERSION 0.3.0)
project(sparql-parser-base VERSION 0.3.1)

include(cmake/boilerplate_init.cmake)
boilerplate_init()

option(CONAN_CMAKE "If this should use conan cmake to fetch dependencies" On)
if (IS_TOP_LEVEL AND CONAN_CMAKE)
OPTION(USE_CONAN "If available, use conan to retrieve dependencies." ON)
if (PROJECT_IS_TOP_LEVEL AND USE_CONAN)
include(cmake/conan_cmake.cmake)
install_packages_via_conan("${CMAKE_CURRENT_SOURCE_DIR}/conanfile.py" "")
if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
set(CONAN_HYPERTRIE_WITH_TEST_DEPS "True")
else()
set(CONAN_HYPERTRIE_WITH_TEST_DEPS "False")
endif()
set(CONAN_OPTIONS "with_test_deps=${CONAN_HYPERTRIE_WITH_TEST_DEPS}")
install_packages_via_conan("${CMAKE_SOURCE_DIR}/conanfile.py" "${CONAN_OPTIONS}")
endif ()

find_package(antlr4-runtime REQUIRED)
Expand Down Expand Up @@ -106,7 +112,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON)

if (IS_TOP_LEVEL)
if (PROJECT_IS_TOP_LEVEL)
include(cmake/install_library.cmake)
install_cpp_library(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}/src/)
endif ()
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ To use sparql-parser-base, add it to your `conanfile.txt`:

```
[requires]
sparql-parser-base/0.3.0
sparql-parser-base/0.3.1
```

If you want to use SPARQL 1.0 instead, add `sparql-parser-base:sparql_version=1.0` to the `[options]` section of your
conan file.

### With FetchContent

Use
Use

```
include(FetchContent)
FetchContent_Declare(
sparql-parser-base
GIT_REPOSITORY "${CMAKE_CURRENT_SOURCE_DIR}/../"
GIT_TAG 0.3.0
GIT_TAG 0.3.1
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(sparql-parser-base)
Expand Down
2 changes: 0 additions & 2 deletions cmake/boilerplate_init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ macro(boilerplate_init)
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(CMAKE_VISIBILITY_INLINES_HIDDEN NO)
endif ()

string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" IS_TOP_LEVEL)
endmacro()
17 changes: 8 additions & 9 deletions cmake/conan_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ macro(install_packages_via_conan conanfile conan_options)
endif ()

conan_cmake_autodetect(settings)

if (IS_TOP_LEVEL AND BUILD_TESTING)
set(CONAN_HYPERTRIE_WITH_TEST_DEPS "True")
conan_check(VERSION 1 DETECT_QUIET)
if (CONAN_CMD)
conan_cmake_install(PATH_OR_REFERENCE ${conanfile}
BUILD missing
SETTINGS ${settings}
OPTIONS ${conan_options_arg}
GENERATOR "CMakeDeps")
else ()
set(CONAN_HYPERTRIE_WITH_TEST_DEPS "False")
message(WARNING "No conan executable was found. Dependency retrieval via conan is disabled. System dependencies will be used if available.")
endif ()
conan_cmake_install(PATH_OR_REFERENCE ${conanfile}
BUILD missing
SETTINGS ${settings}
OPTIONS ${conan_options_arg}
GENERATOR "CMakeDeps")
endmacro()
24 changes: 15 additions & 9 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import os
import re

from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake
from conan.tools.microsoft import is_msvc
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan.tools.files import load, rmdir
from conan import ConanFile, Version
from conan.errors import ConanInvalidConfiguration


class Recipe(ConanFile):
Expand Down Expand Up @@ -32,7 +35,7 @@ class Recipe(ConanFile):

def set_version(self):
if not hasattr(self, 'version') or self.version is None:
cmake_file = tools.load(os.path.join(self.recipe_folder, "CMakeLists.txt"))
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 = {
Expand All @@ -52,12 +55,12 @@ def validate(self):
# Need to deal with missing libuuid on Arm.
# So far ANTLR delivers macOS binary package.

compiler_version = tools.Version(self.settings.compiler.version)
compiler_version = 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"):
tools.check_min_cppstd(self, "17")
check_min_cppstd(self, "17")

minimum_version = self.compiler_required_cpp17.get(str(self.settings.compiler), False)

Expand All @@ -75,8 +78,11 @@ def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions['CONAN_CMAKE'] = False
self._cmake.definitions['ANTLR4_TAG'] = self.requires['antlr4-cppruntime'].ref.version
self._cmake.configure(
variables=
{"USE_CONAN": False,
"ANTLR4_TAG": self.requires['antlr4-cppruntime'].ref.version}
)
self._cmake.configure()
return self._cmake

Expand All @@ -88,8 +94,8 @@ def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy("LICENSE", src=self.folders.base_source, dst="licenses")
tools.rmdir(os.path.join(self.package_folder, "cmake"))
tools.rmdir(os.path.join(self.package_folder, "share"))
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"]

0 comments on commit 9bb9b11

Please sign in to comment.