Repository: conan-io/conan-center-index

Issue:
[request] sqlpp11/0.62
### Package Name/Version

sqlpp11/0.62

### Changelog

https://github.com/rbock/sqlpp11/releases/tag/0.62

### Context about the new update

The above-mentioned version is newly released by the upstream project and not yet available as a recipe.
Please add this version.



Discussion:

Resolving patch:
diff --git a/recipes/sqlpp11/all/conanfile.py b/recipes/sqlpp11/all/conanfile.py
--- a/recipes/sqlpp11/all/conanfile.py
+++ b/recipes/sqlpp11/all/conanfile.py
@@ -1,8 +1,12 @@
-from conans import ConanFile, tools
-from conans.errors import ConanInvalidConfiguration
+from conan import ConanFile
+from conan.errors import ConanInvalidConfiguration
+from conan.tools.build import check_min_cppstd
+from conan.tools.layout import basic_layout
+from conan.tools.files import get, copy
+from conan import Version
 import os
 
-required_conan_version = ">=1.33.0"
+required_conan_version = ">=1.53.0"
 
 
 class Sqlpp11Conan(ConanFile):
@@ -12,60 +16,56 @@ class Sqlpp11Conan(ConanFile):
     homepage = "https://github.com/rbock/sqlpp11"
     description = "A type safe SQL template library for C++"
     topics = ("sql", "dsl", "embedded", "data-base")
+    package_type = "header-library"
     settings = "os", "arch", "compiler", "build_type"
     no_copy_source = True
 
-    @property
-    def _source_subfolder(self):
-        return "source_subfolder"
 
     @property
-    def _min_stdcpp_version(self):
-        return 11 if tools.Version(self.version) < "0.61" else 14
+    def _min_cppstd(self):
+        return 11 if Version(self.version) < "0.61" else 14
 
     @property
     def _compilers_minimum_version(self):
         return {
             "gcc": "5",
             "Visual Studio": "14",
+            "msvc": "190",
             "clang": "3.4",
             "apple-clang": "10",
         }
 
+    def layout(self):
+        basic_layout(self, src_folder="src")
+
     def requirements(self):
         self.requires("date/3.0.1")
 
-    def validate(self):
-        if self.settings.compiler.cppstd:
-            tools.check_min_cppstd(self, self._min_stdcpp_version)
-
-        if self._min_stdcpp_version > 11:
-            minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
-            if minimum_version:
-                if tools.Version(self.settings.compiler.version) < minimum_version:
-                    raise ConanInvalidConfiguration(f"{self.name} requires C++14, which your compiler does not support.")
-            else:
-                self.output.warn(f"{self.name} requires C++14. Your compiler is unknown. Assuming it supports C++14.")
-
     def package_id(self):
-        self.info.header_only()
+        self.info.clear()
+
+    def validate(self):
+        if self.settings.compiler.get_safe("cppstd"):
+            check_min_cppstd(self, self._min_cppstd)
+        minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
+        if minimum_version and Version(self.settings.compiler.version) < minimum_version:
+            raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.")
 
     def source(self):
-        tools.get(
-            **self.conan_data["sources"][self.version],
-            destination=self._source_subfolder,
-            strip_root=True
-        )
+        get(self, **self.conan_data["sources"][self.version], strip_root=True)
 
     def package(self):
-        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
-        self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include"))
-        self.copy("*", dst="bin", src=os.path.join(self._source_subfolder, "scripts"))
+        copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
+        copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include"))
+        copy(self, "*", dst=os.path.join(self.package_folder, "bin"), src=os.path.join(self.source_folder, "scripts"))
 
     def package_info(self):
-        self.cpp_info.filenames["cmake_find_package"] = "Sqlpp11"
-        self.cpp_info.filenames["cmake_find_package_multi"] = "Sqlpp11"
+        self.cpp_info.libdirs = []
+
+        self.cpp_info.set_property("cmake_file_name", "Sqlpp11")
+        self.cpp_info.set_property("cmake_target_name", "sqlpp11::sqlpp11")
 
+        # TODO: to remove in conan v2 once cmake_find_package_* generators removed
         bindir = os.path.join(self.package_folder, "bin")
         self.output.info("Appending PATH environment variable: {}".format(bindir))
         self.env_info.PATH.append(bindir)


Test patch:
diff --git a/recipes/sqlpp11/all/test_package/CMakeLists.txt b/recipes/sqlpp11/all/test_package/CMakeLists.txt
--- a/recipes/sqlpp11/all/test_package/CMakeLists.txt
+++ b/recipes/sqlpp11/all/test_package/CMakeLists.txt
@@ -1,11 +1,8 @@
-cmake_minimum_required(VERSION 3.1)
-project(PackageTest CXX)
+cmake_minimum_required(VERSION 3.15)
+project(test_package LANGUAGES CXX)
 
-include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-conan_basic_setup(TARGETS)
+find_package(Sqlpp11 REQUIRED CONFIG)
 
-find_package(Sqlpp11 CONFIG REQUIRED)
-
-add_executable(example example.cpp)
-set_property(TARGET example PROPERTY CXX_STANDARD 14)
-target_link_libraries(example sqlpp11::sqlpp11)
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} PRIVATE sqlpp11::sqlpp11)
+target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
diff --git a/recipes/sqlpp11/all/test_package/conanfile.py b/recipes/sqlpp11/all/test_package/conanfile.py
--- a/recipes/sqlpp11/all/test_package/conanfile.py
+++ b/recipes/sqlpp11/all/test_package/conanfile.py
@@ -1,10 +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
 
 
-class Sqlpp11TestConan(ConanFile):
-    settings = "os", "compiler", "build_type", "arch"
-    generators = "cmake", "cmake_find_package_multi"
+class TestPackageConan(ConanFile):
+    settings = "os", "arch", "compiler", "build_type"
+    generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
+    test_type = "explicit"
+
+    def layout(self):
+        cmake_layout(self)
+
+    def requirements(self):
+        self.requires(self.tested_reference_str)
 
     def build(self):
         cmake = CMake(self)
@@ -12,5 +21,6 @@ def build(self):
         cmake.build()
 
     def test(self):
-        if not tools.cross_building(self.settings):
-            self.run(os.path.join("bin", "example"), run_environment=True)
+        if can_run(self):
+            bin_path = os.path.join(self.cpp.build.bindir, "test_package")
+            self.run(bin_path, env="conanrun")
diff --git a/recipes/sqlpp11/all/test_package/example.cpp b/recipes/sqlpp11/all/test_package/example.cpp
deleted file mode 100644
--- a/recipes/sqlpp11/all/test_package/example.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sqlpp11/sqlpp11.h>
-
-int main()
-{
-  sqlpp::connection c;
-}
diff --git a/recipes/sqlpp11/all/test_package/test_package.cpp b/recipes/sqlpp11/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/sqlpp11/all/test_package/test_package.cpp
@@ -0,0 +1,8 @@
+#include <cstdlib>
+#include <sqlpp11/select.h>
+#include <sqlpp11/alias_provider.h>
+
+int main() {
+    select(sqlpp::value(false).as(sqlpp::alias::a));
+    return EXIT_SUCCESS;
+}
diff --git a/recipes/sqlpp11/all/test_v1_package/CMakeLists.txt b/recipes/sqlpp11/all/test_v1_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/sqlpp11/all/test_v1_package/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.1)
+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/all/test_v1_package/conanfile.py b/recipes/sqlpp11/all/test_v1_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/sqlpp11/all/test_v1_package/conanfile.py
@@ -0,0 +1,19 @@
+import os
+
+from conan.tools.build import cross_building
+from conans import ConanFile, CMake
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    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)