Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlitecpp: Add has_codec option #22795

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
23 changes: 21 additions & 2 deletions recipes/sqlitecpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.errors import ConanInvalidConfiguration
from conan.tools.gnu import PkgConfigDeps
import os
import textwrap

Expand All @@ -24,11 +25,13 @@ class SQLiteCppConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"stack_protection": [True, False],
"with_sqlcipher": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"stack_protection": True,
"with_sqlcipher": False,
}

def export_sources(self):
Expand All @@ -37,20 +40,31 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) < "3.3.1":
del self.options.with_sqlcipher

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
if self.options.get_safe("with_sqlcipher"):
self.options["sqlcipher"].enable_column_metadata = True

def requirements(self):
self.requires("sqlite3/3.45.0")
if self.options.get_safe("with_sqlcipher"):
self.requires("sqlcipher/4.5.6")
else:
self.requires("sqlite3/3.45.0")
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

def validate(self):
if Version(self.version) >= "3.0.0" and self.info.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)
if self.info.settings.os == "Windows" and self.info.options.shared:
raise ConanInvalidConfiguration("SQLiteCpp can not be built as shared lib on Windows")

if self.options.get_safe("with_sqlcipher")and Version(self.version) < "3.3.1":
raise ConanInvalidConfiguration("Using SQLCipher with this recipe is only available from version 3.3.1")
if self.options.get_safe("with_sqlcipher") and not self.dependencies["sqlcipher"].options.enable_column_metadata:
raise ConanInvalidConfiguration(f"{self.ref} option with_sqlcipher=True requires 'sqlcipher/*:enable_column_metadata=True'")

def layout(self):
cmake_layout(self, src_folder="src")

Expand Down Expand Up @@ -78,11 +92,16 @@ def generate(self):
tc.variables["SQLITECPP_BUILD_EXAMPLES"] = False
tc.variables["SQLITECPP_BUILD_TESTS"] = False
tc.variables["SQLITECPP_USE_STACK_PROTECTION"] = self.options.stack_protection
tc.variables["SQLITE_HAS_CODEC"] = self.options.get_safe("with_sqlcipher", False)
tc.generate()

tc = CMakeDeps(self)
tc.generate()

if self.options.get_safe("with_sqlcipher"):
pc = PkgConfigDeps(self)
pc.generate()

def build(self):
self._patch_sources()
cmake = CMake(self)
Expand Down
Loading