title: cmake, can't link static library into shared one
body: <p>I'm writing adapter (shared library) to some fpga API. I've got <code>libsomelib.a</code> and its API - <code>somelibAPI.h</code>. Here is a minimal example of my adapter:</p>
  
  <p><code>somelib_adapter.h</code>:</p>
  
  <pre><code>#include &lt;string&gt;
  
  namespace details {
  #include "somelibAPI.h"
  }
  
  class somelib_adapter {
  public:
    std::string foo();
  };
  </code></pre>
  
  <p><code>somelib_adapter.cpp</code>:</p>
  
  <pre><code>#include "somelib_adapter.h"
  using namespace details;
  
  std::string somelib_adapter::foo() {
    char result[64];
    somelibAPI_call(result);
    return std::string(result);
  }
  </code></pre>
  
  <p><code>CMakeLists.txt</code>:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.8)
  project(untitled1)
  set(CMAKE_CXX_STANDARD 11)
  set(SOURCE_FILES somelib_adapter.cpp somelib_adapter.h)
  FIND_LIBRARY(SOMELIB_LIBRARIES
          NAMES libsomelib.a
          PATHS "${SRC_CPP_DIRECTORY}")
  
  add_library(untitled1 SHARED ${SOURCE_FILES})
  
  set(untitled1 -Wl,--whole-archive ${SOMELIB_LIBRARIES} -Wl,--no-whole-archive)
  target_link_libraries(untitled1 some_other_shared_lib_used_by_somelib)
  </code></pre>
  
  <p>cmake finds <code>libsomelib.a</code> but when I'm trying to <code>nm libuntitled1.so | c++filt</code> it does not contain symbols location of <code>somelibAPI_call</code>. What's more, there is an <code>undefined reference</code> error with executable I made to test it. What may be wrong?</p>
  
  <p>EDIT: <code>libsomelib.a</code> is compiled with <code>-fPIC</code></p>
  
  <p>EDIT2: I see I misunderstood some example. Now Ive got <code>target_link_libraries(untitled1 -Wl,--whole-archive ${SOMELIB_LIBRARIES} -Wl,--no-whole-archive some_other_shared_lib_used_by_somelib)</code> but there is another problem: <code>/usr/bin/ld: ../libsomelib.a(somelibAPI.o): relocation R_X86_64_32 against .rodata.str1.1 can not be used when making a shared object; recompile with -fPIC</code></p>