|
| 1 | +# cppIni - A C++20 library for reading and writing INI files |
| 2 | +# Copyright (C) 2023-2024 Nils Hofmann <nils.friedchen@googlemail.com> |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | +# |
| 17 | +# This program is free software: you can redistribute it and/or modify |
| 18 | +# it under the terms of the GNU General Public License as published by |
| 19 | +# the Free Software Foundation, either version 3 of the License, or |
| 20 | +# (at your option) any later version. |
| 21 | +# |
| 22 | +# This program is distributed in the hope that it will be useful, |
| 23 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | +# GNU General Public License for more details. |
| 26 | +# |
| 27 | +# You should have received a copy of the GNU General Public License |
| 28 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 29 | + |
| 30 | +from conan import ConanFile |
| 31 | +from conan.tools.build import check_min_cppstd |
| 32 | +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps |
| 33 | + |
| 34 | + |
| 35 | +class cppiniRecipe(ConanFile): |
| 36 | + name = "cppini" |
| 37 | + version = "0.2.0" |
| 38 | + package_type = "library" |
| 39 | + |
| 40 | + # Optional metadata |
| 41 | + license = "GPL-3.0-or-later" |
| 42 | + author = "Nils Hofmann <nils.friedchen@gooelamil.com>" |
| 43 | + url = "https://github.com/Master92/cppIni" |
| 44 | + description = "A C++20 library for reading and writing INI files" |
| 45 | + topics = ("c++20", "configuration", "ini") |
| 46 | + |
| 47 | + # Binary configuration |
| 48 | + settings = "os", "compiler", "build_type", "arch" |
| 49 | + options = { |
| 50 | + "shared": [True, False], |
| 51 | + "fPIC": [True, False], |
| 52 | + "testing": [True, False], |
| 53 | + "coverage": [True, False] |
| 54 | + } |
| 55 | + default_options = { |
| 56 | + "shared": False, |
| 57 | + "fPIC": True, |
| 58 | + "testing": True, |
| 59 | + "coverage": False |
| 60 | + } |
| 61 | + |
| 62 | + # Sources are located in the same place as this recipe, copy them to the recipe |
| 63 | + exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "tests/*" |
| 64 | + |
| 65 | + def build_requirements(self): |
| 66 | + self.build_requires("cmake/[>=3.24]") |
| 67 | + if self.options.testing: |
| 68 | + self.test_requires("doctest/[>=2.4]") |
| 69 | + |
| 70 | + def config_options(self): |
| 71 | + if self.settings.os == "Windows": |
| 72 | + self.options.rm_safe("fPIC") |
| 73 | + |
| 74 | + def configure(self): |
| 75 | + if self.options.shared: |
| 76 | + self.options.rm_safe("fPIC") |
| 77 | + |
| 78 | + def layout(self): |
| 79 | + cmake_layout(self) |
| 80 | + |
| 81 | + def validate(self): |
| 82 | + if self.settings.compiler.cppstd: |
| 83 | + check_min_cppstd(self, "20") |
| 84 | + |
| 85 | + def generate(self): |
| 86 | + deps = CMakeDeps(self) |
| 87 | + deps.generate() |
| 88 | + tc = CMakeToolchain(self) |
| 89 | + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared |
| 90 | + tc.variables["BUILD_TESTING"] = self.options.testing |
| 91 | + tc.variables["CODE_COVERAGE"] = self.options.coverage |
| 92 | + tc.generate() |
| 93 | + |
| 94 | + def build(self): |
| 95 | + cmake = CMake(self) |
| 96 | + cmake.configure() |
| 97 | + cmake.build() |
| 98 | + cmake.test() |
| 99 | + |
| 100 | + def package(self): |
| 101 | + cmake = CMake(self) |
| 102 | + cmake.install() |
| 103 | + |
| 104 | + def package_info(self): |
| 105 | + self.cpp_info.libs = ["cppini"] |
0 commit comments