[DO-981] qt package (!15)

Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
This commit is contained in:
Aleksandr Vodyanov
2025-02-13 12:25:48 +03:00
parent 60445ac09e
commit 3759e1163f
228 changed files with 16106 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
sources:
"2.13.4":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.13/libxml2-2.13.4.tar.xz"
sha256: "65d042e1c8010243e617efb02afda20b85c2160acdbfbcb5b26b80cec6515650"
"2.12.9":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.12/libxml2-2.12.9.tar.xz"
sha256: "59912db536ab56a3996489ea0299768c7bcffe57169f0235e7f962a91f483590"
"2.12.4":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.12/libxml2-2.12.4.tar.xz"
sha256: "497360e423cf0bd99eacdb7c6215dea92e6d6e89ee940393c2bae0e77cb9b7d0"
"2.12.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.12/libxml2-2.12.3.tar.xz"
sha256: "8c8f1092340a89ff32bc44ad5c9693aff9bc8a7a3e161bb239666e5d15ac9aaa"
"2.11.9":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.11/libxml2-2.11.9.tar.xz"
sha256: "780157a1efdb57188ec474dca87acaee67a3a839c2525b2214d318228451809f"
"2.11.6":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.11/libxml2-2.11.6.tar.xz"
sha256: "c90eee7506764abbe07bb616b82da452529609815aefef423d66ef080eb0c300"
"2.11.4":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.11/libxml2-2.11.4.tar.xz"
sha256: "737e1d7f8ab3f139729ca13a2494fd17bf30ddb4b7a427cf336252cab57f57f7"
"2.10.4":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.10/libxml2-2.10.4.tar.xz"
sha256: "ed0c91c5845008f1936739e4eee2035531c1c94742c6541f44ee66d885948d45"
"2.10.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.10/libxml2-2.10.3.tar.xz"
sha256: "5d2cc3d78bec3dbe212a9d7fa629ada25a7da928af432c93060ff5c17ee28a9c"
"2.9.14":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.9/libxml2-2.9.14.tar.xz"
sha256: "60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee"
"2.9.12":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.9/libxml2-2.9.12.tar.xz"
sha256: "28a92f6ab1f311acf5e478564c49088ef0ac77090d9c719bbc5d518f1fe62eb9"
"2.9.10":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/libxml2/2.9/libxml2-2.9.10.tar.xz"
sha256: "593b7b751dd18c2d6abcd0c4bcb29efc203d0b4373a6df98e3a455ea74ae2813"

View File

