I'm new to conan and I'm trying to structure my project (let's call it BaseProject) using it. In particular I'm trying to add another local project as a dependency to it.
BaseProject has the following conanfile.txt:
[requires]
other_project/1.0
[generators]
cmake
other_project is a separate project being built using make, which generates three static libraries: libfoo1.a, libfoo2.a, libfoo3.a
So I created a conanfile.py under OtherProject to add that project as a local package. The conanfile.py is the following:
from conans import ConanFile, AutoToolsBuildEnvironment
from conans import tools
class OtherProjectConan(ConanFile):
name = "other_project"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
exports_sources = "Makefile", "src/*"
def build(self):
with tools.chdir("."):
atools = AutoToolsBuildEnvironment(self)
atools.make()
def package(self):
self.copy("*.h", dst="include", src="src")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
self.deps = {"libfoo1": [], "libfoo2": [], "libfoo3": []}
# self.cpp_info.libs = ["libfoo1", "libfoo2", "libfoo3"]
src has three separates folder under it, each with its own makefile, which are all included from the base one.
After installing the package with conan, everything runs smoothly, and I can actually find libfoo1.a, libfoo2.a and libfoo3.a in the conan local cache.
Then I build BaseProject, which has the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.9)
project(base_project VERSION 0.1 LANGUAGES CXX)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
...
add_executable(base_project main.cpp)
target_link_libraries(base_project PRIVATE ${CONAN_LIBS})
install(TARGETS base_project DESTINATION ${INSTALL_BIN_DIR})
But during the linking phase I get the following error:
/usr/bin/ld: cannot find -lother_project
collect2: error: ld returned 1 exit status
This probably means that conan is looking to find a libother_project.a, but instead I'd like it to search for the three other libraries.
I tried two different approaches in the package_info() (the commented out line), but the result did not change.
I'm sorry if this happens to be a trivial question, but I'm new to conan, and after some googling I could not find a solution to this.
Thanks in advance.