Conan: Get a several dependency packages in one `褋onan install` launch

Created on 25 Jan 2016  路  8Comments  路  Source: conan-io/conan

I want on Windows:

  1. Specify in conanfile.txt which Visual C++ compiler version, architectures, build types I want download from conan.io
  2. Run conan install that will download all packages and generate one conanbuildinfo.props for all configurations (using Condition). There is a problem with the build_type, but this problem can be solved.

This would be an ideal C++ package manager for Windows.

Current conan install behavior wouldn't allow me to build my solution which contain configurations for debug/release, several toolsets (vc++ compiler version) and platforms Win32/x64

low

Most helpful comment

I think for Visual Studio it should at least be possible to build debug and release builds from one build folder.

All 8 comments

The current design has the following rationale: The conanfile.txt (and conanfile.py) files, are declarative files that can be commited into a repository together with source code, and thus are intended to be portable, among OS, compilers, and versions. The same design, for example, as CMake, you define a portable build, and then instantiate a particular build, compiler and version in command line with CMake generators. So, the specific versions that a developer wants in their machines cannot be added to conanfiles, or they will render them useless for other developers. But they can be declared in another file or script very easily.

Now, conan install XXX --all will download all packages from such XXX lib. This would retrieve Mac, Linux and Win packages if exist, which is probably too much. You can also install several specific packages with the specific shas of the versions you want conan install XXX -p=sha1 -p=sha2... which can be very easily done in a .bat file.

The current state of conan, allows to generate multiple conaninfo.txt and conanbuildinfo.props files, for multiple configurations, in different folders, but not a single file with all configurations. Thus, you would have to add the corresponding .props file for each configuration manually, which could be a workaround. Have you tried this approach? The proposed workflow (can be easily scripted) could be like:

$ mkdir build && cd build
$ mkdir vs12_debug_32 && cd vs_12_debug_32
$ conan install ../.. -s compiler="Visual Studio" -s compiler.version=12 -s arch=x86 -s build_type=Debug
$ cd .. && mkdir vs14_release_64 && vs14_release_64
$ conan install ../.. -s compiler="Visual Studio" -s compiler.version=14 -s arch=x86_64 -s build_type=Release

Then add the resulting .props files to each VS configuration.
Please tell me if this workaround works for you, or if something fails.

I'd like to know a bit more about your setup, how do you manage to build with different VC++ compiler versions from the same project? Changing arch and debug/release is done in the project/IDE, but I didn't know that changing compiler was possible withouth switching projects. What would be your expected single conanbuildinfo.props file, with the mentioned Condition? It doesn't look like a simple feature, but we can try. Thanks for your suggestions!

Thank you for detailed answer.

The same design, for example, as CMake, you define a portable build, and then instantiate a particular build, compiler and version in command line with CMake generators

Yeah, same issue with CMake on Windows. I can't even generate solution for both platforms Win32/x64, but at least CMake generate solution that can build Debug and Release configurations.

The current state of conan, allows to generate multiple conaninfo.txt and conanbuildinfo.props files, for multiple configurations, in different folders, but not a single file with all configurations.

CMake also have some multi-configuration generators, it's not exactly same but for similar purpose.

Have you tried this approach?

I have not tried. Good idea as workaround. I can write props file that include by condition conanbuildinfo.props from sub-folder.
That will allow include one props file for all projects/configurations.

how do you manage to build with different VC++ compiler versions from the same project? Changing arch and debug/release is done in the project/IDE, but I didn't know that changing compiler was possible withouth switching projects.

VS allow specify different VC++ compiler versions (platform toolset) for each configuration.
So each project configuration can use different compilers (even you can select clang if you have installed Clang for Windows)

How to: Modify the Platform Toolset https://msdn.microsoft.com/library/ff770576%28v=vs.110%29.aspx

What would be your expected single conanbuildinfo.props file, with the mentioned Condition? It doesn't look like a simple feature, but we can try.

Condition is attribute that can be used to conditionally select include path or .lib file name by platform or used compiler. Something like that http://stackoverflow.com/a/3503738/61505 , but selecting Debug/Release by configuration name not good idea because user can change configuration name. In the first step, you can generate a separate props for Debug and Release

+1 for this. Could we achieve this by creating meta-packages that require the real package but with different settings such as build_type and compiler.runtime? This meta-package could export a different XXX.props or provide a different FindXXX.cmake that resolve the required dependencies for each configuration? Maybe https://github.com/conan-io/conan-package-tools could come in handy here?

Please tell me if this workaround works for you, or if something fails.

Something like that:

@echo off
setlocal EnableDelayedExpansion
mkdir _build
cd _build

set TOOLSET=12 14
set ARCH=x86 x86_64
set BUILD_TYPE=Debug Release

for %%t in (%TOOLSET%) do (
    for %%a in (%ARCH%) do (
        for %%b in (%BUILD_TYPE%) do (
            set runtime=MD
            if "%%b"=="Debug" ( 
                set runtime=MDd
            )
            echo vc%%t0_%%a_%%b [!runtime!]
            mkdir vc%%t0_%%a_%%b
            cd vc%%t0_%%a_%%b
            conan install ../.. -s compiler="Visual Studio" -s compiler.version=%%t -s arch=%%a -s build_type=%%b -s compiler.runtime=!runtime! %*
            rem if !errorlevel! neq 0 exit /b !errorlevel!
            cd ..
        )
    )
)

I don't know why conan cannot select automatically right runtime with build_type=debug for boost.

I think for Visual Studio it should at least be possible to build debug and release builds from one build folder.

At least, something like CMAKE multiconfig generator, see CMAKE_CONFIGURATION_TYPES

It seems this issue was addressed with the creation of visual_studio_multi generator, which does exactly what the OP asks here:

Run conan install that will download all packages and generate one conanbuildinfo.props for all configurations (using Condition). There is a problem with the build_type, but this problem can be solved.

Please read: http://docs.conan.io/en/latest/reference/generators/visualstudiomulti.html

It uses the toolset information as pointed out by @KindDragon too

I think this is the best conan can do on its own, regarding this request.
For further functionality, integration with the IDE is required, so please follow conversation about this topic here: https://github.com/conan-io/conan/issues/2353

Many thanks!

For reference, I am able to compile with debug and release from the same build generated folder without any special or complicated instructions. Only selecting cmake as the generator and afterwards visual studio as the generator for cmake with cmake . -G "Visual Studio 15 Win64 works with my app for any generated target by cmake.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rconde01 picture rconde01  路  3Comments

mpdelbuono picture mpdelbuono  路  3Comments

petermbauer picture petermbauer  路  3Comments

Polibif picture Polibif  路  3Comments

zlalanne picture zlalanne  路  3Comments