Hi, my 2c...<br><br><div class="gmail_quote">2008/11/10 Andreas Pakulat <span dir="ltr"><<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>></span><br><div><br>On 10.11.08 12:01:13, Fernando Cacciola wrote:<br>
> The CGAL library (<a href="http://www.cgal.org/" target="_blank">www.cgal.org</a>) uses cmake as build system. Thus, our<br>
> users do:<br>
><br>
> find_package(CGAL REQUIRED)<br>
> include( ${CGAL_USE_FILE} )<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
<br>
</div>There are projects that have headers that are usable without linking<br>
against any library. There are also projects installing their headers into<br>
a common place, that have multiple libraries. In that latter case you'd<br>
have include_directories() point to the common place for the headers, but<br>
obviously you can't know which of the libraries needs to be linked in.<br>
<br>
Boost is a good example (albeit it doesn't use cmake to build itself).</blockquote><div><br>they have just added cmake support, i think it was just added to the trunk<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
There are various libraries shipped with it, they all install their headers<br>
into <includedir>/boost/<libraryname>/ and the libs are of course directly<br>
in <libdir>. And its common practice to have only <includedir>/boost in the<br>
include-directories.<br>
</blockquote><div><br>i would disagree, its common practice to have only <includedir> in the include-directories, and then you<br>#include <boost/shared_ptr.hpp><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
For the case of a single library with a few headers, for which a UseXXX<br>
file is provided the requirement really doesn't make much sense (IMHO) -<br>
unless you can use some of the headers without linking.<br>
</blockquote><br>(snipped from above)<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">On 10.11.08 12:01:13, Fernando Cacciola wrote:<br>
> Well, I'm questioning this recommended practice because it's half baked:<br><div>
> It makes sense to allow users to control which targets are linked<br>
> against CGAL, but NOT if OTOH they cannot control which targets are<br>
> given the CGAL include directories, definitions and flags.<br>
><br>
> That is, IMO, target_link_libraries makes little sense in the absence of<br>
> target_include_directories, target_add_definitions and target_*_FLAGS.<br>
><br>
> What it's so special about linking that only that command can be made<br>
> target specific???</div><br></blockquote></div><br>I can specify which headers I want to include by writing #includes in my .cpp file.<br><br>But the ONLY place I can specify which libraries I want to include is within CMake config files. Thus, you only need target_link_libraries and not target_add_directories.<br>
<br>As for target_add_definitions, you don't add definitions to a target, you add them to cpp files you are compiling. I think you can define them for certain files if you have the add_definition in a subdirectory CMakeLists.txt, but I'm not sure how else you can limit its 'scope'.<br>
<br>Paul<br><br>