conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] What's the replacement of `virtualenv` generator in Conan 2?

Open PauloCarvalhoRJ opened this issue 4 months ago • 4 comments

Hello,

So, I have in an Conan 1 recipe:

    generators = "cmake", "virtualenv"

How do I rewrite this in order to get the activate.bat script in Conan 2? Is it the VirtualRunEnv? I don't want to get fooled by a possibly misleading namesake.

best,

PC

PauloCarvalhoRJ avatar Dec 02 '25 18:12 PauloCarvalhoRJ

Hi @PauloCarvalhoRJ thanks for your question.

Yes, the virtualenv generator was replaced with the VirtualRunEnv and VirtualBuildEnv generators. Those are available in Conan 1 too, and their usage is pretty similar, as described in their documentation sections

In fact, these 2 generators are injected by Conan 2 by default, so if you don't need to customize anything, you can drop them from the generators expression too :)

Let me know if this helps, we're always happy to help in the transition from Conan 1 to Conan 2!

AbrilRBS avatar Dec 02 '25 18:12 AbrilRBS

Hello,

Thank you for the feedback. Continuing on the issue, I have a legacy Bootstrap.cmake script that expects a Conan 1-generated conanbuildinfo.cmake. What is the new name of the corresponding file in Conan 2? I found several .cmake files in the build directory, but I couldn't identify which one would do.

regards,

PC

PauloCarvalhoRJ avatar Dec 02 '25 19:12 PauloCarvalhoRJ

In Conan 2 (and also using the CMakeDeps and CMakeToolchain integrations in Conan 1), the integration is transparent. No need to modify the CMakeLists.txt to include anything Conan-specific. Just standard find_package().

Check for example how it works:

mkdir dep && cd dep
conan new cmake_lib -d name=dep -d version=0.1
conan create
cd ..
mkdir pkg && cd pkg
conan new cmake_exe -d name=pkg -d version=0.1 -d requires=dep/0.1
conan build

The pkg uses the CMakeToolchain and CMakeDeps, inspect the CMakeLists.txt to see how it works.

Also, the tutorial, in the first section explains about this, see: https://docs.conan.io/2/tutorial/consuming_packages/build_simple_cmake_project.html

memsharded avatar Dec 02 '25 23:12 memsharded

@PauloCarvalhoRJ do you have any other questions regarding the migration? Else we can mark this as solved and close the issue, but do feel free to create new issues if you find any other blockers, thanks!

AbrilRBS avatar Dec 04 '25 09:12 AbrilRBS

Closing this ticket as answered, but don't hesitate to open new tickets if necessary, thanks for the feedback!

memsharded avatar Dec 15 '25 09:12 memsharded