<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's a cmake target ) and now everythink rocks!!!!!!!!!!!!!!!!</div>
<div> </div>
<div>thanks again<br><br></div>
<div class="gmail_quote">2008/8/22 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>
<div></div>
<div class="Wj3C7c">On Friday 22 August 2008 11:18:50 Ingrid Kemgoum wrote:<br>> 2008/8/21 Yuri V. Timenkov <<a href="mailto:ytimenkov@parallels.com">ytimenkov@parallels.com</a>><br>><br>> > 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<br>> ><br>> > different<br>> ><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>> > Very strange file, but...<br>> ><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>> ><br>> > 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<br>> > will<br>> > look cleaner...<br>><br>> i know the existence of those variables. but in this case i can't use them.<br>
> i'm building a triple out-of-source project. The project files are in<br>> ${ORIGIN}, the cmake files are in a different directory and the binaries<br>> anf libraries obtained are in an order directory.<br>
> i can't do it differently, it's how the enterprise want it to be.<br></div></div>Yes, it's bad and I'm aware of such cases. I'm happy that I convinced my<br>management to use full advantages of cmake build process and completely drop<br>
Makefiles and vcproj's from CVS.<br>
<div>
<div></div>
<div class="Wj3C7c"><br>><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>
> ><br>> > I'm not sure if this works for not cmake targets.<br>><br>> They are cmake targets so it works<br>><br>> > > if (${CONFIG} MATCHES "DEBUG")<br>> > > target_link_libraries(tst_xsystem libxsystemd_so libxsystemd pthread<br>
> > > rt<br>> ><br>> > dl<br>> ><br>> > > nsl) ###########"<br>> > > else(${CONFIG} MATCHES "DEBUG")<br>> > > target_link_libraries(tst_xsystem libxsystem_so libxsystem pthread rt<br>
> > > dl nsl)<br>> > > endif(${CONFIG} MATCHES "DEBUG")<br>> ><br>> > 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>
> > target_link_libraries(tst_xsystem libxsystem_so<br>> > ${libxsystm_LIBS}<br>> > ${libxsystem_so_LIBS}<br>> > pthread rt dl)<br>> ><br>> > Using ${CONFIG} is not portable, it will not work in generators, which<br>
> > support<br>> > multiple configurations.<br>><br>> i've taken it into account thanks (but no changes)<br>><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>> ><br>> > Why not use DEBUG_POSTFIX "d"?<br>
><br>> i can't use the postfix because the naming system of the company is not<br>> that simple. postfix will work for executables and static libs but shared<br>> ones are named lib_so and the debug name libd_so<br>
><br>> > > the problem is in the red line (marqued ########).<br>> > > names are differents and the error is<br>> > ><br>> > > Linking CXX executable<br>> ><br>> > /home/ikemgoum/workspace/reference/xsystem/code/os/linux_redhatEL4_0_i386<br>
> >__<br>> ><br>> > >gcc3_4/bin/tst_xsystemd /usr/bin/ld: can not find -llibxsystemd<br>> ><br>> > If libxsystemd is a target generated by cmake in the same project, you<br>> > don't<br>
> > need to bother with release/debug switches at all (I suppose).<br>><br>> it is what i supposed to but obviously it's not. libxsystem is a cmake<br>> target, static lib, and it's debug output name is libxsystemd<br>
><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.<br>><br>> i dont know how but this works in windows!! the debug name is found. i try<br>
> to add the cmake_library_path with the path of the output lib path but no<br>> changes.<br>> 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 "libsystemd")<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++ -g CMakeFiles/myapp.dir/myapp.o -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">><br>> if you have any idea thanks for help, very much.<br>><br>> > > am i missing something?<br>> ><br>> > Too many places where the problem could be. But looking at your code, I<br>
> > can say that you try to use CMake in wrong way. While used properly,<br>> > cmake makes<br>> > many things much simpler.<br>> ><br>> > > thanks for help<br><br></div></div></blockquote>
</div><br></div>