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
4 changes: 4 additions & 0 deletions recipes/sqlitecpp/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ sources:
url: "https://github.com/SRombauts/SQLiteCpp/archive/2.4.0.tar.gz"
sha256: "16bf963619786652a60533bcdc71a0412cad1ce132cd09ce43344af6ed7463d9"
patches:
"3.3.1":
- patch_file: "patches/3.3.1-0001-cmake-sqlite3.patch"
patch_description: "Fix Sqlite3 CMake target"
patch_type: "conan"
"2.5.0":
- patch_file: "patches/2.5.0-0001-cmake-sqlite3.patch"
patch_description: "Fix Sqlite3 CMake target"
Expand Down
13 changes: 12 additions & 1 deletion recipes/sqlitecpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,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,9 +43,17 @@ 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:
if Version(self.version) < "3.3.1":
raise ConanInvalidConfiguration("Using SQLCipher with this recipe is only available from version 3.3.1")
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
else:
self.requires("sqlcipher/[>=4.5.6]")
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
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"):
Expand Down Expand Up @@ -78,6 +88,7 @@ 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.has_codec
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()

tc = CMakeDeps(self)
Expand Down
48 changes: 48 additions & 0 deletions recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch
Alex-PLACET marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 898f71f772871223a0801b3b05613b2c6f386277..21af5b994de440d2e4da80d4165ee8410b18cef4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -285,40 +285,9 @@ else (SQLITECPP_INTERNAL_SQLITE)
# When using the SQLite codec, we need to link against the sqlcipher lib & include <sqlcipher/sqlite3.h>
# So this gets the lib & header, and links/includes everything
if(SQLITE_HAS_CODEC)
- # Make PkgConfig optional since Windows doesn't usually have it installed.
- find_package(PkgConfig QUIET)
- if(PKG_CONFIG_FOUND)
- # IMPORTED_TARGET was added in 3.6.3
- if(CMAKE_VERSION VERSION_LESS 3.6.3)
- pkg_check_modules(sqlcipher REQUIRED sqlcipher)
- # Only used in Database.cpp so PRIVATE to hide from end-user
- # Since we can't use IMPORTED_TARGET on this older Cmake version, manually link libs & includes
- target_link_libraries(SQLiteCpp PRIVATE ${sqlcipher_LIBRARIES})
- target_include_directories(SQLiteCpp PRIVATE ${sqlcipher_INCLUDE_DIRS})
- else()
- pkg_check_modules(sqlcipher REQUIRED IMPORTED_TARGET sqlcipher)
- # Only used in Database.cpp so PRIVATE to hide from end-user
- target_link_libraries(SQLiteCpp PRIVATE PkgConfig::sqlcipher)
- endif()
- else()
- # Since we aren't using pkgconf here, find it manually
- find_library(sqlcipher_LIBRARY "sqlcipher")
- find_path(sqlcipher_INCLUDE_DIR "sqlcipher/sqlite3.h"
- PATH_SUFFIXES
- "include"
- "includes"
- )
- # Hides it from the GUI
- mark_as_advanced(sqlcipher_LIBRARY sqlcipher_INCLUDE_DIR)
- if(NOT sqlcipher_INCLUDE_DIR)
- message(FATAL_ERROR "${PROJECT_NAME} requires the \"<sqlcipher/sqlite3.h>\" header to use the codec functionality but it wasn't found.")
- elseif(NOT sqlcipher_LIBRARY)
- message(FATAL_ERROR "${PROJECT_NAME} requires the sqlcipher library to use the codec functionality but it wasn't found.")
- endif()
- # Only used in Database.cpp so PRIVATE to hide from end-user
- target_include_directories(SQLiteCpp PRIVATE "${sqlcipher_INCLUDE_DIR}/sqlcipher")
- target_link_libraries(SQLiteCpp PRIVATE ${sqlcipher_LIBRARY})
- endif()
+ find_package(sqlcipher REQUIRED)
+ message(STATUS "Link to sqlcipher library")
+ target_link_libraries(SQLiteCpp PRIVATE sqlcipher::sqlcipher)
else()
find_package (SQLite3 REQUIRED)
message(STATUS "Link to sqlite3 system library")
Loading