title: Linking freetype with cmake
body: <p>I'm having troubles with linking <code>freetype 2</code> under linux using <code>cmake</code> when building a C++11 project with an <code>extern C</code> library.</p>
  
  <p>With cmake and freetype 2 I basically have 2 options :</p>
  
  <ul>
  <li>use the utility <code>freetype-config</code> like <code>freetype-config --libs</code></li>
  <li>use the <code>FindFreetype</code> <a href="http://www.cmake.org/Wiki/CMake_2.6.0_Docs" rel="noreferrer">cmake module</a></li>
  </ul>
  
  <p>Now I'm trying to implement the second option and I'm not very skilled with <code>cmake</code> nor I understand the logic of it.</p>
  
  <p>My problem is the linking phase, I have no idea how to do that properly plus this module is not as complete as the result of <code>freetype-config --libs</code> which really includes all the libraries and flags that I need, and not just the path of a file; so I'm assuming that I have to do the same for <code>zlib</code> and <code>libpng</code>.</p>
  
  <p><code>CMakeLists.txt</code></p>
  
  <pre><code>cmake_minimum_required (VERSION 2.6)
  project (FreetypeTutorials1)
  
  include(FindFreetype)
  include_directories(${FREETYPE_INCLUDE_DIRS})
  
  SET(CMAKE_CXX_FLAGS "-O2 -std=c++11")
  
  SET(CMAKE_EXE_LINKER_FLAGS "-v -lfreetype")
  
  add_executable( demo "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
  </code></pre>
  
  <p><code>./src/main.cpp</code> ( just some random code so I have something to feed to the compiler )</p>
  
  <pre><code>extern "C" {
  #include &lt;ft2build.h&gt;
  #include FT_FREETYPE_H
  }
  #include &lt;iostream&gt;
  int main()
  {
    FT_Library library;
    auto error = FT_Init_FreeType(&amp;library);
    if (error)
    {
      std::cout &lt;&lt; "An error !\n";
    }
  }
  </code></pre>