I'm working with a C++ project using Conan for dependency management and CMake as the build system.
I created a new Conan package for a static library called mylib. The header files are located under the path:
mylib/include/mylib/MyHeader_Interface.h
relevant conan_pkg.py content looks like this:
from conans import CMake, ConanFile
@property
def conan(self):
return self._conan
def get_exports_sources(self) -> Iterable[str]:
return (
"src/**",
"include/**",
"cmake/*",
"CMakeLists.txt",
"version",
"LICENSE",
"tests/**"
)
def package_info(self):
super().package_info()
self.conan.cpp_info.includedirs = [
self.conan.cpp_info.rootpath + '/include/mylib']
Conan version 1.64.0
After creating the package, I confirmed the header is located at:
~/.conan/data/mylib/0.0.1/user/channel/package/<package-id>/include/mylib/mylib/MyHeader_Interface.h
In the consuming core project, I use:
find_package(mylib REQUIRED)
target_link_libraries(${target_name} PUBLIC mylib::mylib)
However, when compiling, I get the following error:
fatal error: mylib/MyHeader_Interface.h: No such file or directory
Question: Why is the header not found during compilation, even though the package seems to have it in the expected include path? Do I need to adjust the include directory layout or change how I reference the headers in the consuming project?
CMakeDepsis the recommended one even in Conan 1. I'd suggest to submit a ticket with a full minimal reproduction example to github.com/conan-io/conan/issuesself.cpp_info), so it might belong to somepython-requiresthat this recipe is using, so it would be necessary to provide also thepython-requires. Same forget_exports_sources(), that method doesn't belong to Conan.conanin conan_pkg.py refers to an instance of theConanFileclass.from conans import CMake, ConanFileincludedirsfield, but you use the absolute one.find_package(mylib ...)was missing in the CMake configuration of the consuming project's tests.