Skip to content

Commit

Permalink
(#8676) Add qdbm/1.8.78
Browse files Browse the repository at this point in the history
* Add qdbm/1.8.78

* Actually use pthread to build when requested

* Unroll loop in CML for `find_package`

* Fix topics

* Nuke CMake info not provided upstream

* Add `KEEP_RPATHS` to the CMakeLists.txt files

* Use target from CMake config with Conan defaults

Co-authored-by: friendlyanon <friendlyanon@users.noreply.github.com>
  • Loading branch information
friendlyanon and friendlyanon authored Feb 2, 2022
1 parent 65282d2 commit a59a124
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 0 deletions.
83 changes: 83 additions & 0 deletions recipes/qdbm/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.1)

project(qdbm_wrapper VERSION "${CONAN_qdbm_VERSION}" LANGUAGES C)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS KEEP_RPATHS)

# ---- Dependencies ----

option(THREADS_PREFER_PTHREAD_FLAG "" ON)

macro(find_package_if condition name)
option("${condition}" "Enable ${condition}" OFF)
if(${condition})
find_package("${name}" REQUIRED ${ARGN})
link_libraries("${name}::${name}")
add_definitions("-D${condition}")
endif()
endmacro()

find_package_if(MYICONV Iconv CONFIG)
find_package_if(MYZLIB ZLIB CONFIG)
find_package_if(MYPTHREAD Threads)

# ---- Library ----

add_library(
qdbm
depot.c
curia.c
relic.c
hovel.c
cabin.c
villa.c
vista.c
odeum.c
myconf.c
)

if(WIN32)
target_sources(qdbm PRIVATE qdbm.def)
endif()

# Too noisy
if(MSVC)
target_compile_definitions(
qdbm PRIVATE
_CRT_SECURE_NO_WARNINGS
_CRT_SECURE_NO_DEPRECATE
)
target_compile_options(qdbm PRIVATE /wd4267 /wd4996 /wd4244)
endif()

target_include_directories(qdbm PRIVATE "${PROJECT_SOURCE_DIR}")

set_target_properties(
qdbm PROPERTIES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
)

# ---- Install ----

include(GNUInstallDirs)

install(
TARGETS qdbm
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

install(
FILES
cabin.h
curia.h
depot.h
odeum.h
relic.h
villa.h
vista.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdbm"
)
4 changes: 4 additions & 0 deletions recipes/qdbm/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.8.78":
sha256: "b466fe730d751e4bfc5900d1f37b0fb955f2826ac456e70012785e012cdcb73e"
url: http://fallabs.com/qdbm/qdbm-1.8.78.tar.gz
79 changes: 79 additions & 0 deletions recipes/qdbm/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import functools
import os

from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.43.0"


class QDBMConan(ConanFile):
name = "qdbm"
description = "QDBM is a library of routines for managing a database."
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://fallabs.com/qdbm/"
topics = ("qdbm", "database", "db")
license = "LGPL-2.1-or-later"
settings = ("os", "arch", "compiler", "build_type")
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_pthread": [True, False],
"with_iconv": [True, False],
"with_zlib": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_pthread": True,
"with_iconv": True,
"with_zlib": True,
}
generators = ("cmake", "cmake_find_package_multi")
exports_sources = ("CMakeLists.txt",)
no_copy_source = True

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
del self.options.with_pthread

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def requirements(self):
if self.options.with_iconv:
self.requires("libiconv/1.16")
if self.options.with_zlib:
self.requires("zlib/1.2.11")

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["CONAN_qdbm_VERSION"] = self.version
cmake.definitions["MYICONV"] = self.options.with_iconv
cmake.definitions["MYZLIB"] = self.options.with_zlib
cmake.definitions["MYPTHREAD"] = self.options\
.get_safe("with_pthread", False)
cmake.configure()
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("COPYING", "licenses")
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.libs = ["qdbm"]
if self.options.get_safe("with_pthread"):
self.cpp_info.system_libs.append("pthread")
10 changes: 10 additions & 0 deletions recipes/qdbm/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS KEEP_RPATHS)

find_package(qdbm REQUIRED CONFIG)

add_executable(test_package test_package.c)
target_link_libraries(test_package PRIVATE qdbm::qdbm)
18 changes: 18 additions & 0 deletions recipes/qdbm/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import ConanFile, CMake, tools


class TestPackageConan(ConanFile):
settings = ("os", "compiler", "build_type", "arch")
generators = ("cmake", "cmake_find_package_multi")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
12 changes: 12 additions & 0 deletions recipes/qdbm/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <qdbm/cabin.h>
#include <stddef.h>

int main(int argc, char const* argv[])
{
(void)argc;
(void)argv;

cbfree(NULL);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/qdbm/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.8.78":
folder: all

0 comments on commit a59a124

Please sign in to comment.