title: cmake link shared and static library individually
body: <p>I am using CMake to build my C++ project. My project needs to link <code>main.cpp</code> with shared libraries and static libraries. For example,</p>
  <p>Static libraries: <code>libstatic1</code>, and <code>libstatic2</code>.
  Shared libraries: <code>libshared1</code>, and <code>libshared2</code>.</p>
  <p>The solution for <code>g++</code> command is:</p>
  <pre><code>g++ -O0 -g main.o -Wl,-Bdynamic libshared1 libshared2 -Wl,-Bstatic libstatic1 libstatic2
  </code></pre>
  <p>By setting the linker options <code>-Bdynamic</code> and <code>-Bstatic</code> for shared libs and static libs respectively, <code>main.p</code> will be able to link with these libs correctly.</p>
  <p>I don't know how to do it using CMake.</p>
  <p>I set <code>target_link_options(proj PUBLIC &quot;LINKER:-Bstatic&quot;)</code> and <code>target_link_options(proj PUBLIC &quot;LINKER:-Bshared&quot;)</code> as below:</p>
  <pre><code>//CMakeLists.txt
  project(proj)
  
  #settings
  ...
  ...
  
  add_executable(proj main.cpp)
  
  target_link_libraries(proj libshared1 libshared2)
  target_link_options(proj PUBLIC &quot;LINKER:-Bdynamic&quot;)
  
  target_link_libraries(proj libstatic1 libstatic2)
  target_link_options(proj PUBLIC &quot;LINKER:-Bstatic&quot;)
  
  </code></pre>
  <p>I checked the g++ command by using <code>make VERBOSE=1</code>, it doesn't behave as I expect.</p>
  <p>So the question is:
  How to use CMake to set such g++ flags?</p>