conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
814 stars 247 forks source link

Question about mixing debug build with release dependencies #607

Closed metalMajor closed 7 months ago

metalMajor commented 7 months ago

Hello,

I have develop2 working in release mode, so I build my application in release mode, and the dependencies in conan2 are also in release and it all compiles, hooray! Now I want my application in Debug mode, but the conan dependencies can stay in Release mode, that is ok and even preferred for performance reasons.

But when I compile my application in Debug mode in a new build dir with CMAKE_BUILD_TYPE=Debug instead of Release, then the cmake run works, but when compiling, the include paths are not set or found. When I print the properties of the imported target, for example with Eigen3, then I see that it has an expression there like this:

[cmake] Listing properties of target 'Eigen3::Eigen' which is of type 'INTERFACE_LIBRARY'
[cmake] Eigen3::Eigen IMPORTED = TRUE
[cmake] Eigen3::Eigen IMPORTED_GLOBAL = FALSE
[cmake] Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES = $<$<CONFIG:Release>:/Users/tom/.conan2/p/eigen3d88c0279cc26/p/include/eigen3>
[cmake] Eigen3::Eigen NAME = Eigen3::Eigen
[cmake] Eigen3::Eigen TYPE = INTERFACE_LIBRARY

So it seems it sets the include path only in Release mode? Can I somehow change it so this path is used in every build mode? Some custom change in cmake_provider or so is ok for me?

Thanks a lot! Best regards

memsharded commented 7 months ago

Hi @metalMajor

Thanks for your question.

The way to achieve this, is to indicate it at install time:

conan install .... -s build_type=Release -s &:build_type=Debug

This will use Release for all dependencies, except the consumer (&=placeholder for consumer) one. (More info in https://docs.conan.io/2/reference/config_files/profiles.html#profile-patterns)

metalMajor commented 7 months ago

It works! Thanks!