<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/xxxx//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>