title: cmake CMAKE_C_COMPILER "is not a full path to an existing compiler tool"
body: <p>This is <strong>cmake</strong> related issue
  Trying to build the project, and had some problems with default <strong>clang-3.5</strong> on build machine, so installed <strong>clang-3.7</strong> there. Unfortunately it has no <strong>clang</strong> symlink, so i am forced to find it.</p>
  
  <p>Having these lines inside <strong>CMakeLists.txt</strong> file to detect clang and set it (i know this is not very good looking find code)</p>
  
  <pre><code># Complilers, NOTE: this section should be before the Project section
  find_program( CLANG_PATH clang )
  find_program( CLANGCXX_PATH clang++ )
  if(NOT CLANG_PATH AND NOT CLANGCXX_PATH)
      set (CLANG_SEARCH_PATH  "/usr/bin/")
      execute_process(COMMAND bash "-c" "ls ${CLANG_SEARCH_PATH} | grep -v clang++ | grep clang | head -1"
          OUTPUT_VARIABLE CLANG_FILE )
      execute_process(COMMAND bash "-c" "ls ${CLANG_SEARCH_PATH} | grep clang++ | head -1"
          OUTPUT_VARIABLE CLANGCXX_FILE )
      if(CLANG_FILE AND CLANGCXX_FILE)
          set(CLANG_PATH          "${CLANG_SEARCH_PATH}${CLANG_FILE}")
          set(CLANGCXX_PATH       "${CLANG_SEARCH_PATH}${CLANGCXX_FILE}")
          set(CMAKE_C_COMPILER    "${CLANG_PATH}")
          message(STATUS "The clang compiler discovered... ${CLANG_PATH}")
          set(CMAKE_CXX_COMPILER  "${CLANGCXX_PATH}")
          message(STATUS "The clang++ compiler discovered... ${CLANGCXX_PATH}")
      else()
          message(FATAL_ERROR "clang and clang++ were not found! Aborting...")
      endif()
  endif()
  </code></pre>
  
  <p>Build result is (the same for clang++)</p>
  
  <pre><code>-- The clang compiler discovered... /usr/bin/clang-3.7
  -- The clang++ compiler discovered... /usr/bin/clang++-3.7
  
  -- The C compiler identification is unknown
  -- The CXX compiler identification is unknown
  CMake Error at CMakeLists.txt:24 (project):
    The CMAKE_C_COMPILER:
  
      /usr/bin/clang-3.7
  
    is not a full path to an existing compiler tool.
  
    Tell CMake where to find the compiler by setting either the environment
    variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
    the compiler, or to the compiler name if it is in the PATH.
  </code></pre>
  
  <p>But the path seems to be correct.
  If i will set it just in a dummy way instead, like </p>
  
  <pre><code>set(CMAKE_C_COMPILER    "/usr/bin/clang-3.7")
  set(CMAKE_CXX_COMPILER  "/usr/bin/clang++-3.7")
  </code></pre>
  
  <p>it works </p>
  
  <pre><code>-- The C compiler identification is Clang 3.7.0
  -- The CXX compiler identification is Clang 3.7.0
  -- Check for working C compiler: /usr/bin/clang-3.7
  -- Check for working C compiler: /usr/bin/clang-3.7 -- works
  </code></pre>
  
  <p>PS: I saw this one <a href="https://stackoverflow.com/questions/45140273/cmake-c-compiler-is-not-a-full-path-to-an-existing-compiler-tool">CMAKE_C_COMPILER is not a full path to an existing compiler tool</a> however it was not very helpful. Left the same topic name though.</p>
  
  <p>UPD:</p>
  
  <pre><code>$cmake --version
  cmake version 3.6.2
  </code></pre>