<div dir="ltr"><br><br>
<div class="gmail_quote">2008/8/21 Yuri V. Timenkov <span dir="ltr"><<a href="mailto:ytimenkov@parallels.com">ytimenkov@parallels.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="Ih2E3d">On Thursday 21 August 2008 17:27:36 Ingrid Kemgoum wrote:<br>> HI,<br>> i'm building a project with 3 targets in Linux. each target has a different<br>> name when in debug.<br>><br>> the executable i want to link to the 2 libraries fail to find thoz libs<br>
> when i'm in debug (not the case in release, everything's good).<br>><br>> here is the CMakeLists of the executable<br>><br></div>Very strange file, but...<br>
<div class="Ih2E3d">><br>> cmake_minimum_required(VERSION 2.6)<br>> include_directories (${ORIGIN}/tst_xsystem/../../../import/xdefaut/inc<br>> ${ORIGIN}/tst_xsystem/../../../inc<br>> ${ORIGIN}/tst_xsystem/../../../imports/xdefaut/inc )<br>
> set(sources ${ORIGIN}/tst_xsystem/../../../src/tst_xsystem.c<br>> ${ORIGIN}/tst_xsystem/../../../imports/xdefaut/inc/x_defaut.h)<br></div>BTW: CMake defines ${CMAKE_SOURCE_DIR} and ${CMAKE_CURRENT_SOURCE_DIR}<br>variables. I suppose they can be used instead of origin. The whole code will<br>
look cleaner...</blockquote>
<div> </div>
<div><font color="#cc0000">i know the existence of those variables. but in this case i can't use them. i'm building a triple out-of-source project. The project files are in ${ORIGIN}, the cmake files are in a different directory and the binaries anf libraries obtained are in an order directory.</font></div>
<div><font color="#cc0000">i can't do it differently, it's how the enterprise want it to be.</font></div>
<div> </div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>
<div class="Ih2E3d"><br>> if (CMAKE_HOST_WIN32)<br>> set (sources ${sources} ${ORIGIN}/tst_xsystem/tst_xsystem.rc)<br>> endif(CMAKE_HOST_WIN32)<br>> if (CMAKE_HOST_UNIX)<br>> set (sources ${sources} ${DEST}/tst_xsystem/tst_xsystem.c)<br>
> endif(CMAKE_HOST_UNIX)<br>> add_executable(tst_xsystem ${sources})<br>> add_dependencies(tst_xsystem libxsystem libxsystem_so)<br></div>I'm not sure if this works for not cmake targets.</blockquote>
<div><font color="#cc0000">They are cmake targets so it works</font></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>
<div class="Ih2E3d">><br>><br>> if (${CONFIG} MATCHES "DEBUG")<br>> target_link_libraries(tst_xsystem libxsystemd_so libxsystemd pthread rt dl<br>> nsl) ###########"<br>> else(${CONFIG} MATCHES "DEBUG")<br>
> target_link_libraries(tst_xsystem libxsystem_so libxsystem pthread rt dl<br>> nsl)<br>> endif(${CONFIG} MATCHES "DEBUG")<br></div>Why not use following instead:<br>set(libxsystm_LIBS debug libxsystemd optimized libxsystem)<br>
set(libxsystem_so_LIBS debug libxsystemd_so optimized libxsystem_so)<br>
<div class="Ih2E3d">target_link_libraries(tst_xsystem libxsystem_so<br></div> ${libxsystm_LIBS}<br> ${libxsystem_so_LIBS}<br> pthread rt dl)<br><br>Using ${CONFIG} is not portable, it will not work in generators, which support<br>
multiple configurations.</blockquote>
<div> </div>
<div> </div>
<div><font color="#cc0000">i've taken it into account thanks (but no changes)</font></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>
<div class="Ih2E3d"><br>> set_target_properties(tst_xsystem PROPERTIES<br>> PREFIX ""<br>> DEBUG_OUTPUT_NAME "tst_xsystemd"<br>> LINKER_LANGUAGE "CXX"<br>> LINK_FLAGS_RELEASE ${linkexecutablerel}<br>
> )<br></div>Why not use DEBUG_POSTFIX "d"?</blockquote>
<div> </div>
<div><font color="#cc0000">i can't use the postfix because the naming system of the company is not that simple. postfix will work for executables and static libs but shared ones are named lib_so and the debug name libd_so</font></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span>
<div class="Ih2E3d"><br>><br>><br>> the problem is in the red line (marqued ########).<br>> names are differents and the error is<br>><br>> Linking CXX executable<br>> /home/ikemgoum/workspace/reference/xsystem/code/os/linux_redhatEL4_0_i386__<br>
>gcc3_4/bin/tst_xsystemd /usr/bin/ld: can not find -llibxsystemd<br></div>If libxsystemd is a target generated by cmake in the same project, you don't<br>need to bother with release/debug switches at all (I suppose).</blockquote>
<div> </div>
<div><font color="#cc0000">it is what i supposed to but obviously it's not. libxsystem is a cmake target, static lib, and it's debug output name is libxsystemd</font></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>Next, your library should be named liblibxsystemd.so if you use<br>DEBUG_OUTPUT_NAME you may break CMake rules which generate proper library<br>
name.</blockquote>
<div> </div>
<div><font color="#cc0000">i dont know how but this works in windows!! the debug name is found. i try to add the cmake_library_path with the path of the output lib path but no changes.</font></div>
<div><font color="#cc0000">i still have the same problem. </font></div>
<div><font color="#cc0000"></font> </div>
<div><font color="#cc0000">if you have any idea thanks for help, very much.</font></div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>><br>> am i missing something?<br>Too many places where the problem could be. But looking at your code, I can<br>
say that you try to use CMake in wrong way. While used properly, cmake makes<br>many things much simpler.<br>> thanks for help<br><br></blockquote></div><br></div>