title: CMake how to set the build directory to be different than source directory
body: <p>I'm pretty new to CMake, and read a few tutorials on how to use it, and wrote some complicated 50 lines of CMake script in order to make a program for 3 different compilers. This probably concludes all my knowledge in CMake.</p>
  
  <p>Now my problem is that I have some source code, whose folder I don't want to touch/mess with when I make the program. I want that all CMake and <code>make</code> output files and folders to go into <code>../Compile/</code>, so I changed a few variables in my CMake script for that, and it worked for sometime when I did something like this on my laptop:</p>
  
  <pre><code>Compile$ cmake ../src
  Compile$ make
  </code></pre>
  
  <p>Where with that I had a clean output in the folder I'm in right now, which is exactly what I'm looking for.</p>
  
  <p>Now I moved to another computer, and recompiled CMake 2.8.11.2, and I'm almost back to square one! It always compiles the thing into the <code>src</code> folder where my <code>CMakeLists.txt</code> is located.</p>
  
  <p>The part where I choose the directory in my CMake script is this:</p>
  
  <pre><code>set(dir ${CMAKE_CURRENT_SOURCE_DIR}/../Compile/)
  set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
  set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${dir})
  set(CMAKE_BUILD_FILES_DIRECTORY ${dir})
  set(CMAKE_BUILD_DIRECTORY ${dir})
  set(CMAKE_BINARY_DIR  ${dir})
  SET(EXECUTABLE_OUTPUT_PATH ${dir})
  SET(LIBRARY_OUTPUT_PATH ${dir}lib)
  SET(CMAKE_CACHEFILE_DIR ${dir})
  </code></pre>
  
  <p>And now it always ends with:</p>
  
  <pre><code>-- Build files have been written to: /.../src
  </code></pre>
  
  <p>Am I missing something?</p>