@@ -0,0 +1,414 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import cross_building, build_jobs
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, get, rename, rm, rmdir, replace_in_file, save, chdir, mkdir
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, NMakeDeps, NMakeToolchain
from conan.tools.scm import Version
import os
import itertools
import textwrap
required_conan_version = ">=1.55.0"
class Libxml2Conan(ConanFile):
name = "libxml2"
package_type = "library"
url = "https://github.com/conan-io/conan-center-index"
description = "libxml2 is a software library for parsing XML documents"
topics = "xml", "parser", "validation"
homepage = "https://gitlab.gnome.org/GNOME/libxml2/-/wikis/"
license = "MIT"
settings = "os", "arch", "compiler", "build_type"
# from ./configure and ./win32/configure.js
default_options = {
"shared": False,
"fPIC": True,
"include_utils": True,
"c14n": True,
"catalog": True,
"docbook": True, # dropped after 2.10.3
"ftp": True,
"http": True,
"html": True,
"iconv": True,
"icu": False,
"iso8859x": True,
"legacy": True,
"mem-debug": False,
"output": True,
"pattern": True,
"push": True,
"python": False,
"reader": True,
"regexps": True,
"run-debug": False,
"sax1": True,
"schemas": True,
"schematron": True,
"threads": True,
"tree": True,
"valid": True,
"writer": True,
"xinclude": True,
"xpath": True,
"xptr": True,
"zlib": True,
"lzma": False,
}
options = {name: [True, False] for name in default_options.keys()}
@property
def _configure_option_names(self):
return [name for name in self.default_options.keys() if (name in self.options)
and (name not in ["shared", "fPIC", "include_utils"])]
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
@property
def _is_mingw_windows(self):
return self.settings.compiler == "gcc" and self.settings.os == "Windows" and self._settings_build.os == "Windows"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) >= "2.10.3":
del self.options.docbook
if Version(self.version) >= "2.11.0":
self.options.rm_safe("run-debug")
if Version(self.version) >= "2.13.0":
self.options.rm_safe("mem-debug")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
if self.options.zlib:
self.requires("zlib/[>=1.2.11 <2]")
if self.options.lzma:
self.requires("xz_utils/5.4.5")
if self.options.iconv:
self.requires("libiconv/1.17", transitive_headers=True, transitive_libs=True)
if self.options.icu:
self.requires("icu/73.2")
def build_requirements(self):
if not (is_msvc(self) or self._is_mingw_windows):
if self.options.zlib or self.options.lzma or self.options.icu:
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/[>=2.1.0]")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
if is_msvc(self):
tc = NMakeToolchain(self)
tc.generate()
deps = NMakeDeps(self)
deps.generate()
elif self._is_mingw_windows:
pass # nothing to do for mingw? it calls mingw-make directly
else:
env = VirtualBuildEnv(self)
env.generate()
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")
tc = AutotoolsToolchain(self)
yes_no = lambda v: "yes" if v else "no"
tc.configure_args.extend([
f"--enable-shared={yes_no(self.options.shared)}",
f"--enable-static={yes_no(not self.options.shared)}",
])
for option_name in self._configure_option_names:
option_value = getattr(self.options, option_name)
tc.configure_args.append(f"--with-{option_name}={yes_no(option_value)}")
tc.generate()
tc = PkgConfigDeps(self)
tc.generate()
tc = AutotoolsDeps(self)
tc.generate()
def _build_msvc(self):
with chdir(self, os.path.join(self.source_folder, 'win32')):
debug = "yes" if self.settings.build_type == "Debug" else "no"
static = "no" if self.options.shared else "yes"
args = [
"cscript",
"configure.js",
"compiler=msvc",
f"prefix={self.package_folder}",
f"cruntime=/{msvc_runtime_flag(self)}",
f"debug={debug}",
f"static={static}",
]
incdirs = [incdir for dep in self.dependencies.values() for incdir in dep.cpp_info.includedirs]
libdirs = [libdir for dep in self.dependencies.values() for libdir in dep.cpp_info.libdirs]
args.append(f"include=\"{';'.join(incdirs)}\"")
args.append(f"lib=\"{';'.join(libdirs)}\"")
for name in self._configure_option_names:
cname = {"mem-debug": "mem_debug",
"run-debug": "run_debug",
"docbook": "docb"}.get(name, name)
value = getattr(self.options, name)
value = "yes" if value else "no"
args.append(f"{cname}={value}")
configure_command = ' '.join(args)
self.output.info(configure_command)
self.run(configure_command)
# Fix library names because they can be not just zlib.lib
def fix_library(option, package, old_libname):
if option:
libs = []
aggregated_cpp_info = self.dependencies[package].cpp_info.aggregated_components()
for lib in itertools.chain(aggregated_cpp_info.libs, aggregated_cpp_info.system_libs):
libname = lib
if not libname.endswith('.lib'):
libname += '.lib'
libs.append(libname)
replace_in_file(self, "Makefile.msvc",
f"LIBS = $(LIBS) {old_libname}",
f"LIBS = $(LIBS) {' '.join(libs)}")
fix_library(self.options.zlib, 'zlib', 'zlib.lib')
fix_library(self.options.lzma, "xz_utils", "liblzma.lib")
fix_library(self.options.iconv, 'libiconv', 'iconv.lib')
fix_library(self.options.icu, 'icu', 'advapi32.lib sicuuc.lib sicuin.lib sicudt.lib')
fix_library(self.options.icu, 'icu', 'icuuc.lib icuin.lib icudt.lib')
self.run("nmake /f Makefile.msvc libxml libxmla libxmladll")
if self.options.include_utils:
self.run("nmake /f Makefile.msvc utils")
def _package_msvc(self):
with chdir(self, os.path.join(self.source_folder, 'win32')):
self.run("nmake /f Makefile.msvc install-libs")
if self.options.include_utils:
self.run("nmake /f Makefile.msvc install-dist")
def _build_mingw(self):
with chdir(self, os.path.join(self.source_folder, "win32")):
# configuration
yes_no = lambda v: "yes" if v else "no"
args = [
"cscript",
"configure.js",
"compiler=mingw",
f"prefix={self.package_folder}",
f"debug={yes_no(self.settings.build_type == 'Debug')}",
f"static={yes_no(not self.options.shared)}",
]
incdirs = [incdir for dep in self.dependencies.values() for incdir in dep.cpp_info.includedirs]
libdirs = [libdir for dep in self.dependencies.values() for libdir in dep.cpp_info.libdirs]
args.append(f"include=\"{' -I'.join(incdirs)}\"")
args.append(f"lib=\"{' -L'.join(libdirs)}\"")
for name in self._configure_option_names:
cname = {
"mem-debug": "mem_debug",
"run-debug": "run_debug",
"docbook": "docb",
}.get(name, name)
args.append(f"{cname}={yes_no(getattr(self.options, name))}")
configure_command = " ".join(args)
self.output.info(configure_command)
self.run(configure_command)
# build
def fix_library(option, package, old_libname):
if option:
aggregated_cpp_info = self.dependencies[package].cpp_info.aggregated_components()
replace_in_file(self,
"Makefile.mingw",
f"LIBS += -l{old_libname}",
f"LIBS += -l{' -l'.join(aggregated_cpp_info.libs)}",
)
fix_library(self.options.iconv, "libiconv", "iconv")
fix_library(self.options.zlib, "zlib", "z")
fix_library(self.options.lzma, "xz_utils", "lzma")
self.run(f"mingw32-make -j{build_jobs(self)} -f Makefile.mingw libxml libxmla")
if self.options.include_utils:
self.run(f"mingw32-make -j{build_jobs(self)} -f Makefile.mingw utils")
def _package_mingw(self):
with chdir(self, os.path.join(self.source_folder, "win32")):
mkdir(self, os.path.join(self.package_folder, "include", "libxml2"))
self.run("mingw32-make -f Makefile.mingw install-libs")
if self.options.include_utils:
self.run("mingw32-make -f Makefile.mingw install-dist")
def _patch_sources(self):
# Break dependency of install on build
for makefile in ("Makefile.mingw", "Makefile.msvc"):
replace_in_file(self, os.path.join(self.source_folder, "win32", makefile),
"install-libs : all",
"install-libs :")
def build(self):
self._patch_sources()
if is_msvc(self):
self._build_msvc()
elif self._is_mingw_windows:
self._build_mingw()
else:
autotools = Autotools(self)
autotools.configure()
autotools.make("libxml2.la")
if self.options.include_utils:
for target in ["xmllint", "xmlcatalog", "xml2-config"]:
autotools.make(target)
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False)
copy(self, "Copyright", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False)
if is_msvc(self):
self._package_msvc()
# remove redundant libraries to avoid confusion
if not self.options.shared:
rm(self, "libxml2.dll", os.path.join(self.package_folder, "bin"))
rm(self, "libxml2_a_dll.lib", os.path.join(self.package_folder, "lib"))
rm(self, "libxml2_a.lib" if self.options.shared else "libxml2.lib", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
elif self._is_mingw_windows:
self._package_mingw()
if self.options.shared:
rm(self, "libxml2.a", os.path.join(self.package_folder, "lib"))
rename(self, os.path.join(self.package_folder, "lib", "libxml2.lib"),
os.path.join(self.package_folder, "lib", "libxml2.dll.a"))
else:
rm(self, "libxml2.dll", os.path.join(self.package_folder, "bin"))
rm(self, "libxml2.lib", os.path.join(self.package_folder, "lib"))
else:
autotools = Autotools(self)
for target in ["install-libLTLIBRARIES", "install-data"]:
autotools.make(target=target, args=[f"DESTDIR={unix_path(self, self.package_folder)}"])
if self.options.include_utils:
autotools.install()
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.sh", os.path.join(self.package_folder, "lib"))
rm(self, "run*", os.path.join(self.package_folder, "bin"))
rm(self, "test*", os.path.join(self.package_folder, "bin"))
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)
for header in ["win32config.h", "wsockcompat.h"]:
copy(self, pattern=header, src=os.path.join(self.source_folder, "include"),
dst=os.path.join(self.package_folder, "include", "libxml2"), keep_path=False)
self._create_cmake_module_variables(
os.path.join(self.package_folder, self._module_file_rel_path)
)
def _create_cmake_module_variables(self, module_file):
# FIXME: also define LIBXML2_XMLLINT_EXECUTABLE variable
content = textwrap.dedent(f"""\
set(LibXml2_FOUND TRUE)
set(LIBXML2_FOUND TRUE)
if(DEFINED LibXml2_INCLUDE_DIRS)
set(LIBXML2_INCLUDE_DIR ${{LibXml2_INCLUDE_DIRS}})
set(LIBXML2_INCLUDE_DIRS ${{LibXml2_INCLUDE_DIRS}})
elseif(DEFINED libxml2_INCLUDE_DIRS)
set(LIBXML2_INCLUDE_DIR ${{libxml2_INCLUDE_DIRS}})
set(LIBXML2_INCLUDE_DIRS ${{libxml2_INCLUDE_DIRS}})
endif()
if(DEFINED LibXml2_LIBRARIES)
set(LIBXML2_LIBRARIES ${{LibXml2_LIBRARIES}})
set(LIBXML2_LIBRARY ${{LibXml2_LIBRARIES}})
elseif(DEFINED libxml2_LIBRARIES)
set(LIBXML2_LIBRARIES ${{libxml2_LIBRARIES}})
set(LIBXML2_LIBRARY ${{libxml2_LIBRARIES}})
endif()
if(DEFINED LibXml2_DEFINITIONS)
set(LIBXML2_DEFINITIONS ${{LibXml2_DEFINITIONS}})
elseif(DEFINED libxml2_DEFINITIONS)
set(LIBXML2_DEFINITIONS ${{libxml2_DEFINITIONS}})
else()
set(LIBXML2_DEFINITIONS "")
endif()
set(LIBXML2_VERSION_STRING "{self.version}")
""")
save(self, module_file, content)
@property
def _module_file_rel_path(self):
return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake")
def package_info(self):
# FIXME: Provide LibXml2::xmllint & LibXml2::xmlcatalog imported target for executables
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_module_file_name", "LibXml2")
self.cpp_info.set_property("cmake_file_name", "libxml2")
self.cpp_info.set_property("cmake_target_name", "LibXml2::LibXml2")
self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path])
self.cpp_info.set_property("pkg_config_name", "libxml-2.0")
prefix = "lib" if is_msvc(self) else ""
suffix = "_a" if is_msvc(self) and not self.options.shared else ""
self.cpp_info.libs = [f"{prefix}xml2{suffix}"]
self.cpp_info.includedirs.append(os.path.join("include", "libxml2"))
if not self.options.shared:
self.cpp_info.defines = ["LIBXML_STATIC"]
if self.options.include_utils:
bindir = os.path.join(self.package_folder, "bin")
self.output.info(f"Appending PATH environment variable: {bindir}")
self.env_info.PATH.append(bindir)
if self.settings.os in ["Linux", "FreeBSD", "Android"]:
self.cpp_info.system_libs.append("m")
if self.options.threads and self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("pthread")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("dl")
elif self.settings.os == "Windows":
if self.options.ftp or self.options.http:
self.cpp_info.system_libs.extend(["ws2_32", "wsock32"])
if Version(self.version) >= "2.13.4":
# https://gitlab.gnome.org/GNOME/libxml2/-/issues/791
# https://gitlab.gnome.org/GNOME/libxml2/-/blob/2.13/win32/Makefile.msvc?ref_type=heads#L84
self.cpp_info.system_libs.append("bcrypt")
# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
self.cpp_info.filenames["cmake_find_package"] = "LibXml2"
self.cpp_info.filenames["cmake_find_package_multi"] = "libxml2"
self.cpp_info.names["cmake_find_package"] = "LibXml2"
self.cpp_info.names["cmake_find_package_multi"] = "LibXml2"
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.names["pkg_config"] = "libxml-2.0"

