I am trying to integrate multiple OpenApi definitions that I generate with the openapi-generator
into my Conan 2 and CMake based project.
I currently have a somewhat working version, but the OpenAPI stubs get rebuild unconditionally during every Conan build even if the OpenAPI YML files have not changed. I think there must be a better solution that uses the cached generated files if the inputs did not change.
I would mainly like to understand if I should call the openapi-generator from Conan or from CMake and how I can achive a more efficient integration.
Currently I am doing roughly the following:
- Add a tool dependency in conan:
tool_requires = "openapi-generator/6.6.0"
- Call
self.run(f"openapi-generator generate -i ... -o ... -g cpprest-sdk <other options>")
from the build method before I runcmake.build()
.
Should I move the generation steps into CMake or is it correct to handle this from Conan? Is there a better way to generate the implementation so that Conan (or CMake) can reuse previously generated files?