Thanks, it solved it.<div><br></div><div>I thought that using set(a project_a) then using ${a} would be the same than using project_a (therefore I could use the same variable everywhere and simply change the target name in the set). But it seems it is not the same.</div>
<div><br></div><div>Thanks for you help :D. I will have another question later, but it will be for a different thread.</div><div><br></div><div>Ludo<br><br><div class="gmail_quote">2011/11/4 Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
On 11/04/2011 11:07 AM, Ludovic Hoyet wrote:<br>
[fixed top-post]<br>
><br>
> 2011/11/4 Michael Wild <<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a> <mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>>><br>
<div><div></div><div class="h5">><br>
> On 11/04/2011 10:47 AM, Ludovic Hoyet wrote:<br>
> > Hi,<br>
> ><br>
> > I am using cmake to build an application made up of a dozen<br>
> projects. We<br>
> > use cmake to automatically generate solutions for x86, x64, and<br>
> both VS<br>
> > 2005 and 2010.<br>
> ><br>
> > Here is an idea of our organisation:<br>
> ><br>
> > * a.lib, which has no dependency<br>
> > * b.lib, which has no dependency<br>
> > * c.lib, which depends on a and b<br>
> > * d.dll, which depends on c<br>
> ><br>
> > Each project lies in its own subdirectory, and has its own<br>
> > CMakeLists.txt file. In order to keep track of the lib/dll<br>
> generated for<br>
> > our different platforms, we automatically post-fix each lib/dll with<br>
> > _x86/_x64 and _vc80/_vc100 (e.g., a_x86_vc100.lib), and with an _d for<br>
> > debug (e.g., a_x86_vc100_d.lib).<br>
> ><br>
> > In the CMakeLists.txt files, I use target_link_libraries to link each<br>
> > target with the corresponding libraries, for instance:<br>
> ><br>
> > TARGET_LINK_LIBRARIES( c debug a_${VS}_${PLATFORM}/d optimized<br>
> > a/${VS_DIR}/${PLATFORM} debug b/${VS}_${PLATFORM}/d optimized<br>
> > b/${VS_DIR}_${PLATFORM})<br>
> ><br>
> > In Visual Studio, the different "Project Dependencies" between the<br>
> > various projects do not appear. I wonder if there is something I miss,<br>
> > or if it is simply not compatible with our library post-fix. I also<br>
> > tried to use ADD_DEPENDENCIES(c a b) but it does not seem to work<br>
> either.<br>
> ><br>
> > Does anyone has an idea how to solve this?<br>
> ><br>
> > Cheers,<br>
> ><br>
> > Ludovic<br>
><br>
><br>
> Are these projects completely isolated, i.e. there is no higher-level<br>
> CMakeLists.txt file that calls add_subdirectory() for each of the<br>
> project directories?<br>
><br>
> 1: if they belong to the same project, then you should use the *target*<br>
> names, not the *output* names in target_link_libraries().<br>
><br>
> 2: if they indeed are independent projects, you should take a look at<br>
> this:<br>
> <a href="http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file" target="_blank">http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file</a><br>
> and for each of the libraries create a <libname>Config.cmake file.<br>
><br>
> A bit more information on how your projects are structured would help.<br>
> Also, showing example code is always useful.<br>
><br>
> HTH<br>
><br>
> Michael<br>
><br>
</div></div><div><div></div><div class="h5">> No, they all belong to a higher-level project. There is a root directory<br>
> with a CMakeLists.txt. This file calls ADD_SUBDIRECTORY(dir_i) for each<br>
> subproject (a, b, c and d). Each sub-project is in his own directory,<br>
> with a CMakeLists.txt for each of them.<br>
><br>
> Root : CMakeLists.txt<br>
> - dir_a : CMakeLists.txt<br>
> - dir_b : CMakeLists.txt<br>
> - dir_c : CMakeLists.txt<br>
> - dir_d : CMakeLists.txt<br>
><br>
> In the root CMakeLists.txt I call<br>
> ADD_SUBDIRECTORY(dir_a)<br>
> ADD_SUBDIRECTORY(dir_b)<br>
> ADD_SUBDIRECTORY(dir_c)<br>
> ADD_SUBDIRECTORY(dir_d)<br>
><br>
> My a CMakeLists contains:<br>
> SET(a project_a)<br>
> add_library(${a} ${SRCS_a} ${HDRS_a})<br>
> SET_TARGET_PROPERTIES(${a} PROPERTIES OUTPUT_NAME ${a} DEBUG_POSTFIX<br>
> "_${VS_DIR}_${PLATFORM}_d" RELEASE_POSTFIX "_${VS_DIR}_${PLATFORM})<br>
><br>
> My c CMakeLists contains:<br>
> SET(c project_c)<br>
> add_library(${c} ${SRCS_c} ${HDRS_c})<br>
> ADD_DEPENDENCIES( ${c} ${a} )<br>
><br>
> I hope it is clearer now and that I provided the required information...<br>
><br>
> Ludo<br>
<br>
</div></div>Your c/CMakeLists.txt should look like this:<br>
<br>
set(c project_c)<br>
<div class="im">add_library(${c} ${SRCS_c} ${HDRS_c})<br>
</div>target_link_libraries(${c} project_a project_b)<br>
<br>
<br>
In CMake you should always use *target* names, CMake handles the rest<br>
for you. Also, the dependencies will be automagically handles this way.<br>
<font color="#888888"><br>
<br>
Michael<br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>_______________________________________<br><br>Ludovic Hoyet<br>Research Fellow, <div><span style="font-family:Tahoma, Helvetica, sans-serif;font-size:13px;line-height:16px;background-color:rgb(255, 255, 255)">Graphics Vision and Visualisation group,</span><br>
Trinity College Dublin<br><a href="http://www.scss.tcd.ie/~hoyetl/" target="_blank">http://www.scss.tcd.ie/~hoyetl/</a></div><br>
</div>