diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py index 135d4bdbf88af..c183f8d0d6e08 100644 --- a/recipes/libxml2/all/conanfile.py +++ b/recipes/libxml2/all/conanfile.py @@ -86,6 +86,9 @@ def configure(self): 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.13") @@ -94,10 +97,7 @@ def requirements(self): if self.options.iconv: self.requires("libiconv/1.17") if self.options.icu: - self.requires("icu/71.1") - - def layout(self): - basic_layout(self, src_folder="src") + self.requires("icu/72.1") def build_requirements(self): if not (is_msvc(self) or self._is_mingw_windows): @@ -151,7 +151,6 @@ def generate(self): 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" @@ -215,7 +214,6 @@ def _package_msvc(self): 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 @@ -269,7 +267,6 @@ def _package_mingw(self): 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"): @@ -281,7 +278,6 @@ def _patch_sources(self): "-install_name \\$rpath/", "-install_name @rpath/") - def build(self): self._patch_sources() if is_msvc(self): @@ -345,22 +341,31 @@ def package(self): def _create_cmake_module_variables(self, module_file): # FIXME: also define LIBXML2_XMLLINT_EXECUTABLE variable content = textwrap.dedent("""\ - if(DEFINED LibXml2_FOUND) - set(LIBXML2_FOUND ${LibXml2_FOUND}) - endif() - if(DEFINED LibXml2_INCLUDE_DIR) - set(LIBXML2_INCLUDE_DIR ${LibXml2_INCLUDE_DIR}) - set(LIBXML2_INCLUDE_DIRS ${LibXml2_INCLUDE_DIR}) + 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_LIBRARIES ${libxml2_INCLUDE_DIRS}) + set(LIBXML2_LIBRARY ${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}) endif() if(DEFINED LibXml2_VERSION) set(LIBXML2_VERSION_STRING ${LibXml2_VERSION}) + elseif(DEFINED libxml2_VERSION) + set(LIBXML2_VERSION_STRING ${libxml2_VERSION}) endif() """) save(self, module_file, content) diff --git a/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt b/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt deleted file mode 100644 index 39f1f2e09e014..0000000000000 --- a/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(test_package C) - -find_package(LibXml2 REQUIRED) - -message("LIBXML2_FOUND: ${LIBXML2_FOUND}") -message("LIBXML2_INCLUDE_DIR: ${LIBXML2_INCLUDE_DIR}") -message("LIBXML2_INCLUDE_DIRS: ${LIBXML2_INCLUDE_DIRS}") -message("LIBXML2_LIBRARIES: ${LIBXML2_LIBRARIES}") -message("LIBXML2_LIBRARY: ${LIBXML2_LIBRARY}") -message("LIBXML2_DEFINITIONS: ${LIBXML2_DEFINITIONS}") -message("LIBXML2_VERSION_STRING: ${LIBXML2_VERSION_STRING}") - -add_executable(${PROJECT_NAME} ../test_package/test_package.c) -target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2) diff --git a/recipes/libxml2/all/test_module_package/CMakeLists.txt b/recipes/libxml2/all/test_module_package/CMakeLists.txt new file mode 100644 index 0000000000000..90d37ee9afb23 --- /dev/null +++ b/recipes/libxml2/all/test_module_package/CMakeLists.txt @@ -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() diff --git a/recipes/libxml2/all/test_cmake_module_package/conanfile.py b/recipes/libxml2/all/test_module_package/conanfile.py similarity index 88% rename from recipes/libxml2/all/test_cmake_module_package/conanfile.py rename to recipes/libxml2/all/test_module_package/conanfile.py index 3eab19928545d..20481a742d614 100644 --- a/recipes/libxml2/all/test_cmake_module_package/conanfile.py +++ b/recipes/libxml2/all/test_module_package/conanfile.py @@ -23,5 +23,5 @@ def build(self): 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, "..", "test_package", "books.xml") + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml") self.run(f"{bin_path} {xml_path}", env="conanrun") diff --git a/recipes/libxml2/all/test_package/CMakeLists.txt b/recipes/libxml2/all/test_package/CMakeLists.txt index 60662e900b4c8..9d8bc300051af 100644 --- a/recipes/libxml2/all/test_package/CMakeLists.txt +++ b/recipes/libxml2/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -find_package(libxml2 CONFIG REQUIRED) +find_package(libxml2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2) +target_link_libraries(${PROJECT_NAME} PRIVATE LibXml2::LibXml2) diff --git a/recipes/libxml2/all/test_v1_cmake_module_package/CMakeLists.txt b/recipes/libxml2/all/test_v1_cmake_module_package/CMakeLists.txt deleted file mode 100644 index 487747f324c50..0000000000000 --- a/recipes/libxml2/all/test_v1_cmake_module_package/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(LibXml2 REQUIRED) - -message("LIBXML2_FOUND: ${LIBXML2_FOUND}") -message("LIBXML2_INCLUDE_DIR: ${LIBXML2_INCLUDE_DIR}") -message("LIBXML2_INCLUDE_DIRS: ${LIBXML2_INCLUDE_DIRS}") -message("LIBXML2_LIBRARIES: ${LIBXML2_LIBRARIES}") -message("LIBXML2_LIBRARY: ${LIBXML2_LIBRARY}") -message("LIBXML2_DEFINITIONS: ${LIBXML2_DEFINITIONS}") -message("LIBXML2_VERSION_STRING: ${LIBXML2_VERSION_STRING}") - -add_executable(${PROJECT_NAME} ../test_package/test_package.c) -target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2) diff --git a/recipes/libxml2/all/test_v1_module_package/CMakeLists.txt b/recipes/libxml2/all/test_v1_module_package/CMakeLists.txt new file mode 100644 index 0000000000000..75233d23b3349 --- /dev/null +++ b/recipes/libxml2/all/test_v1_module_package/CMakeLists.txt @@ -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_module_package + ${CMAKE_CURRENT_BINARY_DIR}/test_module_package) diff --git a/recipes/libxml2/all/test_v1_cmake_module_package/conanfile.py b/recipes/libxml2/all/test_v1_module_package/conanfile.py similarity index 66% rename from recipes/libxml2/all/test_v1_cmake_module_package/conanfile.py rename to recipes/libxml2/all/test_v1_module_package/conanfile.py index 3bec0de0bab22..ca3b4e232a4f3 100644 --- a/recipes/libxml2/all/test_v1_cmake_module_package/conanfile.py +++ b/recipes/libxml2/all/test_v1_module_package/conanfile.py @@ -14,6 +14,5 @@ def build(self): 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, "..", "test_package", "books.xml") - bin_arg_path = "%s %s" % (bin_path, xml_path) - self.run(bin_arg_path, run_environment=True) + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml") + self.run(f"{bin_path} {xml_path}", run_environment=True) diff --git a/recipes/libxml2/all/test_v1_package/CMakeLists.txt b/recipes/libxml2/all/test_v1_package/CMakeLists.txt index ea045cdb5efca..0d20897301b68 100644 --- a/recipes/libxml2/all/test_v1_package/CMakeLists.txt +++ b/recipes/libxml2/all/test_v1_package/CMakeLists.txt @@ -1,17 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -find_package(LibXml2 REQUIRED) -message("LIBXML2_FOUND: ${LIBXML2_FOUND}") -message("LIBXML2_INCLUDE_DIR: ${LIBXML2_INCLUDE_DIR}") -message("LIBXML2_INCLUDE_DIRS: ${LIBXML2_INCLUDE_DIRS}") -message("LIBXML2_LIBRARIES: ${LIBXML2_LIBRARIES}") -message("LIBXML2_LIBRARY: ${LIBXML2_LIBRARY}") -message("LIBXML2_DEFINITIONS: ${LIBXML2_DEFINITIONS}") -message("LIBXML2_VERSION_STRING: ${LIBXML2_VERSION_STRING}") - -add_executable(${PROJECT_NAME} ../test_package/test_package.c) -target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libxml2/all/test_v1_package/conanfile.py b/recipes/libxml2/all/test_v1_package/conanfile.py index 3bec0de0bab22..ae0f76f08489b 100644 --- a/recipes/libxml2/all/test_v1_package/conanfile.py +++ b/recipes/libxml2/all/test_v1_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -14,6 +14,5 @@ def build(self): 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, "..", "test_package", "books.xml") - bin_arg_path = "%s %s" % (bin_path, xml_path) - self.run(bin_arg_path, run_environment=True) + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml") + self.run(f"{bin_path} {xml_path}", run_environment=True)