title: Compiling nginx using CLion (via CMake)
body: <p>I'm trying to compile <a href="https://github.com/nginx/nginx/tree/release-1.9.5" rel="nofollow noreferrer">nginx 1.9.5</a> via CLion for debugging purposes.</p>
  
  <p>Because CLion doesn't currently support vanilla Makefiles/Autoconf I ran the autoconf <code>auto/configure</code> script to generate a valid Makefile, opened the project in CLion, then made a very simple <code>CMakeLists.txt</code> to delegate the CLion build to the autoconf generated <code>Makefile</code> (as advised by <a href="https://stackoverflow.com/questions/26918459/using-local-makefile-for-clion-instead-of-cmake">Using local makefile for CLion instead of CMake</a>).</p>
  
  <p>Unfortunately, my simple <code>CMakeLists.txt</code> seems to have a flaw, as when I reload and run CLion's build command, CMake seems to generate yet a new Makefile and run this empty Make task instead of running the one in ${nginx_SOURCE_DIR}.</p>
  
  <p>How can I change the CMakeLists.txt file below to delegate to the nginx Makefile instead of regenerating a new one?</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.4)
  project(nginx)
  
  add_custom_target(nginx ALL COMMAND make -C ${nginx_SOURCE_DIR} CLION_EXE_DIR=${PROJECT_BINARY_DIR})
  </code></pre>