diff --git a/recipes/sqlpp11-connector-sqlite3/all/CMakeLists.txt b/recipes/sqlpp11-connector-sqlite3/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/sqlpp11-connector-sqlite3/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/sqlpp11-connector-sqlite3/all/conandata.yml b/recipes/sqlpp11-connector-sqlite3/all/conandata.yml index 6f7198fb9a268..117f18fff5e8c 100644 --- a/recipes/sqlpp11-connector-sqlite3/all/conandata.yml +++ b/recipes/sqlpp11-connector-sqlite3/all/conandata.yml @@ -1,14 +1,23 @@ sources: - "0.29": - url: "https://github.com/rbock/sqlpp11-connector-sqlite3/archive/0.29.tar.gz" - sha256: "2904ddd578adb0e122a70f73a80bae4843434d685b7a23ae3ab43471c35efc4f" + "0.31": + url: "https://github.com/rbock/sqlpp11-connector-sqlite3/archive/0.31.tar.gz" + sha256: "b6be3b9b6c4a64ed9cf75d5434683d018c5fd517b2a428596e9dce97a9e030bd" "0.30": url: "https://github.com/rbock/sqlpp11-connector-sqlite3/archive/0.30.tar.gz" sha256: "e39f420312d311f3eaa162e201883b4594c34e04739b39a4563f84be920e654f" -patches: "0.29": - - patch_file: "patches/cmake-dependencies.patch" - base_path: "source_subfolder" + url: "https://github.com/rbock/sqlpp11-connector-sqlite3/archive/0.29.tar.gz" + sha256: "2904ddd578adb0e122a70f73a80bae4843434d685b7a23ae3ab43471c35efc4f" +patches: + "0.31": + - patch_file: "patches/0.31-0001-cmake-dependencies.patch" + patch_description: "use cci packages" + patch_type: "conan" "0.30": - - patch_file: "patches/cmake-dependencies.patch" - base_path: "source_subfolder" + - patch_file: "patches/0.30-0001-cmake-dependencies.patch" + patch_description: "use cci packages" + patch_type: "conan" + "0.29": + - patch_file: "patches/0.29-0001-cmake-dependencies.patch" + patch_description: "use cci packages" + patch_type: "conan" diff --git a/recipes/sqlpp11-connector-sqlite3/all/conanfile.py b/recipes/sqlpp11-connector-sqlite3/all/conanfile.py index 964d73c54cc6d..75639f1b3dd07 100644 --- a/recipes/sqlpp11-connector-sqlite3/all/conanfile.py +++ b/recipes/sqlpp11-connector-sqlite3/all/conanfile.py @@ -1,30 +1,34 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os +required_conan_version = ">=1.53.0" class sqlpp11Conan(ConanFile): name = "sqlpp11-connector-sqlite3" description = "A C++ wrapper for sqlite3 meant to be used in combination with sqlpp11." - topics = ("conan", "sqlpp11-connector-sqlite3", "sqlite3", "sqlpp11", "sql", "database") - settings = "os", "compiler", "build_type", "arch" + license = "BSD-2-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/rbock/sqlpp11-connector-sqlite3" - license = "BSD-2-Clause" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - options = {"shared": [True, False], "fPIC": [True, False], "with_sqlcipher": [True, False]} - default_options = {"shared": False, "fPIC": True, "with_sqlcipher": False} + topics = ("conan", "sqlpp11-connector-sqlite3", "sqlite3", "sqlpp11", "sql", "database") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_sqlcipher": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_sqlcipher": False, + } short_paths = True - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -32,46 +36,54 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("sqlpp11/0.59") + self.requires("sqlpp11/0.60") + if Version(self.version) < "0.31.0": + self.requires("date/3.0.1") if self.options.with_sqlcipher: - self.requires("sqlcipher/4.4.0") + self.requires("sqlcipher/4.5.1") else: - self.requires("sqlite3/3.32.3") + self.requires("sqlite3/3.40.1") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "0.31.0": + tc.variables["ENABLE_TESTS"] = False + else: + tc.variables["ENABLE_TESTING"] = False + tc.variables["SQLCIPHER"] = self.options.with_sqlcipher + tc.variables["SQLPP11_INCLUDE_DIR"] = self.deps_cpp_info["sqlpp11"].include_paths[0].replace("\\", "/") + tc.generate() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_TESTS"] = False - self._cmake.definitions["SQLCIPHER"] = self.options.with_sqlcipher - self._cmake.definitions["SQLPP11_INCLUDE_DIR"] = self.deps_cpp_info["sqlpp11"].include_paths[0] - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["sqlpp11-connector-sqlite3"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] if self.options.with_sqlcipher: self.cpp_info.defines = ["SQLPP_USE_SQLCIPHER"] diff --git a/recipes/sqlpp11-connector-sqlite3/all/patches/0.29-0001-cmake-dependencies.patch b/recipes/sqlpp11-connector-sqlite3/all/patches/0.29-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..061604c4ca3fa --- /dev/null +++ b/recipes/sqlpp11-connector-sqlite3/all/patches/0.29-0001-cmake-dependencies.patch @@ -0,0 +1,90 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1fe77de..5db38f6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -36,21 +36,22 @@ if (NOT DEFINED SQLPP11_DYNAMIC_LOADING) + set(SQLPP11_DYNAMIC_LOADING Off) + endif() + +-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") ++# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(SQLCIPHER ) +- find_package(SQLCipher REQUIRED) +- set (SQLITE3_LIBRARIES "${SQLCIPHER_LIBRARIES}" ) +- set (SQLITE3_INCLUDE_DIRS "${SQLCIPHER_INCLUDE_DIRS}" ) +- set (SQLITE3_LIBRARY "${SQLCIPHER_LIBRARY}") ++ find_package(sqlcipher REQUIRED) ++ set (SQLite3_LIBRARIES "${sqlcipher_LIBRARIES}") ++ set (SQLite3_INCLUDE_DIRS "${sqlcipher_INCLUDE_DIRS}") ++ set (SQLite3_LIBRARY "${sqlcipher_LIBRARY}") + else() +- find_package(Sqlite3 REQUIRED) ++ find_package(SQLite3 REQUIRED) + endif() + +-find_package(HinnantDate REQUIRED) ++find_package(date REQUIRED) + + message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})") + +-set(SQLPP11_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../sqlpp11/include" CACHE FILEPATH "Path to sqlpp11 includes") ++find_package(Sqlpp11 REQUIRED) ++set(SQLPP11_INCLUDE_DIR "${Sqlpp11_INCLUDE_DIR}" CACHE FILEPATH "Path to sqlpp11 includes") + + if(NOT EXISTS ${SQLPP11_INCLUDE_DIR}/sqlpp11/sqlpp11.h) + message(SEND_ERROR "Can't find file sqlpp11/sqlpp11.h") +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 3141a6d..11ce73c 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -16,11 +16,11 @@ if (SQLPP_DYNAMIC_LOADING) + detail/dynamic_libsqlite3.cpp + ) + +- get_filename_component(SQLITE3_LIB_FILE ${SQLITE3_LIBRARY} NAME) ++ get_filename_component(SQLITE3_LIB_FILE ${SQLite3_LIBRARY} NAME) + + if (WIN32) + # the import library (.lib) needs to be replaced by .dll + get_filename_component(SQLITE3_LIB_FILE ${SQLITE3_LIB_FILE} NAME_WE) + string(APPEND SQLITE3_LIB_FILE ".dll") + endif() + +@@ -34,8 +34,8 @@ if (SQLPP_DYNAMIC_LOADING) + target_include_directories(sqlpp11-connector-sqlite3-dynamic + PUBLIC + ${SQLPP11_INCLUDE_DIR} +- ${HinnantDate_INCLUDE_DIR} +- ${SQLITE3_INCLUDE_DIRS} ++ ${date_INCLUDE_DIR} ++ ${SQLite3_INCLUDE_DIRS} + $ + $) + endif() +@@ -43,9 +43,6 @@ endif() + # TODO export Targets for HinnantDate and Sqlite3 as well + target_include_directories(sqlpp11-connector-sqlite3 + PUBLIC +- ${SQLPP11_INCLUDE_DIR} +- ${HinnantDate_INCLUDE_DIR} +- ${SQLITE3_INCLUDE_DIRS} + $ + $) + +@@ -58,14 +55,13 @@ endif() + + if (SQLCIPHER) + target_compile_definitions(sqlpp11-connector-sqlite3 PUBLIC SQLPP_USE_SQLCIPHER) +- target_link_libraries(sqlpp11-connector-sqlite3 SQLCipher::SQLCipher) + if (SQLPP_DYNAMIC_LOADING) + target_compile_definitions(sqlpp11-connector-sqlite3-dynamic PUBLIC SQLPP_USE_SQLCIPHER) +- target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${SQLCIPHER_INCLUDE_DIRS}) ++ target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${sqlcipher_INCLUDE_DIRS}) + endif() + else() +- target_link_libraries(sqlpp11-connector-sqlite3 ${SQLITE3_LIBRARIES}) + endif() ++target_link_libraries(sqlpp11-connector-sqlite3 ${SQLite3_LIBRARIES} date::date sqlpp11::sqlpp11) + + install(TARGETS sqlpp11-connector-sqlite3 + ARCHIVE DESTINATION lib diff --git a/recipes/sqlpp11-connector-sqlite3/all/patches/0.30-0001-cmake-dependencies.patch b/recipes/sqlpp11-connector-sqlite3/all/patches/0.30-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..f1d4572089cd1 --- /dev/null +++ b/recipes/sqlpp11-connector-sqlite3/all/patches/0.30-0001-cmake-dependencies.patch @@ -0,0 +1,86 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e3008a4..2e72a74 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -39,21 +39,21 @@ if (NOT DEFINED SQLPP11_DYNAMIC_LOADING) + set(SQLPP11_DYNAMIC_LOADING Off) + endif() + +-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(SQLCIPHER ) +- find_package(SQLCipher REQUIRED) +- set (SQLITE3_LIBRARIES "${SQLCIPHER_LIBRARIES}" ) +- set (SQLITE3_INCLUDE_DIRS "${SQLCIPHER_INCLUDE_DIRS}" ) +- set (SQLITE3_LIBRARY "${SQLCIPHER_LIBRARY}") ++ find_package(sqlcipher REQUIRED) ++ set (SQLite3_LIBRARIES "${sqlcipher_LIBRARIES}") ++ set (SQLite3_INCLUDE_DIRS "${sqlcipher_INCLUDE_DIRS}") ++ set (SQLite3_LIBRARY "${sqlcipher_LIBRARY}") + else() +- find_package(Sqlite3 REQUIRED) ++ find_package(SQLite3 REQUIRED) + endif() + +-find_package(HinnantDate REQUIRED) ++find_package(date REQUIRED) + + message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})") + +-set(SQLPP11_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../sqlpp11/include" CACHE FILEPATH "Path to sqlpp11 includes") ++find_package(Sqlpp11 REQUIRED) ++set(SQLPP11_INCLUDE_DIR "${Sqlpp11_INCLUDE_DIR}" CACHE FILEPATH "Path to sqlpp11 includes") + + if(NOT EXISTS ${SQLPP11_INCLUDE_DIR}/sqlpp11/sqlpp11.h) + message(SEND_ERROR "Can't find file sqlpp11/sqlpp11.h") +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 3141a6d..d005579 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -16,7 +16,7 @@ if (SQLPP_DYNAMIC_LOADING) + detail/dynamic_libsqlite3.cpp + ) + +- get_filename_component(SQLITE3_LIB_FILE ${SQLITE3_LIBRARY} NAME) ++ get_filename_component(SQLITE3_LIB_FILE ${SQLite3_LIBRARY} NAME) + + if (WIN32) + # the import library (.lib) needs to be replaced by .dll +@@ -34,8 +34,8 @@ if (SQLPP_DYNAMIC_LOADING) + target_include_directories(sqlpp11-connector-sqlite3-dynamic + PUBLIC + ${SQLPP11_INCLUDE_DIR} +- ${HinnantDate_INCLUDE_DIR} +- ${SQLITE3_INCLUDE_DIRS} ++ ${date_INCLUDE_DIR} ++ ${SQLite3_INCLUDE_DIRS} + $ + $) + endif() +@@ -44,8 +44,8 @@ endif() + target_include_directories(sqlpp11-connector-sqlite3 + PUBLIC + ${SQLPP11_INCLUDE_DIR} +- ${HinnantDate_INCLUDE_DIR} +- ${SQLITE3_INCLUDE_DIRS} ++ ${date_INCLUDE_DIR} ++ ${SQLite3_INCLUDE_DIRS} + $ + $) + +@@ -58,14 +58,13 @@ endif() + + if (SQLCIPHER) + target_compile_definitions(sqlpp11-connector-sqlite3 PUBLIC SQLPP_USE_SQLCIPHER) +- target_link_libraries(sqlpp11-connector-sqlite3 SQLCipher::SQLCipher) + if (SQLPP_DYNAMIC_LOADING) + target_compile_definitions(sqlpp11-connector-sqlite3-dynamic PUBLIC SQLPP_USE_SQLCIPHER) +- target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${SQLCIPHER_INCLUDE_DIRS}) ++ target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${sqlcipher_INCLUDE_DIRS}) + endif() + else() +- target_link_libraries(sqlpp11-connector-sqlite3 ${SQLITE3_LIBRARIES}) + endif() ++target_link_libraries(sqlpp11-connector-sqlite3 ${SQLite3_LIBRARIES} date::date sqlpp11::sqlpp11) + + install(TARGETS sqlpp11-connector-sqlite3 + ARCHIVE DESTINATION lib diff --git a/recipes/sqlpp11-connector-sqlite3/all/patches/0.31-0001-cmake-dependencies.patch b/recipes/sqlpp11-connector-sqlite3/all/patches/0.31-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..755342bcc5ead --- /dev/null +++ b/recipes/sqlpp11-connector-sqlite3/all/patches/0.31-0001-cmake-dependencies.patch @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 521927b..18a2615 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -40,15 +40,14 @@ if (NOT DEFINED SQLPP11_DYNAMIC_LOADING) + set(SQLPP11_DYNAMIC_LOADING Off) + endif() + +-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(SQLCIPHER ) +- find_package(SQLCipher REQUIRED) +- set (SQLite3_LIBRARY "${SQLCIPHER_LIBRARY}") # TO DO: Needed because of l. 19 in src/CmakeLists.txt? ++ find_package(sqlcipher REQUIRED) ++ set (SQLite3_LIBRARY "${sqlcipher_LIBRARY}") # TO DO: Needed because of l. 19 in src/CmakeLists.txt? + else() + find_package(SQLite3 REQUIRED) + endif() + +-add_subdirectory(dependencies) ++find_package(Sqlpp11 REQUIRED) + + message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})") + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 22cc106..40f3381 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -74,10 +74,10 @@ target_include_directories(sqlpp11-connector-sqlite3 PUBLIC + + if (SQLCIPHER) + target_compile_definitions(sqlpp11-connector-sqlite3 PUBLIC SQLPP_USE_SQLCIPHER) +- target_link_libraries(sqlpp11-connector-sqlite3 PUBLIC SQLCipher::SQLCipher) ++ target_link_libraries(sqlpp11-connector-sqlite3 PUBLIC sqlcipher::sqlcipher) + if (SQLPP_DYNAMIC_LOADING) + target_compile_definitions(sqlpp11-connector-sqlite3-dynamic PUBLIC SQLPP_USE_SQLCIPHER) +- target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${SQLCIPHER_INCLUDE_DIRS}) ++ target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${sqlcipher_INCLUDE_DIRS}) + endif() + else() + target_link_libraries(sqlpp11-connector-sqlite3 PUBLIC SQLite::SQLite3) diff --git a/recipes/sqlpp11-connector-sqlite3/all/patches/cmake-dependencies.patch b/recipes/sqlpp11-connector-sqlite3/all/patches/cmake-dependencies.patch deleted file mode 100644 index e9244768a488a..0000000000000 --- a/recipes/sqlpp11-connector-sqlite3/all/patches/cmake-dependencies.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -43,9 +43,6 @@ endif() - # TODO export Targets for HinnantDate and Sqlite3 as well - target_include_directories(sqlpp11-connector-sqlite3 - PUBLIC -- ${SQLPP11_INCLUDE_DIR} -- ${HinnantDate_INCLUDE_DIR} -- ${SQLITE3_INCLUDE_DIRS} - $ - $) - -@@ -58,14 +55,13 @@ endif() - - if (SQLCIPHER) - target_compile_definitions(sqlpp11-connector-sqlite3 PUBLIC SQLPP_USE_SQLCIPHER) -- target_link_libraries(sqlpp11-connector-sqlite3 SQLCipher::SQLCipher) - if (SQLPP_DYNAMIC_LOADING) - target_compile_definitions(sqlpp11-connector-sqlite3-dynamic PUBLIC SQLPP_USE_SQLCIPHER) - target_include_directories(sqlpp11-connector-sqlite3-dynamic PUBLIC ${SQLCIPHER_INCLUDE_DIRS}) - endif() - else() -- target_link_libraries(sqlpp11-connector-sqlite3 ${SQLITE3_LIBRARIES}) - endif() -+target_link_libraries(sqlpp11-connector-sqlite3 ${CONAN_LIBS}) - - install(TARGETS sqlpp11-connector-sqlite3 - ARCHIVE DESTINATION lib diff --git a/recipes/sqlpp11-connector-sqlite3/all/test_package/CMakeLists.txt b/recipes/sqlpp11-connector-sqlite3/all/test_package/CMakeLists.txt index 33ae887aa6aea..93abcb4ad8918 100644 --- a/recipes/sqlpp11-connector-sqlite3/all/test_package/CMakeLists.txt +++ b/recipes/sqlpp11-connector-sqlite3/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(sqlpp11-connector-sqlite3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE sqlpp11-connector-sqlite3::sqlpp11-connector-sqlite3) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/sqlpp11-connector-sqlite3/all/test_package/conanfile.py b/recipes/sqlpp11-connector-sqlite3/all/test_package/conanfile.py index 008c4dc3fb8e3..a2dc431b471dc 100644 --- a/recipes/sqlpp11-connector-sqlite3/all/test_package/conanfile.py +++ b/recipes/sqlpp11-connector-sqlite3/all/test_package/conanfile.py @@ -1,11 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os import sqlite3 - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,9 +21,10 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + # test that the database is encrypted when sqlcipher is used con = sqlite3.connect("test.db") cursor = con.cursor() diff --git a/recipes/sqlpp11-connector-sqlite3/all/test_v1_package/CMakeLists.txt b/recipes/sqlpp11-connector-sqlite3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..be00a8c7f57c7 --- /dev/null +++ b/recipes/sqlpp11-connector-sqlite3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/sqlpp11-connector-sqlite3/all/test_v1_package/conanfile.py b/recipes/sqlpp11-connector-sqlite3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f2e9cf22559a9 --- /dev/null +++ b/recipes/sqlpp11-connector-sqlite3/all/test_v1_package/conanfile.py @@ -0,0 +1,30 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os +import sqlite3 + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + + # test that the database is encrypted when sqlcipher is used + con = sqlite3.connect("test.db") + cursor = con.cursor() + try: + cursor.execute("select * from tab_sample") + except sqlite3.DatabaseError: + assert self.options["sqlpp11-connector-sqlite3"].with_sqlcipher + self.output.info("database is encrypted with sqlcipher") + return + assert not self.options["sqlpp11-connector-sqlite3"].with_sqlcipher + self.output.info("database is not encrypted") diff --git a/recipes/sqlpp11-connector-sqlite3/config.yml b/recipes/sqlpp11-connector-sqlite3/config.yml index f307186375038..81b8dc2adcbb4 100644 --- a/recipes/sqlpp11-connector-sqlite3/config.yml +++ b/recipes/sqlpp11-connector-sqlite3/config.yml @@ -1,5 +1,7 @@ versions: - "0.29": + "0.31": folder: all "0.30": folder: all + "0.29": + folder: all