Let's say I have a library uploaded as a package in conan, which uses OpenGL, and as such links with GL in the CMakeLists.txt. Do the users of the library need to explicitly link against GL again? Does conan provide a method to track it and include it in ${CONAN_LIBS}?
The nearest thing I found in the docs is the method package_info, where it seems that you can specify linker extra options, but I don't seem to be using it properly in my library's conanfile.py. I tried all of:
self.cpp_info.sharedlinkflags = ["-lGL", "GL", "libGL", "libGL.so", "-llibGL.so"]
But if in the user code I don't put the link flag, it raises "undefined reference" to GL's methods.
EDIT: I'm working in linux mint 17.
Yes, you need to declare it in the
conanfile.pypackage_info()method, as conan decouples build (as defined in your cmake files) from package management. There is a specific attribute for libraries in thecpp_infoattribute, which you could use:This
libsfield is transitive between dependencies, and the GL lib will be contained in the${CONAN_LIBS}variableThe
sharedlinkflagsis transitive too, and it ends with its values accumulated in the cmake variable${CMAKE_SHARED_LINKER_FLAGS}. But as its name states, it is only for shared linking, so it is likely that you are not building such a shared library, so your lib flags asGLare not being applied to your target.