title: Excluding directory somewhere in file structure from cmake sourcefile list
body: <p>In any subdirectory of my project it shall be possible to create anywhere a directory called 'hide' and put some code files (.c, .cpp, .h, ...) inside. CMake shall ignore those files. How can I achieve this?
  Any proposals for a simple approach? Searched the net but could not find a solution.</p>
  <p>What I tried:</p>
  <h2>file &amp; glob</h2>
  <pre><code>file(GLOB_RECURSE SOURCE_FILES &quot;*.cpp&quot; &quot;*.c&quot;)
  file(GLOB_RECURSE REMOVE_SOURCES  
    &quot;*/hide/*&quot;
    &quot;${PROJECT_SOURCE_DIR}/CMakeFiles/*&quot;
    &quot;*main.c&quot;)
  file(GLOB_RECURSE REMOVE_SOURCES &quot;*/hide/*&quot;)
  list(REMOVE_ITEM SOURCE_FILES ${REMOVE_SOURCES})
  </code></pre>
  <p>The 2rd line works fine if the directory path is known (as for the 'CMakeFiles' directory) or if the file is known (as for the 'main.c' file). But it does not work if there are two '*' for a string. I can not find a simple solution for a directory which is located somewhere.</p>
  <h2>Regex</h2>
  <p>Then I tried with REGEX.</p>
  <pre><code>file(GLOB_RECURSE SOURCE_FILES &quot;*.cpp&quot; &quot;*.c&quot;)
  string(REGEX REPLACE &quot;;.*/hide/.*;&quot; &quot;;&quot; FOO ${SOURCE_FILES})
  </code></pre>
  <p>Because the source file list is separated by semicolon, the line above shall remove the string from one semicolon to the next in case it contained the string 'hide'.
  The expression seems to have a problem with the semicolon. Having any semicolon makes the command to find nothing.</p>
  <h2>foreach loop</h2>
  <p>I tried with some foreach loops, but could not achieve to get a list of all my 'hide'-directories.</p>