conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.28k stars 981 forks source link

[question] Can not find by boost with components #9841

Open playgithub opened 3 years ago

playgithub commented 3 years ago

Env

windows 11 qt creator 5.0.2 conan 1.41.0

conanfile.py

from conans import ConanFile

class ConanDeps(ConanFile):
   settings = "os", "compiler", "build_type", "arch"
   requires = "boost/1.77.0"
   default_options = { "*:shared": True }
   generators = "CMakeToolchain", "CMakeDeps"

   def imports(self):
      self.copy("*.dll", dst="bin", src="bin")

cmake configure options

-GNinja
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}

Problem

CMakeLists.txt

...
find_package(Boost REQUIRED COMPONENTS locale) # fails
find_package(Boost REQUIRED) # succeeds and target_link_libraries works, e.g. target_link_libraries(tgt PRIVATE Boost::locale)
...

More Info

tested on wxWidgets

find_package(wxWidgets REQUIRED COMPONENTS core) succeeds

SpaceIm commented 3 years ago

Do you pass generated toolchain file to CMake with -DCMAKE_TOOLCHAIN_FILE?

playgithub commented 3 years ago

Do you pass generated toolchain file to CMake with -DCMAKE_TOOLCHAIN_FILE?

Qt Creator will automatically do this, and other libs working fine. Anyway I've tried -DCMAKE_TOOLCHAIN_FILE, but it doesn't help.

If you have Qt Creator, simply test it.

SpaceIm commented 3 years ago

I don't have Qt Creator, but it works fine on my side with -DCMAKE_TOOLCHAIN_FILE=<abspath/to/conan_toolchain.cmake> in a terminal.

So maybe some magic in https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/share/3rdparty/package-manager/auto-setup.cmake is not ready for CMakeToolchain and/or CMakeDeps generators?

With wxWidgets, during CMake configuration, do you see messages like -- Conan: Component target declared or -- Conan: Target declared? If not, it means there is something wrong.