conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.31k stars 986 forks source link

support quickly create a template project #17184

Closed aiyolo closed 1 month ago

aiyolo commented 1 month ago

What is your suggestion?

I'd like that conan can help me to quickly setup a project. the workflow would be something like (refer to cargo): conan new myproj [--bin/--lib] cd myproj conan add lib1 conan install . cmake -B build cmake --build build]

although conan currently support create cmake_exe, the syntax is too long, and it creates several files instead of a project folder ! As a big fan of conan, I really don't like this feature.

Have you read the CONTRIBUTING guide?

memsharded commented 1 month ago

Hi @aiyolo

Thanks for your suggestion.

The built-in templates like conan new cmake_lib create the files inside the current folder, which means:

mkdir myproj && cd myproj
conan new cmake_lib -d name=mypkg -d version=0.1
conan install .
cmake ...

works great. I honestly don't think there is much difference in UX compared with what you are posting, mostly a matter of subjective personal opinion. Furthermore, the implemented approach is quite flexible and powerful, for example:

conan new cmake_exe -d name=myapp -d version=0.1 -d requires=mypkg/0.1

will create the scaffolding of an application including the requires, the find_package() in the CMakeLists.txt, the necessary calls in the .cpp files, etc.

So overall, it doesn't seem worth changing how conan new works, it already can create template projects, quickly and easily.

Otherwise the conan new allows to define your own project templates to customize what is created, please check https://docs.conan.io/2/reference/commands/new.html#custom-templates. Those templates can also be shared with conan config install.

aiyolo commented 1 month ago

In my opinion, “-d name=myapp -d version=0.1” should be optional, because we always want to create a project quickly. The name and version are not so much important and they can be populated with some default values that can be edited later in conanfile.py. And I insist that the if “-d” can be omitted, this command will be accepted by more users.

memsharded commented 1 month ago

I agree that defaulting those arguments could be nice, let's give that a try.

memsharded commented 1 month ago

Closed by https://github.com/conan-io/conan/pull/17186 for next Conan 2.9