title: Adding files to source_group in CMake
body: <p>I am having an issue with CMake in which I cannot get my files to be added to folders/filters inside of Visual Studio.</p>
  
  <pre><code># Add folders to filters
  file(GLOB_RECURSE DATABASE_SRCS     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/database *.cpp *.h)
  file(GLOB_RECURSE LOG_SRCS          RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/log *.cpp *.h)
  file(GLOB_RECURSE NETWORK_SRCS      RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/network *.cpp *.h)
  file(GLOB_RECURSE THREADING_SRCS    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/threading *.cpp *.h)
  file(GLOB_RECURSE UTILS_SRCS        RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/utils *.cpp *.h)
  
  source_group(database   FILES ${DATABASE_SRCS})
  source_group(log        FILES ${LOG_SRCS})
  source_group(network    FILES ${NETWORK_SRCS})
  source_group(threading  FILES ${THREADING_SRCS})
  source_group(utils      FILES ${UTILS_SRCS})
  </code></pre>
  
  <p>An issue that might be causing this problem is that the <code>GLOB_RECURSE</code>'s return the files that are in <code>${CMAKE_CURRENT_SOURCE_DIR}</code> but relative to the <code>/database</code> (or whatever other directory).</p>
  
  <p>For example, there is a file in <code>database/</code> called <code>dbcore.cpp</code>. This file gets added to <code>DATABASE_SRCS</code> as <code>dbcore.cpp</code>, but files in the main directory (i.e. <code>${CMAKE_CURRENT_SOURCE_DIR}</code>) also get added, but have a path relative to <code>database/</code>, such as <code>../common.h</code>.</p>
  
  <p>Another issue may be that inside of the Visual Studio project the default "Header Files" and "Source Files" filters already exist.</p>
  
  <p>I am using CMake 2.8.6 and Visual Studio 11/2012.</p>