Search code examples
conanconan-2

Does conan config install <repo> support git submodules?


I want to use conan new https://docs.conan.io/2.0/reference/commands/new.html to create new project from specific template. But I do not want to manage all templates in the same conan config repo. Instead I want to use git submodule for that. Is it possible?


Solution

  • You can use multiple repos, and conan config install them. Each repo can contain different things, you can have some templates in one repo, some profiles in another repo, etc. Every conan config install will append files that don't exist, overwrite files that exist.

    The conan config install command also has extra -a <args> argument that can be passed to the underlaying git clone command. It is intended mostly to be able to checkout a specific folder, but it is forwarding those arguments to git clone so you can also instruct to fetch submodules with --recursive

    For configuration management in Conan, specially if the sources for that configuration is complex (with submodules), it might be worth checking the conan config install-pkg command, that allows to put configuration in a Conan package, so it can benefit from versioning and easy updates conan config install-pkg myconf/[>=1.0 2] and better reproducibility adding the config version to lockfiles. So it might be useful to "pre-process" your source repo with the submodules for the config, create a conan package with a version for it and upload the package, so consumers of the configuration use it instead of the git repo.