-
Notifications
You must be signed in to change notification settings - Fork 954
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
Be able to depend on the same package with different options #660
Comments
Should be great to have more information about the use case. If we are talking about real libraries it sound rare (link against the same library compiled differently has no much sense) but I assume the use case is for a tool or something like that? |
Yeah the most common use case for this will most likely be in a tool yeah. Or a lib with a tool and a option is to just build the tool or the library. |
But, it's related to #662? I need more info about what are you trying to do, maybe a little graph picture? |
In this case we have a toolchain that have several different targets (arm, x86, x86_64, ...) instead of having one separate conanfile per toolchain target we created one conanfile that takes a target option. But that means that there is no way to pull in x86 and x86_64 toolchain into the same package (which we need in some places). So now I need to separate these packages into different conanfiles just to give them different names and duplicate all that code to build the toolchain even if it's just the same build with different configure flags. |
What about creating a new option "x86-x86_64"? |
Definitely a possibility. |
I have a similar need for this. I would like to export only the headers of package B for package A without build. And my main package should depend on package A and B - B should now be build. We need this setup to calculate some sizes from the header without building them (embedded, static allocation). |
Sorry, I don't get the idea. |
We have an OS abstraction layer above freeRTOS, pthreads and WIN32. In order to support static allocation (especially for embedded freeRTOS). We determine the needed implementation size without actually include the headers. We use CMakes CheckTypeSize. Its a pimpl ideom without using heap allocation. Example:
If we could have the same package with different options, we could automatic generate the sizes (without running build of the freeRTOS abstraction layer implementation) and later, compile and link the implementation. |
I more or less get the idea now. |
@lasote sorry to revive this old thread, but it seemed fitting... I have a very similar question. We need to link against different libraries (components) from the same package with different options. To be specific we "require" boost and for some reason have to link against boost_thread in the dynamic variant ( |
Hi @Carsten87 This is challenging with Conan 1.X, depending on the same package with different options. You might depend on This will become a first class feature in Conan 2.0, check #10112 for example, scheduled for next alpha2 (we are already in alpha1), and defining options for individual requirements, and allowing way more finer control over dependencies will be possible. Please keep an eye on 2.0 releases, and feedback very welcome over those features. |
@memsharded thanks a lot for your super quick response. We were planning on having a look at Conan 2.0 anyway, one more reason to do so sooner 😉 In the meantime the |
@memsharded I don't seem to get the workaround running and I'm running out of ideas. As you can see in the output of C:\conan_boost>conan install .. -pr:h ../prh.txt -pr:b ../prb.txt
Configuration (profile_host):
[settings]
arch=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
[options]
boost:shared=True
[build_requires]
[env]
Configuration (profile_build):
[settings]
arch=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
[options]
boost:shared=False
[build_requires]
[env]
conanfile.py: Installing package
Requirements
boost/1.76.0 from 'conanio' - Cache
bzip2/1.0.8 from 'conanio' - Cache
zlib/1.2.11 from 'conanio' - Cache
Packages
boost/1.76.0:847654ce15b50bdbb96596fa75b793c981bdc204 - Cache
bzip2/1.0.8:d16a91eadaaf5829b928b12d2f836ff7680d3df5 - Cache
zlib/1.2.11:3fb49604f9c2f729b85ba3115852006824e72cab - Cache
Build requirements
boost/1.76.0 from 'conanio' - Cache
bzip2/1.0.8 from 'conanio' - Cache
zlib/1.2.11 from 'conanio' - Cache
Build requirements packages
boost/1.76.0:847654ce15b50bdbb96596fa75b793c981bdc204 - Cache
bzip2/1.0.8:d16a91eadaaf5829b928b12d2f836ff7680d3df5 - Cache
zlib/1.2.11:3fb49604f9c2f729b85ba3115852006824e72cab - Cache
Installing (downloading, building) binaries...
bzip2/1.0.8: Already installed!
bzip2/1.0.8: Appending PATH environment variable: E:\dev\.conan\data\bzip2\1.0.8\_\_\package\d16a91eadaaf5829b928b12d2f836ff7680d3df5\bin
bzip2/1.0.8: Appending PATH environment variable: E:\dev\.conan\data\bzip2\1.0.8\_\_\package\d16a91eadaaf5829b928b12d2f836ff7680d3df5\bin
zlib/1.2.11: Already installed!
boost/1.76.0: Already installed!
boost/1.76.0: Disabled magic autolinking (smart and magic decisions)
boost/1.76.0: Disabled magic autolinking (smart and magic decisions)
conanfile.py: Applying build-requirement: boost/1.76.0
conanfile.py: Applying build-requirement: zlib/1.2.11
conanfile.py: Applying build-requirement: bzip2/1.0.8
conanfile.py: Generator cmake_find_package created FindBoost.cmake
conanfile.py: Generator cmake_find_package created FindZLIB.cmake
conanfile.py: Generator cmake_find_package created FindBZip2.cmake
conanfile.py: Generator txt created conanbuildinfo.txt
conanfile.py: Generator cmake created conanbuildinfo.cmake
conanfile.py: Aggregating env generators
conanfile.py: Generated conaninfo.txt
conanfile.py: Generated graphinfo from conans import ConanFile, CMake
class ConanTest(ConanFile):
settings = "os", "compiler", "arch", "build_type"
generators = "cmake", "cmake_find_package"
requires =["boost/1.76.0@"]
build_requires =["boost/1.76.0@"]
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package_info(self):
self.cpp_info.requires = ['boost::thread']
self.cpp_info.build_requires = ['boost::random'] |
With the new generators like So please, have a look to the new generators, it seems the previous ones don't have the features to be able to handle this case. Also It seems that your case might be also a bit too challenging for |
Currently we build some packages with different options since the build scripts are very similar. The problem is that we need depend on both versions of that package from our main application. This is currently not allowed with conan.
This means that we need to split the package and duplicate build logic over two different packages.
Possible solutions: be able to change the name of the package depending on options or make it so that you can depend on several packages with different options.
The text was updated successfully, but these errors were encountered: