Hi, my 2c...

2008/11/10 Andreas Pakulat <[EMAIL PROTECTED]>

On 10.11.08 12:01:13, Fernando Cacciola wrote:
> The CGAL library (www.cgal.org) uses cmake as build system. Thus, our
> users do:
>
> find_package(CGAL REQUIRED)
> include( ${CGAL_USE_FILE} )


>
>
> There are projects that have headers that are usable without linking
> against any library. There are also projects installing their headers into
> a common place, that have multiple libraries. In that latter case you'd
> have include_directories() point to the common place for the headers, but
> obviously you can't know which of the libraries needs to be linked in.
>
> Boost is a good example (albeit it doesn't use cmake to build itself).


they have just added cmake support, i think it was just added to the trunk


>
> There are various libraries shipped with it, they all install their headers
> into <includedir>/boost/<libraryname>/ and the libs are of course directly
> in <libdir>. And its common practice to have only <includedir>/boost in the
> include-directories.
>

i would disagree, its common practice to have only <includedir> in the
include-directories, and then you
#include <boost/shared_ptr.hpp>


>
> For the case of a single library with a few headers, for which a UseXXX
> file is provided the requirement really doesn't make much sense (IMHO) -
> unless you can use some of the headers without linking.
>

(snipped from above)

> On 10.11.08 12:01:13, Fernando Cacciola wrote:
> > Well, I'm questioning this recommended practice because it's half baked:
> > It makes sense to allow users to control which targets are linked
> > against CGAL, but NOT if OTOH they cannot control which targets are
> > given the CGAL include directories, definitions and flags.
> >
> > That is, IMO, target_link_libraries makes little sense in the absence of
> > target_include_directories, target_add_definitions and target_*_FLAGS.
> >
> > What it's so special about linking that only that command can be made
> > target specific???
>
>
I can specify which headers I want to include by writing #includes in my
.cpp file.

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.

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'.

Paul
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to