title: using static libraries in cmake project
body: <p>I have two C++ projects A and B. Project B depends on project A. 
  Project A has this structure split into some subdirectories:</p>
  
  <pre><code>Project A
  |-\inc
  |  |-a1.h
  |  |-a2.h
  |-\src
     |-CMakeLists.txt
     |-\subdir_A1
     |  |-CMakeLists.txt
     |  |-a1.cpp
     |
     |-\subdir_A2
        |-CMakeLists.txt
        |-a2.cpp
  
  Project B
  |-\lib
     |-a1.h
     |-a2.h
     |-lib_ProjectA.a
  |-\src
     |-CMakeLists.txt
     |-b.cpp
  </code></pre>
  
  <p>The problem is that project B can't resolve the project's A definitions. Although I've added <code>target_link_libraries</code> to CMakeLists.txt in Project B, I have an error like this:</p>
  
  <blockquote>
    <p>undefined reference to `project_a::a1::func1()"</p>
  </blockquote>
  
  <p><strong>UPD1</strong></p>
  
  <p>I managed to compile Project B by copping all libraries from subdirectories (liba1.a, liba2.a) and linking them to the project. I wonder if it's possible to tune Project A, so that I can do with only one file lib_ProjectA.a</p>
  
  <p><strong>UPD2</strong></p>
  
  <p>Code:</p>
  
  <p>Project A</p>
  
  <pre><code>add_library (adapter
     adapter.cpp
   )
  
  target_link_libraries (adapter PUBLIC
     net  # From project's A subdirectory 
     utils # From project's A subdirectory 
  )
  </code></pre>
  
  <p>Project B</p>
  
  <pre><code>add_library (anthill
     functional_block.cpp)
  
  target_link_libraries(anthill 
    ${PROJECT_SOURCE_DIR}/lib/libjsoncpp.a
    ${PROJECT_SOURCE_DIR}/lib/libadapter.a 
    ${PROJECT_SOURCE_DIR}/lib/libnet.a     # Can't compile without it   
    ${PROJECT_SOURCE_DIR}/lib/libutils.a   # Can't compile without it
  )
  </code></pre>