title: Understanding roles of CMake, make and GCC
body: <p><strong>1.</strong> <code>cmake</code> is a command from CMake software: preparation for build automation system; make and make install are commands from Make software: build automation system.</p>
  
  <p><strong>2.</strong> From reading this <a href="https://stackoverflow.com/questions/12475056/how-does-cmake-choose-gcc-and-g-for-compiling">post</a>, what I understand is that:</p>
  
  <p><strong>a.</strong> This "cmake and make" stuffs actually use g++ / gcc in its implementation. cmake and make stuffs are basically just tools in using g++ / gcc. Is that correct?</p>
  
  <p><strong>b.</strong> gcc / g++ are the compiler that do the actual work.</p>
  
  <p><strong>c.</strong> So I can just use gcc / g++ directly without using the make and CMake things?</p>
  
  <p><strong>3.</strong>  According to this stackoverflow <a href="https://stackoverflow.com/questions/7859623/how-do-i-use-cmake/7859663#7859663">answer</a>: CMake takes a CMakeList.txt file, and outputs it to a platform-specific build format, e.g.,  a Makefile, Visual Studio, etc.</p>
  
  <p>However when I came across <a href="http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation" rel="noreferrer">this</a> openCV installation :</p>
  
  <pre><code>mkdir release
  cd release
  cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  </code></pre>
  
  <p>It executes cmake command in a directory where there is no CMakeLists.txt file. Can you explain and elaborate on this?</p>
  
  <p><strong>4.</strong> The usual steps that I've seen are: <code>cmake</code>, <code>make</code>, <code>sudo make install</code>.
  I read this stackoverflow <a href="https://stackoverflow.com/questions/16637860/why-make-before-make-install">post</a>, what I understand:</p>
  
  <p><strong>(i)</strong> <code>make</code> is for building the project. </p>
  
  <p><strong>(ii)</strong> <code>make install</code> is to copy the binary / executables to the installed directories.</p>
  
  <p><strong>a.</strong> So when we <code>make</code>, where are the result / binary files / executables stored at?</p>
  
  <p><strong>b.</strong> If we only run <code>make</code> without <code>make install</code>, does it mean that the files are not generated?</p>
  
  <p><strong>c.</strong> I came across this openCV <a href="http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage" rel="noreferrer">tutorial</a> on using openCV with GCC and CMake. It uses:</p>
  
  <pre><code>cd &lt;DisplayImage_directory&gt;
  cmake .
  make
  </code></pre>
  
  <p>Why doesn't it do <code>make install</code> as well?</p>
  
  <p><strong>5.</strong> In summary:</p>
  
  <ul>
  <li><p>CMake takes CMakeList.txt file (which is cross platform) to generate a Makefile (which is specific to a platform).</p></li>
  <li><p>I can just write Makefile manually and skip the CMake step. but it is better to do with the CMake step because it is cross platform, otherwise I have to rewrite the Makefile again if I change platform.</p></li>
  <li><p>Make takes Makefile (which is generated by CMake or written manually) as a guide to compile and build. Make basically uses gcc / g++ or other compiler in its work. Make itself is just a tool for the compiler.</p></li>
  <li><p>Make install put the result / executables into the install path</p></li>
  </ul>