title: run Cmake and make in parent directory
body: <p>I have a project which is in parent directory a. The script runs the executables in 3 different subdirectories. Example below:</p>
  
  <pre><code>      A
      / | \
     B  C  D
  </code></pre>
  
  <p>Now, I would like to compile the cpp files in B, C, and D using a scrpit from A.</p>
  
  <p>So far, in my script, I remove all the old CMakeCache.txt and Makefile files and the CMakeFiles directory to make sure there is no overlap.</p>
  
  <p>THen I run <code>cmake B/</code> followed by <code>make -C B/</code>. I do this for each subdirectory. But I get an error saying <code>CMake Error: The source "/home/ybouvron/Documents/A/B/CMakeLists.txt" does not match the source "/home/ybouvron/Documents/A/C/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.</code></p>
  
  <p>Why am I getting this and how to I fix it? Seems like it's trying to compile the two as the same project, but in each of the CMakeLists.txt files in the subdirectories, they have different project names and executable names. </p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>#! /bin/bash
  
  echo Deleting old make files
  
  rm B/CMakeCache.txt
  rm -r B/CMakeFiles/
  rm B/Makefile
  
  rm C/CMakeCache.txt
  rm -r C/CMakeFiles/
  rm C/Makefile
  
  rm D/CMakeCache.txt
  rm -r D/CMakeFiles/
  rm D/Makefile
  
  set -e
  
  echo Compiling subsystems...
  cmake B
  make -C B
  
  cmake C/
  make -C C/ 
  
  cmake D/
  make -C D/
  </code></pre>