View File

@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.12)
project(test_package LANGUAGES C)
find_package(LibXml2 REQUIRED MODULE)
add_executable(${PROJECT_NAME} ../test_package/test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE LibXml2::LibXml2)
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindLibXml2.html
# are properly defined in conan generators
set(_custom_vars
LibXml2_FOUND # since CMake 3.14
LIBXML2_FOUND # until CMake 3.14
LIBXML2_INCLUDE_DIR
LIBXML2_INCLUDE_DIRS
LIBXML2_LIBRARIES
LIBXML2_DEFINITIONS
LIBXML2_VERSION_STRING
)
foreach(_custom_var ${_custom_vars})
if(DEFINED ${_custom_var})
message(STATUS "${_custom_var}: ${${_custom_var}}")
else()
message(FATAL_ERROR "${_custom_var} not defined")
endif()
endforeach()

View File

@@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
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)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml")
self.run(f"{bin_path} {xml_path}", env="conanrun")

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(libxml2 REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE LibXml2::LibXml2)

View File

@@ -0,0 +1,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"build/gcc-12-x86_64-gnu17-release/generators/CMakePresets.json"
]
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious
agent known only as Oberon helps to create a new life
for the inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
<book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters,
battle one another for control of England. Sequel to
Oberon's Legacy.</description>
</book>
<book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled.</description>
</book>
<book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty
thousand leagues beneath the sea.</description>
</book>
<book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.</description>
</book>
<book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a Heisenberg
Uncertainty Device, James Salway discovers the problems
of being quantum.</description>
</book>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
<book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
</book>
<book id="bk112">
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.</description>
</book>
</catalog>

