docs icon indicating copy to clipboard operation
docs copied to clipboard

How to use conan with CMake to generate multi-config Visual Studio Solution Files?

Open RochaStratovan opened this issue 1 year ago • 2 comments

What is your question?

Hello,

We have a sizeable C/C++ code base that uses CMake to generate multi-config solution files for Windows, as well as single config make file for Linux. Our company is split pretty evenly between Linux and Windows developers.

We would like to use Conan for package management and integration with GitLab. I've worked through the examples, and I'm stuck on one issue. How do I use Conan with CMake to generate a multi-configuration Visual Studio solution file that allows me to select any of the configurations and compile?

Here is the problem I noticed. I worked through the tutorial's Build a simple CMake project using Conan demo.

Following the instructions, I created a Visual Studio solution file that would compile when using the command line cmake --build . --config Release or the Visual Studio IDE set to Release.

I noticed the VS IDE still had the selector for Debug and RelWithDebInfo, so I tried compiling Debug, and it failed saying it couldn't find zlib.h file. I used the VS IDE and quickly saw that the extra include paths and link libraries for Debug weren't set.

This makes sense, because I only configured Release, but I cannot find any documentation that explains how to get it to work with both Release and Debug at the same time.

I found the tutorial page "Building for multiple configurations: Release, Debug, Static and Shared", but this page explains how to change configuration, essentially meaning a separate solution file per configuration.

How can I use conan to to install the desired dependencies: Release and Debug and then run cmake to use the installed Release and Debug dependencies?

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

RochaStratovan avatar Jan 19 '24 23:01 RochaStratovan