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
16 changes: 15 additions & 1 deletion 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],
"has_codec": [True, False],
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
}
default_options = {
"shared": False,
"fPIC": True,
"stack_protection": True,
"has_codec": False,
}

def export_sources(self):
Expand All @@ -41,15 +44,22 @@ def config_options(self):
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
if self.options.has_codec:
self.options["sqlcipher"].enable_column_metadata = True

def requirements(self):
self.requires("sqlite3/3.45.0")
if self.options.has_codec:
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.has_codec and Version(self.version) < "3.3.1":
raise ConanInvalidConfiguration("Using SQLCipher with this recipe is only available from version 3.3.1")

def layout(self):
cmake_layout(self, src_folder="src")
Expand Down Expand Up @@ -78,11 +88,15 @@ 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("has_codec")
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()

tc = CMakeDeps(self)
tc.generate()

pc = PkgConfigDeps(self)
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
pc.generate()

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