View File

@@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
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)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
xml_path = os.path.join(self.source_folder, "books.xml")
self.run(f"{bin_path} {xml_path}", env="conanrun")

View File

@@ -0,0 +1,45 @@
#include <stdio.h>
#include <stdlib.h>
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
static void print_element_names(xmlNode *a_node)
{
xmlNode *cur_node = NULL;
for (cur_node = a_node; cur_node; cur_node = cur_node->next)
{
if (cur_node->type == XML_ELEMENT_NODE)
{
printf("node type: Element, name: %s\n", cur_node->name);
}
print_element_names(cur_node->children);
}
}
int main(int argc, char **argv)
{
xmlDoc *doc = NULL;
xmlNode *root_element = NULL;
if (argc != 2)
return (1);
LIBXML_TEST_VERSION
/*parse the file and get the DOM */
doc = xmlReadFile(argv[1], NULL, 0);
if (doc == NULL)
{
printf("error: could not parse file %s\n", argv[1]);
exit(-1);
}
/*Get the root element node */
root_element = xmlDocGetRootElement(doc);
print_element_names(root_element);
xmlFreeDoc(doc); // free document
xmlCleanupParser(); // Free globals
return 0;
}

View File

@@ -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_cmake_module_package
${CMAKE_CURRENT_BINARY_DIR}/test_cmake_module_package)

View File

@@ -0,0 +1,18 @@
from conans import ConanFile, CMake, tools
import os
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml")
self.run(f"{bin_path} {xml_path}", run_environment=True)

View File

@@ -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)

View File

@@ -0,0 +1,18 @@
from conans import ConanFile, CMake, tools
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml")
self.run(f"{bin_path} {xml_path}", run_environment=True)