title: CMake doesn't link C and C++ static libraries (undefined reference to function)
body: <p>I tried to reproduce minimal problem. When I run CMake+Make on Ubuntu I get error </p>
  
  <p><code>funccpp.cpp:(.text+0x5): undefined reference to `FuncC'</code></p>
  
  <p>i.e. exported function in C library is not found when importing in C++ library. When I try to manually compile using <code>g++ main.cpp funcc.c funccpp.cpp</code> it successfully compiles final program. How to fix CMake issue?</p>
  
  <p>For reference, when I run <code>nm libfuncc_lib.a</code> I get line <code>T FuncC</code> (so symbol is external and defined in Text section), when I run <code>nm libfunccpp_lib.a</code> I get <code>U FuncC</code> (so symbol is Undefined and should be linked from outside).</p>
  
  <p><strong>CMakeLists.txt</strong></p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  
  project(Test C CXX)
  
  set (SRC_CPP funccpp.cpp)
  set (SRC_C funcc.c)
  set (SRC_MAIN main.cpp)
  
  add_library(funcc_lib STATIC ${SRC_C})
  add_library(funccpp_lib STATIC ${SRC_CPP})
  add_executable(prog ${SRC_MAIN})
  target_link_libraries(prog funcc_lib funccpp_lib)
  </code></pre>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include "funccpp.h"
  
  int main() {
      FuncCPP();
      return 0;
  }
  </code></pre>
  
  <p><strong>funccpp.h</strong></p>
  
  <pre><code>#ifndef FUNCCPP_H
  #define FUNCCPP_H
  
  void FuncCPP();
  
  #endif
  </code></pre>
  
  <p><strong>funccpp.cpp</strong></p>
  
  <pre><code>#include "funcc.h"
  
  void FuncCPP() {
      FuncC();
  }
  </code></pre>
  
  <p><strong>funcc.h</strong></p>
  
  <pre><code>#ifndef FUNCC_H
  #define FUNCC_H
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  void FuncC();
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif // FUNCC_H
  </code></pre>
  
  <p><strong>funcc.c</strong></p>
  
  <pre><code>#include "funcc.h"
  #include &lt;stdio.h&gt;
  
  void FuncC() {
      printf("Hello, World!\n");
  }
  </code></pre>