<div dir="ltr">Hi, <div><br></div><div>I just want to confirm that I have the same problem on Windows with the Ninja generator. Even when I always use both keywords (debug & optimized) in my <b>target_link_libraries </b>commands I still <span style="font-size:12.8px">got a </span><b style="font-size:12.8px">ninja.build </b><span style="font-size:12.8px">file that has bad $-escape characters.</span></div><div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I think that this problem is happening only when I tried to compile a library twice (shared and static) and I tried to propagate the <b>LINK_LIBRARIES</b> property from the shared library to the static one:</div><div style="font-size:12.8px"><br></div><div><div style="font-size:12.8px">        add_library(mylib SHARED ${<span style="font-size:12.8px">mylib</span>_all_sources})</div><div style="font-size:12.8px">        add_library(<span style="font-size:12.8px">mylib</span>_static STATIC EXCLUDE_FROM_ALL ${<span style="font-size:12.8px">mylib</span>_all_sources})</div><div style="font-size:12.8px"><br></div><div><div><span style="font-size:12.8px">        target_link_libraries(mylib PUBLIC ${SOME_LIBS})</span></div></div><div><div><span style="font-size:12.8px">        target_link_libraries(mylib_static PUBLIC $<TARGET_PROPERTY:mylib,LINK_LIBRARIES>)</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Only in that situation is when I got the weird bad $-escape characters on the ninja.build file. This is an example of the line with these problems:</span></div><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px">  LINK_LIBRARIES = C:\myProject\buildRelease\bin64\library1.lib</span></div><div><span style="font-size:12.8px">  C:\myProject\buildRelease\bin64\library2.lib </span></div><div><span style="font-size:12.8px">  C:\myProject\libs\gmock.lib</span></div><div><span style="font-size:12.8px">  C:\myProject\libs\CGAL-vc120-mt-4.4.lib </span></div><div><span style="font-size:12.8px">  C:\myProject\libs\exiv2.lib </span></div><div><span style="font-size:12.8px">  C:\myProject\libs\ceres.lib</span></div><div><span style="font-size:12.8px">  ... // removing some lines</span></div><div><span style="font-size:12.8px">  $<$<NOT:$<CONFIG:DEBUG>>:C:/myProject\libs/CGAL-vc120-mt-4.4.lib></span></div><div><span style="font-size:12.8px">  $<$<CONFIG:DEBUG>:C:/myProject\libs/CGAL-vc120-mt-gd-4.4.lib> </span></div><div><span style="font-size:12.8px">  ... // removing some lines</span></div><div><span style="font-size:12.8px">  $<$<NOT:$<CONFIG:DEBUG>>:C:/myProject\libs/exiv2.lib></span></div><div><span style="font-size:12.8px">  $<$<CONFIG:DEBUG>:C:/myProject\libs/exiv2d.lib></span></div><div><span style="font-size:12.8px">  $<$<NOT:$<CONFIG:DEBUG>>:C:/myProject\libs/ceres.lib></span></div><div><span style="font-size:12.8px">  $<$<CONFIG:DEBUG>:C:/myProject\libs/ceres-debug.lib></span></div><div><span style="font-size:12.8px">  ...</span></div><div><span style="font-size:12.8px">  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib</span></div><div style="font-size:12.8px"><br></div></div><div style="font-size:12.8px">I will try to create a minimum example to reproduce this issue.</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Cheers,</div><div style="font-size:12.8px">Luis</div><div style="font-size:12.8px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-10-05 16:39 GMT+02:00 Luis Díaz Más <span dir="ltr"><<a href="mailto:piponazo@gmail.com" target="_blank">piponazo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div><br></div><div>I have found a problem while configuring a project and I want to share the experience with you to figure out whether it is a known problem or a bug in CMake.</div><div><br></div><div>In some cases I use the cmake command <b>target_link_libraries </b>specifying different libraries for the <i>debug</i> and <i>optimized</i> modes. This normally work as expected. However recently we got a problem with the Ninja generator. This is what I could see in the console when I try to compile the project:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>ninja: error: build.ninja:4956: bad $-escape (literal $ must be written as $$)</div></blockquote><div><br></div><div>The content of the file in that particular line has something like this:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>$<$<CONFIG:DEBUG>:/home/luis/x<wbr>xxx//lib/libCGAL.so></div><div><br></div></blockquote>Examining my cmake configuration I noticed that a colleague introduced something like that in the <b>target_link_libraries</b> call:</div><div><br></div><div><div>            ${ZLIB_LIBRARIES}</div><div>            debug;${CGAL_LIB}</div><div>            ${GMP_LIB}</div></div><div><br></div><div>If we specify the debug & optimized modes we do not have problems. However in this particular case, it seems that we only need to link against the CGAL in debug mode and not in release mode. Note that with a Make generator we can compile normally the project. </div><div><br></div><div>The work around for this case is to link normally against CGAL when we are in Debug mode:</div><div><br></div><div><div>        if (${CMAKE_BUILD_TYPE} STREQUAL Debug)</div><div>            target_link_libraries(myTarget ${CGAL_LIB}</div><div>        endif()</div></div><div><br></div><div>So ... the questions are:</div><div><br></div><div><ul><li>Is it possible to use <b>target_link_libraries </b>only with one of the modes (debug  / optimized) ? </li><li>The Make generator works properly for this case. Could it be a bug with the Ninja generator? I tried with the most recent versions of CMake & Ninja.</li></ul><div>Best regards,</div><div>Luis Diaz Mas</div></div></div>
</blockquote></div><br></div></div></div>