-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Integrate with Conan package manager #327
Comments
Ok, I will support it. |
xmake is going to work as a generator in Conan, isn't it? |
@solvingj I have supported to find conan packages using $ xmake l lib.detect.find_package bzip2
{
links =
{
bz2
}
, linkdirs =
{
/Users/ruki/.conan/data/bzip2/1.0.6/conan/stable/package/534dcc368c999e07e81f146b3466b8f656ef1f55/lib
}
, includedirs =
{
/Users/ruki/.conan/data/bzip2/1.0.6/conan/stable/package/534dcc368c999e07e81f146b3466b8f656ef1f55/include
}
} Find and use conan packages in project with xmake.lua target("test")
set_kind("binary")
add_files("src/*.c")
on_load(function (target)
import("lib.detect.find_package")
target:add(find_package("bzip2"))
end) And add_requires("bzip2")
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("bzip2") |
@yssource Yes, we are planning to do it. |
Thanks! Can you tell me how it finds packages? In theory, the user should have to include the generated conanbuildinfo.lua file, and then cmake could look for the targets with the Conan- prefix. Like, Conan-zlib, although we can decide how the names will be formatted when we create the generator. |
Ok, I have looked at the code and unfortunately, the way you have tried to solve the problem will not work. I will try my best to explain the problem, and how we'll need to proceed. Build System Settings
Libraries generated with one set of these "settings" can generally only be linked into binaries being compiled with the same settings. Furthermore, compiler flags, preprocessor flags, and special library options might need to be different, depending on the current settings. Also of note, developers often have to switch between different settings very frequently, going from Release to Debug, or from x86 to x64, etc. As a result, build systems generally create a unique folder structure for each unique combination of settings to hold the output files. Conan does something similar, but in a far more robust way. Also, it produces more than just folders with files, it produces critical variables for consuming build systems, such as Conan Settings
It does this each time Conan is run, by taking the values for all the settings (in the current execution) and hashing them to produce a Conan also lets packages define custom options for libraries, which will be factored into the Finally, as mentioned, each package might have advanced logic to choose variables that it will pass to consumers, including def package_info(self):
if self.options.minizip:
self.cpp_info.libs.append('minizip')
if self.options.shared:
self.cpp_info.defines.append('MINIZIP_DLL')
if self.settings.os == "Windows" and not tools.os_info.is_linux:
if tools.os_info.is_windows:
self.cpp_info.libs.append('zlib')
else:
self.cpp_info.libs.append('z') # MSYS/Cygwin builds
else:
self.cpp_info.libs.append('z') The Workflow of Integration Manual Workflow
Now when the user runs the Improving the workflow Obviously, the above example is extremely naive and unnecessarily verbose. I used it because it shows how all the variables are relevant in both To improve the flow, there are several things that can be done. Here's an integration for Cmake, implemented as a CMake module. With this approach, CMake did not have to be modified at all. Users simply have to include this module in every project which wants to use Conan. It has some disadvantages, but it's an option for However, since you're already writing custom code for If the user sets or passes this option when running
** Summary ** I will start work on the xmake generator now. It should not take long. |
Ok, I will improve it. |
Great, thanks! See #331 for the working draft of the |
I improved find_package and re-integrated conan, you can see (in dev branch) https://github.com/tboox/xmake/tree/dev/xmake/modules/package/manager/conan add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true,
configs = {build_requires = "xmake_generator/0.1.0@bincrafters/testing", build = "all"}})
add_requires("CONAN::OpenSSL/1.0.2n@conan/stable", {alias = "openssl",
configs = {build_requires = "xmake_generator/0.1.0@bincrafters/testing",
options = "OpenSSL:shared=True", build = "all"}})
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("openssl", "zlib") Build project ruki:test_package ruki$ xmake
checking for the architecture ... x86_64
checking for the Xcode directory ... /Applications/Xcode.app
checking for the SDK version of Xcode ... 10.14
note: try installing these packages (pass -y to skip confirm)?
-> CONAN::zlib/1.2.11@conan/stable (debug)
-> CONAN::OpenSSL/1.0.2n@conan/stable
please input: y (y/n)
=> installing CONAN::zlib/1.2.11@conan/stable .. ok
=> installing CONAN::OpenSSL/1.0.2n@conan/stable .. ok
[ 0%]: ccache compiling.release src/main.c
[100%]: linking.release test If you want to known more, you can see #339 |
this is looking very good, amazing progress as usual. it seems you have learned a great deal about Conan, and now have plans on how to improve your support for it in the future. I think continued improvement on this integration will be sufficiently tracked in #339 along with the other package managers in a general way. Overall, there is a mostly-working integration now, so I will close this ticket. |
A simple example add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true}})
add_requires("CONAN::OpenSSL/1.0.2n@conan/stable", {alias = "openssl",
configs = {options = "OpenSSL:shared=True"}})
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("openssl", "zlib") |
@solvingj It seems that the new version of conan 2.x breaks a lot of things.
|
Your current quandary is a very difficult consequence of adding integration and support with multiple other tool/ecosystems like Conan, VCPKG, Cmake, and others. Each one is likely to make breaking changes at some point, And it's rarely easy to deal with four "wrapper tools" like Xmake. Now you have to decide how much time and complexity you want to devote to continue supporting the subset of xmake users who also use Conan, and use them together. It's been a few years since initial support was added. Now maybe you have some idea of whether or not a substantial number of people are even doing that. You added a native package manager into xmake, so if I were using Xmake for anything serious, I would probably want to use only xmake packages. Having some dependencies come from one package manager, and others come from another seems completely chaotic and unmanageable. If you decide to continue support, Conan integration, you probably have two choices:
Of note, I only really consider the needs of professional software development teams in my comments. Hobbyists, and open source projects have different wants/needs. I don't know which user base you focus on more with Xmake. In any case, things are going to get difficult end messy for you and/or any affected users for a while, so I wish you the best of luck. |
Can I integrate xmake into https://github.com/conan-io/conan/tree/release/2.0/conan/tools? Wouldn't that be better? |
That folder contains mostly generators for build systems like the But again, all that is separate from what broke and what you asked about. The topic at hand is the details of how But getting back to the point, the |
I may have missed something but can't this be simply solved by querying Conan version before using its CLI, like |
Which problem are you suggesting that solves specifically? If you mean the part about a "Conan v1|v2 mode", sure that could be the default "autodetect" behavior but I would consider that a minor detail. There are a lot of implementation details in the current conan support which will be fundamentally different for Conan v2 so that's a lot of code to re-write/change/maintain. But again, bigger than all that is the strategic decision about whether to support both modes in perpetuity. |
I'm trying to write a new generator for xmake, but I'm having some problems. conan-io/conan#13709 |
You're almost there, they'll get you the rest of the way. |
conan 2.0.5 re-supports the export of global generators. conan-io/conan#13718 xmake/dev now also supports conan 2.0.5 #3703 |
I'm having an issue trying to use the conan support. I'm trying to use a package that is already downloaded in the conan cache: add_requires("conan::qtmaya/2024", {alias = "qt"})
target("UILibrary")
set_kind("static")
add_files("MyWidget.cpp")
add_packages("qt") When I run
Pressing How should I do that? I tried |
Per @waruqi request, opening this ticket to track an effort to add support for Conan packages.
Ideally, each build system would not need to support each package manager, but this is not a solved problem yet. Until then, custom support must be added to find Conan packages installed on the local machine.
The text was updated successfully, but these errors were encountered: