-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
595 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish Conan branch package | ||
on: [ push ] | ||
|
||
concurrency: | ||
group: publish-conan-branch-package-${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
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 | ||
cmake-version: 3.22.6 | ||
conan-options: -o boost:header_only=True | ||
secrets: | ||
CONAN_USER: ${{ secrets.CONAN_USER }} | ||
CONAN_PW: ${{ secrets.CONAN_PW }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: [ "Publish Conan branch package" ] | ||
branches: [ main ] | ||
types: | ||
- completed | ||
|
||
|
||
concurrency: | ||
group: publish-release-${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
publish-release: | ||
uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/publish-release.yml@main | ||
with: | ||
public_artifactory: false | ||
os: ubuntu-22.04 | ||
compiler: clang-14 | ||
cmake-version: 3.22.6 | ||
conan-version: 1.59 | ||
conan-options: -o boost:header_only=True | ||
secrets: | ||
CONAN_USER: ${{ secrets.CONAN_USER }} | ||
CONAN_PW: ${{ secrets.CONAN_PW }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
cmake-build* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
cmake_minimum_required(VERSION 3.17) | ||
project(metall-ffi VERSION 0.1.0) | ||
|
||
include(cmake/boilerplate_init.cmake) | ||
boilerplate_init() | ||
|
||
OPTION(USE_CONAN "If available, use conan to retrieve dependencies." ON) | ||
if (IS_TOP_LEVEL AND USE_CONAN) | ||
include(cmake/conan_cmake.cmake) | ||
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};boost:header_only=True") | ||
endif () | ||
|
||
find_package(Metall REQUIRED) | ||
find_package(dice-sparse-map REQUIRED) | ||
|
||
add_library(metall-ffi | ||
src/dice/ffi/metall.cpp | ||
) | ||
|
||
add_library(metall-ffi::metall-ffi ALIAS metall-ffi) | ||
|
||
target_include_directories( | ||
metall-ffi | ||
PUBLIC | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>" | ||
) | ||
|
||
target_link_libraries(metall-ffi | ||
PUBLIC | ||
Metall::Metall | ||
dice-sparse-map::dice-sparse-map | ||
) | ||
|
||
set_target_properties(metall-ffi PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} | ||
CXX_STANDARD 20 | ||
CXX_EXTENSIONS OFF | ||
CXX_STANDARD_REQUIRED ON | ||
) | ||
|
||
if (IS_TOP_LEVEL) | ||
include(cmake/install_library.cmake) | ||
install_cpp_library(metall-ffi src) | ||
endif () | ||
|
||
if (BUILD_TESTING AND IS_TOP_LEVEL) | ||
message("Tests are configured to be build.") | ||
include(CTest) | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
macro(boilerplate_init) | ||
## enforce standard compliance | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
## C++ compiler flags | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") | ||
else () | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wold-style-cast -Wcast-qual") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0") | ||
|
||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
# -Wdangling-reference seems to have false positives atm | ||
# We run sanitizers in the CI anyway, so should be fine | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-dangling-reference") | ||
endif () | ||
endif () | ||
|
||
## C++ language visibility configuration | ||
if (NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET AND | ||
NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN) | ||
set(CMAKE_CXX_VISIBILITY_PRESET default) | ||
set(CMAKE_VISIBILITY_INLINES_HIDDEN NO) | ||
endif () | ||
|
||
# conan requires cmake build type to be specified and it is generally a good idea | ||
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CMakeCache.txt) | ||
if (NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) | ||
endif () | ||
endif () | ||
|
||
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" IS_TOP_LEVEL) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
macro(install_packages_via_conan conanfile conan_options) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) | ||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) | ||
|
||
|
||
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") | ||
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") | ||
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake" | ||
"${CMAKE_BINARY_DIR}/conan.cmake" | ||
TLS_VERIFY ON) | ||
endif () | ||
include(${CMAKE_BINARY_DIR}/conan.cmake) | ||
|
||
conan_cmake_autodetect(settings) | ||
conan_check(VERSION 1 DETECT_QUIET) | ||
if (CONAN_CMD) | ||
conan_cmake_install(PATH_OR_REFERENCE ${conanfile} | ||
BUILD missing | ||
SETTINGS ${settings} | ||
OPTIONS "${conan_options}" | ||
ENV_HOST "CC=${CMAKE_C_COMPILER};CXX=${CMAKE_CXX_COMPILER}") | ||
else () | ||
message(WARNING "No conan executable was found. Dependency retrieval via conan is disabled. System dependencies will be used if available.") | ||
endif () | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
function(install_cpp_library TARGET_NAME INCLUDE_PATH) | ||
if (NOT ${ARGC} GREATER_EQUAL 2) | ||
message( | ||
FATAL_ERROR | ||
"you did not specify the target and the include path in the parameter!") | ||
endif () | ||
|
||
target_include_directories( | ||
${TARGET_NAME} PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
install(TARGETS ${TARGET_NAME} ${ARGN} | ||
EXPORT ${TARGET_NAME}-targets | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
|
||
write_basic_package_version_file("${TARGET_NAME}-config-version.cmake" | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY ExactVersion) | ||
|
||
configure_package_config_file( | ||
"${PROJECT_SOURCE_DIR}/cmake/lib-config.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
# here we have two possibilities: either CMAKE_INSTALL_DATAROOTDIR (share) or CMAKE_INSTALL_LIBDIR (lib/lib64) | ||
# we just have to be consistent for one target | ||
|
||
install( | ||
EXPORT ${PROJECT_NAME}-targets | ||
FILE ${PROJECT_NAME}-targets.cmake | ||
NAMESPACE ${PROJECT_NAME}:: | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
|
||
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" | ||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
|
||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PATH}/ | ||
DESTINATION include | ||
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
check_required_components("@PROJECT_NAME@") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
import re | ||
|
||
from conan.tools.cmake import CMake | ||
|
||
from conan import ConanFile | ||
|
||
from conan.tools.files import load, copy, rmdir | ||
|
||
|
||
class Recipe(ConanFile): | ||
name = "metall-ffi" | ||
version = None | ||
|
||
author = "https://github.com/dice-group/metall-ffi" | ||
url = "https://github.com/dice-group/metall-ffi" | ||
description = "FFI for the metall libary" | ||
topics = ("FFI", "persistent memory") | ||
|
||
# Binary configuration | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False], "with_test_deps": [True, False]} | ||
default_options = {"shared": False, "fPIC": True, "with_test_deps": False} | ||
exports = "LICENSE", | ||
exports_sources = "src/*", "CMakeLists.txt", "cmake/*" | ||
|
||
generators = ("CMakeDeps", "CMakeToolchain") | ||
|
||
def requirements(self): | ||
self.requires("metall/0.21") | ||
self.requires("dice-sparse-map/0.2.4") | ||
self.requires("boost/1.81.0") # override to fix dependencies | ||
|
||
if self.options.with_test_deps: | ||
self.requires("doctest/2.4.11") | ||
|
||
|
||
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) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
_cmake = None | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.configure(variables={"USE_CONAN": False}) | ||
|
||
return self._cmake | ||
|
||
def build(self): | ||
self._configure_cmake().build() | ||
|
||
def package(self): | ||
self._configure_cmake().install() | ||
rmdir(self, os.path.join(self.package_folder, "cmake")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
copy(self, "LICENSE", src=self.recipe_folder, dst="licenses") | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["metall-ffi"] |
Oops, something went wrong.