diff --git a/recipes/libjwt/all/conandata.yml b/recipes/libjwt/all/conandata.yml new file mode 100644 index 0000000000000..3b8d341727d2b --- /dev/null +++ b/recipes/libjwt/all/conandata.yml @@ -0,0 +1,3 @@ +sources: + "1.18.3": + url: "https://github.com/benmcollins/libjwt/archive/refs/tags/v1.18.3.zip" diff --git a/recipes/libjwt/all/conanfile.py b/recipes/libjwt/all/conanfile.py new file mode 100644 index 0000000000000..baa553c84d535 --- /dev/null +++ b/recipes/libjwt/all/conanfile.py @@ -0,0 +1,82 @@ +from conan import ConanFile, conan_version +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.files import get +from conan.tools.system import package_manager +from conan.tools.scm import Version + + +class libjwtRecipe(ConanFile): + name = "libjwt" + package_type = "library" + + # Optional metadata + license = "Mozilla Public License Version 2.0" + author = "Ben Collins" + url = "https://github.com/benmcollins/libjwt" + description = "The C JSON Web Token Library +JWK +JWKS" + topics = ("json", "jwt", "jwt-token") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + def source(self): + get(self, self.conan_data["sources"][self.version]["url"], strip_root=True) + + def requirements(self): + self.requires("openssl/3.3.2") + self.requires("jansson/2.14") + + def system_requirements(self): + apt = package_manager.Apt(self) + apt.install(["libjansson-dev"], update=True, check=True) + + yum = package_manager.Yum(self) + yum.install(["jansson-devel"], update=True, check=True) + + dnf = package_manager.Dnf(self) + dnf.install(["jansson-devel"], update=True, check=True) + + zypper = package_manager.Zypper(self) + zypper.install(["libjansson-devel"], update=True, check=True) + + pacman = package_manager.PacMan(self) + pacman.install(["jansson"], update=True, check=True) + + pkg = package_manager.Pkg(self) + pkg.install(["jansson"], update=True, check=True) + + if Version(conan_version) >= "2.0.10": + alpine = package_manager.Apk(self) + alpine.install(["jansson"], update=True, check=True) + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def generate(self): + cmakeDeps = CMakeDeps(self) + cmakeDeps.generate() + + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["jwt"] diff --git a/recipes/libjwt/all/test_package/CMakeLists.txt b/recipes/libjwt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d6ce080112b0d --- /dev/null +++ b/recipes/libjwt/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(libjwt CONFIG REQUIRED) + + + +add_executable(example src/example.cpp) +target_link_libraries(example libjwt::libjwt) diff --git a/recipes/libjwt/all/test_package/conanfile.py b/recipes/libjwt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a0c84dcd8f60e --- /dev/null +++ b/recipes/libjwt/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class libjwtTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") diff --git a/recipes/libjwt/all/test_package/src/example.cpp b/recipes/libjwt/all/test_package/src/example.cpp new file mode 100644 index 0000000000000..92096d39a94e1 --- /dev/null +++ b/recipes/libjwt/all/test_package/src/example.cpp @@ -0,0 +1,13 @@ +#include "jwt.h" + +int main() { + + jwt_t *jwt = NULL; + int ret = 0; + + ret = jwt_new(&jwt); + + jwt_free(jwt); + + return ret; +} diff --git a/recipes/libjwt/config.yml b/recipes/libjwt/config.yml new file mode 100644 index 0000000000000..f40c8df617b63 --- /dev/null +++ b/recipes/libjwt/config.yml @@ -0,0 +1,3 @@ +versions: + "1.18.3": + folder: all