From 1e0409670576b0b59e211df5edbc22c60a772e58 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 15 Feb 2020 19:00:38 +0100 Subject: [PATCH] add tinyxml2/7.1.0 --- recipes/tinyxml2/all/CMakeLists.txt | 7 +++ recipes/tinyxml2/all/conandata.yml | 4 ++ recipes/tinyxml2/all/conanfile.py | 57 +++++++++++++++++++ .../tinyxml2/all/test_package/CMakeLists.txt | 8 +++ .../tinyxml2/all/test_package/conanfile.py | 17 ++++++ .../all/test_package/test_package.cpp | 15 +++++ recipes/tinyxml2/config.yml | 3 + 7 files changed, 111 insertions(+) create mode 100644 recipes/tinyxml2/all/CMakeLists.txt create mode 100644 recipes/tinyxml2/all/conandata.yml create mode 100644 recipes/tinyxml2/all/conanfile.py create mode 100644 recipes/tinyxml2/all/test_package/CMakeLists.txt create mode 100644 recipes/tinyxml2/all/test_package/conanfile.py create mode 100644 recipes/tinyxml2/all/test_package/test_package.cpp create mode 100644 recipes/tinyxml2/config.yml diff --git a/recipes/tinyxml2/all/CMakeLists.txt b/recipes/tinyxml2/all/CMakeLists.txt new file mode 100644 index 0000000000000..217b9530b904d --- /dev/null +++ b/recipes/tinyxml2/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/tinyxml2/all/conandata.yml b/recipes/tinyxml2/all/conandata.yml new file mode 100644 index 0000000000000..633be98e53b2e --- /dev/null +++ b/recipes/tinyxml2/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "7.1.0": + url: "https://github.com/leethomason/tinyxml2/archive/7.1.0.tar.gz" + sha256: "68ebd396a4220d5a9b5a621c6e9c66349c5cfdf5efaea3f16e3bb92e45f4e2a3" diff --git a/recipes/tinyxml2/all/conanfile.py b/recipes/tinyxml2/all/conanfile.py new file mode 100644 index 0000000000000..5516e368a0428 --- /dev/null +++ b/recipes/tinyxml2/all/conanfile.py @@ -0,0 +1,57 @@ +import os + +from conans import ConanFile, CMake, tools + +class Tinyxml2Conan(ConanFile): + name = "tinyxml2" + description = "Simple, small, efficient, C++ XML parser that can be " \ + "easily integrated into other programs." + license = "Zlib" + topics = ("conan", "tinyxml2", "xml", "parser") + homepage = "https://github.com/leethomason/tinyxml2" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = "CMakeLists.txt" + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename(self.name + "-" + self.version, self._source_subfolder) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/tinyxml2/all/test_package/CMakeLists.txt b/recipes/tinyxml2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..48b17115a09d2 --- /dev/null +++ b/recipes/tinyxml2/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.11) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/tinyxml2/all/test_package/conanfile.py b/recipes/tinyxml2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ea57a464900be --- /dev/null +++ b/recipes/tinyxml2/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + 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) diff --git a/recipes/tinyxml2/all/test_package/test_package.cpp b/recipes/tinyxml2/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ab243f53716ad --- /dev/null +++ b/recipes/tinyxml2/all/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include + +int main() { + static const char* xml = + "" + "" + "" + "A Midsummer Night's Dream" + ""; + + tinyxml2::XMLDocument doc; + doc.Parse(xml); + + return doc.ErrorID(); +} diff --git a/recipes/tinyxml2/config.yml b/recipes/tinyxml2/config.yml new file mode 100644 index 0000000000000..9903eda947bf5 --- /dev/null +++ b/recipes/tinyxml2/config.yml @@ -0,0 +1,3 @@ +versions: + "7.1.0": + folder: all