|
| 1 | +from conan import ConanFile |
| 2 | +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout |
| 3 | +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv |
| 4 | +from conan.tools.scm import Git, Version |
| 5 | +from conan.tools.files import copy |
| 6 | + |
| 7 | +import os |
| 8 | + |
| 9 | +class JsonStructLibrary(ConanFile): |
| 10 | + name = "json_struct" |
| 11 | + |
| 12 | + # Metadata |
| 13 | + license = "MIT" |
| 14 | + version = "1.0.0" |
| 15 | + author = "Jørgen Lind <jorgen.lind@gmail.com>" |
| 16 | + url = "https://github.com/jorgen/json_struct" |
| 17 | + description = "json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa" |
| 18 | + |
| 19 | + topics = ("serialization", "deserialization", "reflection", "json") |
| 20 | + |
| 21 | + settings = "os", "compiler", "build_type", "arch" |
| 22 | + pacgake_type = "header-library" |
| 23 | + implements = ["auto_header_only"] |
| 24 | + exports_sources = "include/*", "cmake/*" "CMakeLists.txt" |
| 25 | + |
| 26 | + options = { |
| 27 | + "opt_build_benchmarks": [True, False], |
| 28 | + "opt_build_examples": [True, False], |
| 29 | + "opt_build_tests": [True, False], |
| 30 | + "opt_disable_pch": [True, False], |
| 31 | + "opt_install": [True, False], |
| 32 | + } |
| 33 | + |
| 34 | + default_options = { |
| 35 | + "opt_build_benchmarks": False, |
| 36 | + "opt_build_examples": False, |
| 37 | + "opt_build_tests": False, |
| 38 | + "opt_disable_pch": False, |
| 39 | + "opt_install": True, |
| 40 | + } |
| 41 | + |
| 42 | + def generate(self): |
| 43 | + toolchain = CMakeToolchain(self) |
| 44 | + |
| 45 | + toolchain.variables["JSON_STRUCT_OPT_BUILD_BENCHMARKS"] = self.options.opt_build_benchmarks.value |
| 46 | + toolchain.variables["JSON_STRUCT_OPT_BUILD_EXAMPLES"] = self.options.opt_build_examples.value |
| 47 | + toolchain.variables["JSON_STRUCT_OPT_BUILD_TESTS"] = self.options.opt_build_tests.value |
| 48 | + toolchain.variables["JSON_STRUCT_OPT_DISABLE_PCH"] = self.options.opt_disable_pch.value |
| 49 | + toolchain.variables["JSON_STRUCT_OPT_INSTALL"] = self.options.opt_install |
| 50 | + |
| 51 | + toolchain.generate() |
| 52 | + |
| 53 | + def build(self): |
| 54 | + cmake = CMake(self) |
| 55 | + cmake.configure() |
| 56 | + cmake.build() |
| 57 | + |
| 58 | + def package(self): |
| 59 | + # Invoke cmake --install |
| 60 | + cmake = CMake(self) |
| 61 | + cmake.install() |
| 62 | + |
| 63 | + def layout(self): |
| 64 | + cmake_layout(self) |
| 65 | + |
| 66 | + def package_id(self): |
| 67 | + self.info.clear() |
0 commit comments