-
Notifications
You must be signed in to change notification settings - Fork 982
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
[feature] Multiple CMake builds from single conanfile #17303
Comments
Hi @s-geiger-si Thanks for your detailed feedback. I'd like to discuss first a bit more option2. Because this honestly sound like the one that I would choose.
Yes, this looks very easy, like the recipe can also generate or add a
But I think this is a very small disadvantage. Doing a So this approach would be much simpler to implement in the recipe, but moreover it will also have consistent input of the same CMake toolchain very easily. Please let me know what you think. I have also checked a bit the implementation of |
I agree that a workaround is possible and I do have a working workaround which involves using a custom cmake template for the openapi-generator that works better with the My main point here is that there is no satisfactory solution that involves a seamless integration of the tree tools involved (i.e., Given that Conan "understands" cmake (via the CMakeToolchain, CMake, CMakeDeps integrations) it would be great if I could say: "Hey Conan, generate and build this other cmake project first, use a separate build tree and install everything into a different install prefix and then consider that when building the main project." and all of that with a relatively clear declarative style that does not involve writing a bunch of python code to achieve the integration. Given that I have a workaround this does not have the highest priority for me. But it would be great if I could come back to this at some point (even if I have to wait a bit) and replace my workaround with a cleaner approach. Btw. I have seen other issues that go in a similar direction and ask about changing the CMake install prefix (which seems to default to the build_folder rather than a subfolder like |
I have also missed this capability when working on some multi-project CMake libraries and ended up using the "root CMakeLists" workaround. Could the |
I have had a look to check the complexity of this. |
What is your suggestion?
Extracting this issue from #10220 after @memsharded suggested in a comment that it should be its own issue.
I would like to be able to build code that is being generated with the OpenAPI generator which I invoke via Conan. The issue is that the
openapi-generator
produces a folder tree that contains a pretty-much self contained CMake project.I tried to explore several alternative options:
add_subdirectory
to build everything from a single CMake project.Option 1 would imply that we move everything into CMake and use
add_custom_command
to invoke theopenapi-generator
. This is not possible, since we cannot load additionalCMakeLists.txt
files during a CMake configure call.Option 2 is generally possible, but it has the disadvantage, that
install()
directives from the openapi modules are being leaked into the main project and we end up installing headers, static libs and other stuff into the main install prefix and then need to filter them out later on.A better solution would be to explore option 3 and to configure and build the openapi generated code as a separate sub-step via Conan, install it into a
CMAKE_PREFIX_PATH
and then usefind_package
from the main project to resolve the dependencies. The openapi generated code only produces static libraries which are being consumed in the main project, so I do not need to create a Conan package from them. Currently I have not found a way to do this, becauseCMakeToolchain
, andCMake
assume that a single build is happening.What I would like to do is:
openapi-generator
CMake
build tree (which can be private to Conan)CMAKE_PREFIX_PATH
Further background can also be found here: https://stackoverflow.com/questions/78361333/integrate-openapi-generate-with-conan-2-and-cmake-with-proper-caching
Question from @memsharded
Not yet, I was hoping that I could reuse the Conan classes for CMake and CMakeToolchain, since I had the impression that this is the best practice approach.
I think I could reuse the same toolchain, since I do not need a different dependency subset, but as I understand it, the toolchain seems to also control details such as the
CMAKE_PREFIX_PATH
and theCMAKE_INSTALL_PREFIX
or the build folder for the CMake build tree and I am not able to pass this as an overwrite toCMake(self)
or tocmake.configure()
.What I would effectively like to have is some structure like the following (if that makes sense):
For the main project build tree, I would then like to configure CMake to set
CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:./openapi-1/build/install:./openapi-2/build/install
.So basically, I was hoping I could do something like:
Maybe I am missing something and this is totally the wrong approach?
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: