<div dir="ltr"><div>thaks a lot.</div>
<div>i try to modify hadly the link.txt file of my exec and nothing worked.</div>
<div>when i add to the target libxsystemd, cmake fail to find it but when i add libxsystem, cmake choose itself the debug name of libxsystem (as it&#39;s a cmake target ) and now everythink rocks!!!!!!!!!!!!!!!!</div>
<div>&nbsp;</div>
<div>thanks again<br><br></div>
<div class="gmail_quote">2008/8/22 Yuri V. Timenkov <span dir="ltr">&lt;<a href="mailto:ytimenkov@parallels.com">ytimenkov@parallels.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="Wj3C7c">On Friday 22 August 2008 11:18:50 Ingrid Kemgoum wrote:<br>&gt; 2008/8/21 Yuri V. Timenkov &lt;<a href="mailto:ytimenkov@parallels.com">ytimenkov@parallels.com</a>&gt;<br>&gt;<br>&gt; &gt; On Thursday 21 August 2008 17:27:36 Ingrid Kemgoum wrote:<br>
&gt; &gt; &gt; HI,<br>&gt; &gt; &gt; i&#39;m building a project with 3 targets in Linux. each target has a<br>&gt; &gt;<br>&gt; &gt; different<br>&gt; &gt;<br>&gt; &gt; &gt; name when in debug.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; the executable i want to link to the 2 libraries fail to find thoz libs<br>
&gt; &gt; &gt; when i&#39;m in debug (not the case in release, everything&#39;s good).<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; here is the CMakeLists of the executable<br>&gt; &gt;<br>&gt; &gt; Very strange file, but...<br>&gt; &gt;<br>
&gt; &gt; &gt; cmake_minimum_required(VERSION 2.6)<br>&gt; &gt; &gt; include_directories (${ORIGIN}/tst_xsystem/../../../import/xdefaut/inc<br>&gt; &gt; &gt; ${ORIGIN}/tst_xsystem/../../../inc<br>&gt; &gt; &gt; ${ORIGIN}/tst_xsystem/../../../imports/xdefaut/inc )<br>
&gt; &gt; &gt; set(sources ${ORIGIN}/tst_xsystem/../../../src/tst_xsystem.c<br>&gt; &gt; &gt; ${ORIGIN}/tst_xsystem/../../../imports/xdefaut/inc/x_defaut.h)<br>&gt; &gt;<br>&gt; &gt; BTW: CMake defines ${CMAKE_SOURCE_DIR} and ${CMAKE_CURRENT_SOURCE_DIR}<br>
&gt; &gt; variables. I suppose they can be used instead of origin. The whole code<br>&gt; &gt; will<br>&gt; &gt; look cleaner...<br>&gt;<br>&gt; i know the existence of those variables. but in this case i can&#39;t use them.<br>
&gt; i&#39;m building a triple out-of-source project. The project files are in<br>&gt; ${ORIGIN}, the cmake files are in a different directory and the binaries<br>&gt; anf libraries obtained are in an order directory.<br>
&gt; i can&#39;t do it differently, it&#39;s how the enterprise want it to be.<br></div></div>Yes, it&#39;s bad and I&#39;m aware of such cases. I&#39;m happy that I convinced my<br>management to use full advantages of cmake build process and completely drop<br>
Makefiles and vcproj&#39;s from CVS.<br>
<div>
<div></div>
<div class="Wj3C7c"><br>&gt;<br>&gt; &gt; &gt; if (CMAKE_HOST_WIN32)<br>&gt; &gt; &gt; &nbsp; set (sources ${sources} ${ORIGIN}/tst_xsystem/tst_xsystem.rc)<br>&gt; &gt; &gt; endif(CMAKE_HOST_WIN32)<br>&gt; &gt; &gt; if (CMAKE_HOST_UNIX)<br>
&gt; &gt; &gt; &nbsp; set (sources ${sources} ${DEST}/tst_xsystem/tst_xsystem.c)<br>&gt; &gt; &gt; endif(CMAKE_HOST_UNIX)<br>&gt; &gt; &gt; add_executable(tst_xsystem ${sources})<br>&gt; &gt; &gt; add_dependencies(tst_xsystem &nbsp;libxsystem libxsystem_so)<br>
&gt; &gt;<br>&gt; &gt; I&#39;m not sure if this works for not cmake targets.<br>&gt;<br>&gt; They are cmake targets so it works<br>&gt;<br>&gt; &gt; &gt; if (${CONFIG} MATCHES &quot;DEBUG&quot;)<br>&gt; &gt; &gt; &nbsp;target_link_libraries(tst_xsystem libxsystemd_so libxsystemd pthread<br>
&gt; &gt; &gt; rt<br>&gt; &gt;<br>&gt; &gt; dl<br>&gt; &gt;<br>&gt; &gt; &gt; nsl) ###########&quot;<br>&gt; &gt; &gt; else(${CONFIG} MATCHES &quot;DEBUG&quot;)<br>&gt; &gt; &gt; &nbsp;target_link_libraries(tst_xsystem libxsystem_so libxsystem pthread rt<br>
&gt; &gt; &gt; dl nsl)<br>&gt; &gt; &gt; endif(${CONFIG} MATCHES &quot;DEBUG&quot;)<br>&gt; &gt;<br>&gt; &gt; Why not use following instead:<br>&gt; &gt; set(libxsystm_LIBS debug libxsystemd optimized libxsystem)<br>&gt; &gt; set(libxsystem_so_LIBS debug libxsystemd_so optimized libxsystem_so)<br>
&gt; &gt; target_link_libraries(tst_xsystem libxsystem_so<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;${libxsystm_LIBS}<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;${libxsystem_so_LIBS}<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;pthread rt dl)<br>&gt; &gt;<br>&gt; &gt; Using ${CONFIG} is not portable, it will not work in generators, which<br>
&gt; &gt; support<br>&gt; &gt; multiple configurations.<br>&gt;<br>&gt; i&#39;ve taken it into account thanks (but no changes)<br>&gt;<br>&gt; &gt; &gt; set_target_properties(tst_xsystem PROPERTIES<br>&gt; &gt; &gt; &nbsp;PREFIX &quot;&quot;<br>
&gt; &gt; &gt; &nbsp;DEBUG_OUTPUT_NAME &quot;tst_xsystemd&quot;<br>&gt; &gt; &gt; &nbsp;LINKER_LANGUAGE &quot;CXX&quot;<br>&gt; &gt; &gt; &nbsp;LINK_FLAGS_RELEASE ${linkexecutablerel}<br>&gt; &gt; &gt; )<br>&gt; &gt;<br>&gt; &gt; Why not use DEBUG_POSTFIX &quot;d&quot;?<br>
&gt;<br>&gt; i can&#39;t use the postfix because the naming system of the company is not<br>&gt; that simple. postfix will work for executables and static libs but shared<br>&gt; ones are named lib_so and the debug name libd_so<br>
&gt;<br>&gt; &gt; &gt; the problem is in the red line (marqued ########).<br>&gt; &gt; &gt; names are differents and the error is<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Linking CXX executable<br>&gt; &gt;<br>&gt; &gt; /home/ikemgoum/workspace/reference/xsystem/code/os/linux_redhatEL4_0_i386<br>
&gt; &gt;__<br>&gt; &gt;<br>&gt; &gt; &gt;gcc3_4/bin/tst_xsystemd /usr/bin/ld: can not find -llibxsystemd<br>&gt; &gt;<br>&gt; &gt; If libxsystemd is a target generated by cmake in the same project, you<br>&gt; &gt; don&#39;t<br>
&gt; &gt; need to bother with release/debug switches at all (I suppose).<br>&gt;<br>&gt; it is what i supposed to but obviously it&#39;s not. libxsystem is a cmake<br>&gt; target, static lib, and it&#39;s debug output name is libxsystemd<br>
&gt;<br>&gt; &gt; Next, your library should be named liblibxsystemd.so if you use<br>&gt; &gt; DEBUG_OUTPUT_NAME you may break CMake rules which generate proper library<br>&gt; &gt; name.<br>&gt;<br>&gt; i dont know how but this works in windows!! the debug name is found. i try<br>
&gt; to add the cmake_library_path with the path of the output lib path but no<br>&gt; changes.<br>&gt; i still have the same problem.<br></div></div>Compare output names of debug and release. Do your debug library generated at<br>
all? The following makefile works in my case:<br><br>project(test)<br><br>set(BUILD_SHARED_LIBS OFF)<br><br>add_library(mylib mylib.cpp)<br>target_link_libraries(mylib dl)<br>set_target_properties(mylib PROPERTIES DEBUG_OUTPUT_NAME &quot;libsystemd&quot;)<br>
<br>add_executable(myapp myapp.cpp)<br>target_link_libraries(myapp ${myapp_LIBS})<br><br>cmake -DCMAKE_BUILD_TYPE=debug ..<br>=(%:~/test/build)=- make<br>[ 50%] Building CXX object CMakeFiles/mylib.dir/mylib.o<br>Linking CXX static library liblibsystemd.a<br>
[ 50%] Built target mylib<br>[100%] Building CXX object CMakeFiles/myapp.dir/myapp.o<br>Linking CXX executable myapp<br>[100%] Built target myapp<br>And the myapp generated with command line:<br><br>/usr/bin/c++ &nbsp; -g &nbsp; CMakeFiles/myapp.dir/myapp.o &nbsp;-o myapp -rdynamic -<br>
L/home/ytimenkov/test/build liblibsystemd.a -ldl<br><br>Note, that cmake uses full paths (not -l notation).<br>
<div>
<div></div>
<div class="Wj3C7c">&gt;<br>&gt; if you have any idea thanks for help, very much.<br>&gt;<br>&gt; &gt; &gt; am i missing something?<br>&gt; &gt;<br>&gt; &gt; Too many places where the problem could be. But looking at your code, I<br>
&gt; &gt; can say that you try to use CMake in wrong way. While used properly,<br>&gt; &gt; cmake makes<br>&gt; &gt; many things much simpler.<br>&gt; &gt;<br>&gt; &gt; &gt; thanks for help<br><br></div></div></blockquote>
</div><br></div>