filipdutescu / modern-cpp-template

A template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
The Unlicense
1.69k stars 214 forks source link

[BUG] Conan not working ootb #28

Closed inql closed 2 years ago

inql commented 2 years ago

Describe the bug After installing conan with pip and enabling conan support for project, several things are not working properly:

  1. ${PROJECT_NAME}_CONAN_REQUIRES and ${PROJECT_NAME}_CONAN_OPTIONS are not being detected.
  2. When detected, libraries are not linked so, compilation is failing (tested with boost only)

Already managed to fix that, so you can apply that @filipdutescu:

  1. For first issue, just replace ${CONAN_REQUIRES} with ${${PROJECT_NAME}_CONAN_REQUIRES} in Conan.cmake - just a typo :) apply same for ${CONAN_OPTIONS}
  2. For second, conan_basic_setup() needs to be called within Conan.cmake.

To Reproduce Steps to reproduce the behavior:

  1. Clone repo
  2. Install conan via pip
  3. Enable conan in cmake/StandardSettings.cmake
  4. Add dependency in cmake/Conan.cmake, like set(${PROJECT_NAME}_CONAN_REQUIRES "boost/1.77.0")
  5. Use the library somewhere in example project, like #include <boost/archive/text_oarchive.hpp> in include/project/tmp.hpp
  6. Build the project, enjoy the compilation error.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

filipdutescu commented 2 years ago

Hello, @inql! Thank's very much for finding and reporting this bug. Many thanks are also due for providing a fix as well, making my life easy :grinning:. I have pushed the fixed, hopefully it works as intended. I would be grateful if you could test it out (4b6ae29) just to confirm everything works as expected.

inql commented 2 years ago

Everything works like a charm :smile: But you should also check on .workflows as they seem not to support conan (at least for ubuntu, needed to add it by myself). I could apply some changes, but I'm not sure if I can contribute :)

filipdutescu commented 2 years ago

You can always make a PR and we can discuss the changes you wish to see. However I would like to keep the actions as generic as possible (i.e. if you want to use Conan I assume you also know how to change the actions)