<div dir="ltr">Hi,<div>TL;DR: The project compiles fine first time, but after touching a source file to trigger a recompile, the recompilation fails with a large list of errors.</div><div><br></div><div>To reproduce this must be done:</div><div><br></div><div>1) Have <span style="color:rgb(128,128,0)">set</span>(<span style="color:rgb(192,144,80)">CMAKE_INCLUDE_CURRENT_DIR</span><span style="color:rgb(192,192,192)"> </span>ON)</div><div>2) call your executable "list"</div><div>3) #include <list> anywhere in your project or include a system/library header that #includes <list></div><div><br></div><div>My own example, folder names have nothing to do with the bug:</div><div>[-] Blink</div><div>    CMakeLists.txt</div><div>    [-]blink</div><div>        main.cpp</div><div>        CMakeLists.txt</div><div><br></div><div>Top CMakeLists.txt content:</div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">cmake_minimum_required</span>(<span style="font-family:Inconsolata;font-size:14pt;color:rgb(0,0,0)">VERSION</span><span style="color:rgb(192,192,192)"> </span>2.8.12)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">Project</span>(Blink)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">add_subdirectory</span>(blink)</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">The other CMakeLists.txt file:</pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><font color="#808000">set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(list main.cpp)</font><br></pre><pre style="margin-top:0px;margin-bottom:0px"><font color="#808000"><br></font></pre><pre style="margin-top:0px;margin-bottom:0px"><font color="#808000">main.cpp:</font></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><cstdio></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><list></span></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">int </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">main</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">(</span><span style="font-family:arial,sans-serif;color:rgb(128,128,0)">int</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">argc</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">,</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(128,128,0)">char</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">*</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">argv</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">[])</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">{</span></pre><pre style="margin-top:0px;margin-bottom:0px">    printf<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,128,0)">"Hello,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">world\n"</span><span style="color:rgb(0,0,0)">);</span></pre><pre style="margin-top:0px;margin-bottom:0px"><font color="#c0c0c0">    </font><span style="color:rgb(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">;</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">}</span></pre></pre><pre style="margin-top:0px;margin-bottom:0px"></pre></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">The project will compile, but if main.cpp gets touched the recompilation will fail.</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">Using Ubuntu 16.04, cmake version 3.5.1, any compiler (gcc/clang)</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">And here's the sample output of a failed compilation (the first umpteen lines):</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">build$ make
Scanning dependencies of target list
make[2]: Circular blink/CMakeFiles/list.dir/main.cpp.o <- blink/list dependency dropped.
[ 50%] Building CXX object blink/CMakeFiles/list.dir/main.cpp.o
In file included from /media/data/docs/dev/Blink/blink/main.cpp:2:0:
/media/data/docs/dev/Blink/build/blink/list:1:1: error: stray ‘\177’ in program
 ELF              >     � @     @       �           @ 8   @            @      
 ^
/media/data/docs/dev/Blink/build/blink/list:1:1: error: stray ‘\2’ in program
/media/data/docs/dev/Blink/build/blink/list:1:1: error: stray ‘\1’ in program
/media/data/docs/dev/Blink/build/blink/list:1:1: error: stray ‘\1’ in program
/media/data/docs/dev/Blink/build/blink/list:1:8: warning: null character(s) ignored
 ELF              >     � @     @       �           @ 8   @            @      
        ^</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">Plus lots and lots of lines, and ends with:</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif">/media/data/docs/dev/Blink/build/blink/list:1:2: error: ‘ELF’ does not name a type</span><br></pre><pre style="margin-top:0px;margin-bottom:0px"> ELF              >     � @     @       �           @ 8   @            @      
  ^
/media/data/docs/dev/Blink/build/blink/list:1:651: error: ‘N’ does not name a type
 x-x86-64.so.2             GNU                             GNU  �נ.;N�)��S�  cQ
                                                                     ^
blink/CMakeFiles/list.dir/build.make:62: recipe for target 'blink/CMakeFiles/list.dir/main.cpp.o' failed
make[2]: *** [blink/CMakeFiles/list.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'blink/CMakeFiles/list.dir/all' failed
make[1]: *** [blink/CMakeFiles/list.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2<br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre></div><div><br></div>
</div>