[question (bug?)] How to use Conan center packages in a multi-config environment (Visual Studio)
See original GitHub issueMinimal example: https://github.com/Adnn/issue_conan-11885
What we are trying
- Conan 1.51.1
- Windows 10
- CMake 3.23.2
- Visual Studio 2019
We are using the modern CMake generators, , in our conan/conanfile.py
:
generators = "CMakeDeps", "CMakeToolchain"
We are following the instruction from CMakeToolchain to configure a multiconfig build environment. This results in the following commands:
conan install conan/
conan install conan/ -s build_type=Debug
conan build conan/
# This next one fails, because the debug build of the upstream lib is found first.
cd build && cmake --build . --config Release
The issue
We would expect it to configure the VS target to link against the Debug (resp. Release) package of the library in the Debug (resp. Release) configuration.
Yet, we observe that both IDE configurations actually have both path (to both Debug and Release packages) configured under Linker > Input > Additional Dependencies
.
e.g. with spdlog:
This leads to the first path always being picked up, only allowing on configuration to successfully link (because of the _ITERATOR_DEBUG_LEVEL
system of MSVC runtime).
The questions
- Can we fix our use of Conan to actually get a working multi-config VS solution?
- Is this a bug in Conan/the packages recipe? (We tried a few different recipes from Conan center, and most of them had the same problem).
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I have been made it work with Conan 1.50 (note that 1.51.1 has some issues that are still pending to be fixed in patch release in 1.51.3 soon in CMakeDeps), with:
Hi @johan-boule
Yes, those files have been already removed in 2.0, and the flow for
conan build
will be clean, working fine for multi-config too. This seems challenging to solve at this moment in 1.X, so I’d recommend giving a try to the beta and making sure things work fine correctly there (the newconan new cmake_lib -d name=hello -d version=1.0
can help for quick testing)