From f4e1ab6fc9b4e01771c9fe56923b1e083e4e6451 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Fri, 16 Feb 2024 21:38:05 +0100 Subject: [PATCH 1/7] sqlitecpp: Add has_codec option This enable the database encryption support --- recipes/sqlitecpp/all/conanfile.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index fb8b5040fb9dc..c736d0aa18ab8 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -24,11 +24,13 @@ class SQLiteCppConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "stack_protection": [True, False], + "has_codec": [True, False], } default_options = { "shared": False, "fPIC": True, "stack_protection": True, + "has_codec": False, } def export_sources(self): @@ -41,9 +43,14 @@ 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") def validate(self): if Version(self.version) >= "3.0.0" and self.info.settings.compiler.get_safe("cppstd"): @@ -78,6 +85,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 tc.generate() tc = CMakeDeps(self) From ee03adc65bb4cd619988883ee040a856ce0f85f7 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Sat, 24 Feb 2024 21:54:23 +0100 Subject: [PATCH 2/7] sqlitecpp: Patch cmakelist --- recipes/sqlitecpp/all/conandata.yml | 4 ++ recipes/sqlitecpp/all/conanfile.py | 5 +- .../patches/3.3.1-0001-cmake-sqlite3.patch | 48 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch diff --git a/recipes/sqlitecpp/all/conandata.yml b/recipes/sqlitecpp/all/conandata.yml index a10675f041108..96a483070b493 100644 --- a/recipes/sqlitecpp/all/conandata.yml +++ b/recipes/sqlitecpp/all/conandata.yml @@ -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" diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index c736d0aa18ab8..106ba46de1782 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -48,7 +48,10 @@ def configure(self): def requirements(self): if self.options.has_codec: - self.requires("sqlcipher/[>=4.5.6]") + if Version(self.version) < "3.3.1": + raise ConanInvalidConfiguration("Using SQLCipher with this recipe is only available from version 3.3.1") + else: + self.requires("sqlcipher/[>=4.5.6]") else: self.requires("sqlite3/3.45.0") diff --git a/recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch b/recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch new file mode 100644 index 0000000000000..1794f52f1ef9e --- /dev/null +++ b/recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch @@ -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 + # 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 \"\" 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") From b926f33c214d45c665d0343342fa22377994d6a9 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Fri, 22 Mar 2024 21:56:52 +0100 Subject: [PATCH 3/7] sqlitecpp: use PkgConfigDeps instead of patch, use fixed version of sqlcipher --- recipes/sqlitecpp/all/conandata.yml | 4 -- recipes/sqlitecpp/all/conanfile.py | 13 +++-- .../patches/3.3.1-0001-cmake-sqlite3.patch | 48 ------------------- 3 files changed, 8 insertions(+), 57 deletions(-) delete mode 100644 recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch diff --git a/recipes/sqlitecpp/all/conandata.yml b/recipes/sqlitecpp/all/conandata.yml index 96a483070b493..a10675f041108 100644 --- a/recipes/sqlitecpp/all/conandata.yml +++ b/recipes/sqlitecpp/all/conandata.yml @@ -21,10 +21,6 @@ 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" diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index 106ba46de1782..8dd759e0cc5c3 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -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 @@ -48,10 +49,7 @@ def configure(self): def requirements(self): 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") - else: - self.requires("sqlcipher/[>=4.5.6]") + self.requires("sqlcipher/4.5.6") else: self.requires("sqlite3/3.45.0") @@ -60,6 +58,8 @@ def validate(self): 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") @@ -88,12 +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.has_codec + tc.variables["SQLITE_HAS_CODEC"] = self.options.get_safe("has_codec") tc.generate() tc = CMakeDeps(self) tc.generate() + pc = PkgConfigDeps(self) + pc.generate() + def build(self): self._patch_sources() cmake = CMake(self) diff --git a/recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch b/recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch deleted file mode 100644 index 1794f52f1ef9e..0000000000000 --- a/recipes/sqlitecpp/all/patches/3.3.1-0001-cmake-sqlite3.patch +++ /dev/null @@ -1,48 +0,0 @@ -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 - # 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 \"\" 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") From 604980aa87fccc82a186e3002adf27dd6501e2c7 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Tue, 26 Mar 2024 20:49:06 +0100 Subject: [PATCH 4/7] sqlitecpp: Replace "has_codec" option name by "with_sqlcipher" --- recipes/sqlitecpp/all/conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index 8dd759e0cc5c3..db67637e8e739 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -25,13 +25,13 @@ class SQLiteCppConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "stack_protection": [True, False], - "has_codec": [True, False], + "with_sqlcipher": [True, False], } default_options = { "shared": False, "fPIC": True, "stack_protection": True, - "has_codec": False, + "with_sqlcipher": False, } def export_sources(self): @@ -44,11 +44,11 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - if self.options.has_codec: + if self.options.with_sqlcipher: self.options["sqlcipher"].enable_column_metadata = True def requirements(self): - if self.options.has_codec: + if self.options.with_sqlcipher: self.requires("sqlcipher/4.5.6") else: self.requires("sqlite3/3.45.0") @@ -58,7 +58,7 @@ def validate(self): 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": + if self.options.with_sqlcipher 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): @@ -88,7 +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.get_safe("has_codec") + tc.variables["SQLITE_HAS_CODEC"] = self.options.get_safe("with_sqlcipher", False) tc.generate() tc = CMakeDeps(self) From b101a6e009abd26315fe2833459dbeed8c7a89a8 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Mon, 8 Apr 2024 21:46:46 +0200 Subject: [PATCH 5/7] sqlitecpp: Fix config option and improve the validation --- recipes/sqlitecpp/all/conanfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index db67637e8e739..02feb4ebaeb49 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -40,6 +40,8 @@ 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: @@ -60,7 +62,9 @@ def validate(self): raise ConanInvalidConfiguration("SQLiteCpp can not be built as shared lib on Windows") if self.options.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") From 25d8b553cf86c3e5f7ed9021af5111444d3dcf47 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Wed, 10 Apr 2024 11:18:21 +0200 Subject: [PATCH 6/7] sqlitecpp: fix option access --- recipes/sqlitecpp/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index 02feb4ebaeb49..4f44d964ae41b 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -46,11 +46,11 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - if self.options.with_sqlcipher: + if self.options.get_safe("with_sqlcipher"): self.options["sqlcipher"].enable_column_metadata = True def requirements(self): - if self.options.with_sqlcipher: + if self.options.get_safe("with_sqlcipher"): self.requires("sqlcipher/4.5.6") else: self.requires("sqlite3/3.45.0") @@ -60,7 +60,7 @@ def validate(self): 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.with_sqlcipher and Version(self.version) < "3.3.1": + 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'") From 9c7739fcb215337120706d670627fd87e283dda9 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Fri, 17 May 2024 17:30:53 +0200 Subject: [PATCH 7/7] sqlitecpp: PkgConfigDeps only used when using with_sqlcipher option --- recipes/sqlitecpp/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/sqlitecpp/all/conanfile.py b/recipes/sqlitecpp/all/conanfile.py index 4f44d964ae41b..cb30399825d72 100644 --- a/recipes/sqlitecpp/all/conanfile.py +++ b/recipes/sqlitecpp/all/conanfile.py @@ -98,8 +98,9 @@ def generate(self): tc = CMakeDeps(self) tc.generate() - pc = PkgConfigDeps(self) - pc.generate() + if self.options.get_safe("with_sqlcipher"): + pc = PkgConfigDeps(self) + pc.generate() def build(self): self._patch_sources()