title: How to separate header file and source file in CMake?
body: <p>My project is in the structure as follows:</p>
  
  <pre><code>--root: main.cpp CMakeLists.txt 
  
      --src: function.cpp CMakeLists.txt 
  
      --include: function.h
  </code></pre>
  
  <hr>
  
  <p>main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "function.h"
  using namespace std;
  
  int main(int argc, char *argv[])
  {
      //call module in function.hpp
      return 0;
  }
  </code></pre>
  
  <p>CMakeLists.txt in root directory:</p>
  
  <pre><code> project(t1)
   cmake_minimum_required(VERSION 2.8)
   add_subdirectory(src)               
   file(GLOB_RECURSE SOURCES
       include/function.h
       src/function.cpp)            
   add_executable(${PROJECT_NAME} ${SOURCES})
  </code></pre>
  
  <p>CmakeLists.txt in src directory:</p>
  
  <pre><code>include_directories(${PROJECT_SOURCE_DIR}/include)
  </code></pre>
  
  <p>How to write CMakelists in the root and src directory to realize separate implementation of function? And further more, how to call them in main. Possible solutions in <a href="https://stackoverflow.com/questions/26937085/cmake-not-finding-proper-header-include-files-in-include-directories">CMake not finding proper header/include files in include_directories</a>. But it still doesn't match my situations.</p>