Skip to content

libxml2 - cannot build with 'msvc' compiler #13511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
abf7354
libxml2 - add note about problem
paulharris Oct 15, 2022
e26eb04
libxml2 - translate MSVC compiler runtime to MD/MT style
paulharris Oct 15, 2022
920b1b6
libxml2 - use msvc_runtime_flag()
paulharris Oct 17, 2022
383c57f
Making autotools work for v2
paulharris Oct 26, 2022
97b2dac
PkgConfigDeps
paulharris Oct 26, 2022
4b62ea1
Add version 2.10.3
paulharris Oct 26, 2022
4ef5557
Add test_v1_package
paulharris Oct 26, 2022
fea8b3b
Trying to fix mingw, started on msvc
paulharris Oct 26, 2022
ca19ad5
Add python import
paulharris Oct 26, 2022
98d230d
Disable msvc for now while debugging mingw
paulharris Oct 26, 2022
647fceb
Re-adding mingw
paulharris Oct 26, 2022
4febd3c
Reintroduce nmake
paulharris Oct 26, 2022
ca46fb1
Build fixes
paulharris Oct 26, 2022
d07a92b
Removed some comments
paulharris Oct 26, 2022
b2931be
Configure in the build(), not in generate()
paulharris Oct 27, 2022
aa8ae7c
Add dl to system_libs
paulharris Oct 27, 2022
1c554b8
Apply suggestions from code review
paulharris Oct 28, 2022
79b7f5b
Remove unused import
paulharris Oct 28, 2022
fa23395
Test MODULE finder
paulharris Oct 31, 2022
fd49274
Try out SpaceIM's workaround for nmake issues
paulharris Oct 31, 2022
eb3787d
Merge remote-tracking branch 'upstream/master' into libxml2-link-error
paulharris Nov 3, 2022
d192fab
Make a loop into 2 explicit lines
paulharris Nov 3, 2022
86dc292
Rename module tests
paulharris Nov 3, 2022
417de8e
Add Environment import
paulharris Nov 3, 2022
6a3198a
Fix test_v1_cmake_module_package (wrong path)
paulharris Nov 3, 2022
2555b01
Make linter happy with f'' format strings
paulharris Nov 3, 2022
a13c9b0
Test variables in test_*_cmake_module_package
paulharris Nov 3, 2022
8e44aa6
Upgrade to conan 1.53.0 with rm_safe()
paulharris Nov 3, 2022
46b10a3
Fixup usage of tools.microsoft.bash:path
paulharris Nov 3, 2022
31fe2d2
Implement nmake workaround from #13941
paulharris Nov 3, 2022
97866f4
Typo fix
paulharris Nov 2, 2022
31391de
Fix some f"" strings
paulharris Nov 3, 2022
bc9f330
Update recipes/libxml2/all/conanfile.py
paulharris Nov 5, 2022
b3d27ec
Update recipes/libxml2/all/conanfile.py
paulharris Nov 5, 2022
8f33399
test_v1_module_package - don't use the add_subdirectory method
paulharris Nov 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions recipes/libxml2/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"2.10.3":
url: "https://download.gnome.org/sources/libxml2/2.10/libxml2-2.10.3.tar.xz"
sha256: "5d2cc3d78bec3dbe212a9d7fa629ada25a7da928af432c93060ff5c17ee28a9c"
"2.9.14":
url: "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.tar.xz"
sha256: "60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee"
Expand Down
247 changes: 135 additions & 112 deletions recipes/libxml2/all/conanfile.py

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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}")
Comment on lines +6 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was there before, and things that use it as a module tend to want these defined,
so I was checking with these.
Happy for them to be removed in a future PR :)


add_executable(${PROJECT_NAME} ../test_package/test_package.c)
target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2)
27 changes: 27 additions & 0 deletions recipes/libxml2/all/test_cmake_module_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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, "..", "test_package", "books.xml")
self.run(f"{bin_path} {xml_path}", env="conanrun")
12 changes: 1 addition & 11 deletions recipes/libxml2/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
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}")
find_package(libxml2 CONFIG REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should actually add a test_module_package/ 🤔

Since there's an official https://cmake.org/cmake/help/latest/module/FindLibXml2.html one we need to make sure it not broken

and we should test both 🤔

Does that make sense? leave the old CMakeLists.txt and duplicate the rest?

Copy link
Contributor

@SpaceIm SpaceIm Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I be testing LIBXML2_INCLUDE_DIR and other old cmake variables in test_v1_package_module?
They work, but only if they are in the CMakeLists.txt in test_package_module.
If I print out the messages after add_subdirectory() (in test_v1_package_module), nothing is printed - cmake scoping?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a scope issue. It's not setting parent by default.

I think the example space shared is a good way. Put all the code in one and add sub dir from the other.

I would call it "test cmake module package" so it's more clear but that a nit

Test package module implies the opposite of what it's doing in English

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've re-added the LIBXML2_INCLUDE_DIR to the test_cmake_module_package test,
however,
it does NOT work correctly for test_cmake_module_package,
it only works for test_v1_cmake_module_package.

I'm wondering if we should test these at all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it should be tested. If it fails it means that there is an issue in libxml2 recipe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SpaceIm ok, well I am not sure if these should work at all. Yes for old v1 stuff, but from other conversations I believe the goal is to move away from old cmake variables and use modern targets etc.
So I guess this recipe is fine for now?


add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2)
29 changes: 14 additions & 15 deletions recipes/libxml2/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
from conans import ConanFile, CMake, tools
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", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def build_requirements(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8":
# Workaround for CMake bug with error message:
# Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being
# set. This could be because you are using a Mac OS X version less than 10.5
# or because CMake's platform configuration is corrupt.
# FIXME: Remove once CMake on macOS/M1 CI runners is upgraded.
self.build_requires("cmake/3.22.0")
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 not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
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")
bin_arg_path = "%s %s" % (bin_path, xml_path)
self.run(bin_arg_path, run_environment=True)
self.run(f"{bin_path} {xml_path}", env="conanrun")
18 changes: 18 additions & 0 deletions recipes/libxml2/all/test_v1_cmake_module_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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)
19 changes: 19 additions & 0 deletions recipes/libxml2/all/test_v1_cmake_module_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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, "..", "test_package", "books.xml")
bin_arg_path = "%s %s" % (bin_path, xml_path)
self.run(bin_arg_path, run_environment=True)
17 changes: 17 additions & 0 deletions recipes/libxml2/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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)
19 changes: 19 additions & 0 deletions recipes/libxml2/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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, "..", "test_package", "books.xml")
bin_arg_path = "%s %s" % (bin_path, xml_path)
self.run(bin_arg_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/libxml2/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"2.10.3":
folder: all
"2.9.14":
folder: all
"2.9.13":
Expand Down