title: Setting CMAKE_INSTALL_PREFIX from CMakeLists.txt file
body: <p>How do I set CMAKE_INSTALL_PREFIX in my root CMakeLists.txt file?</p>
  
  <p>I have been doing</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  project(MyProject)
  
  # Set default install prefix
  set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
  </code></pre>
  
  <p>with the hopes that by installations would be destined to folders in the source tree. That is,</p>
  
  <pre><code>install(TARGETS my_exe DESTINATION bin/)
  </code></pre>
  
  <p>would install to <code>${CMAKE_SOURCE_DIR}/bin/</code>. Instead, it keeps trying to write to <code>/usr/local/bin</code> (the default for Ubuntu 14.04).</p>
  
  <p>I tried the answers to <a href="https://stackoverflow.com/questions/6241922/how-to-use-cmake-install-prefix">this question</a>, but I still get the standard <code>usr/local/</code> as my CMAKE_INSTALL_PREFIX when I check CMakeCache.txt.</p>
  
  <p>The only working solution I have is to do</p>
  
  <pre><code>install(TARGETS my_exe DESTINATION "${CMAKE_SOURCE_DIR}/bin/")
  </code></pre>
  
  <p>but this then removes the user's ability to specify where the bin directory to install is.</p>
  
  <p>tl;dr I would like <code>make install</code> to automatically install to <code>${CMAKE_SOURCE_DIR}</code> by default, rather than <code>/usr/local/</code>.</p>