[CMake] Library locations returned by find_package() and find_library()

Mateusz Loskot mateusz at loskot.net
Thu Dec 6 15:51:01 EST 2012


On 6 December 2012 18:45, Andreas Pakulat <apaku at gmx.de> wrote:
> On Thu, Dec 6, 2012 at 5:13 PM, Mateusz Loskot <mateusz at loskot.net> wrote:
>> The CMake 2.8.10 manual includes the following statement in the paragraph
>> about link_directories() command:
>>
>> "Library locations returned by find_package() and find_library() are
>> absolute paths."
>>
>> Would it be possible to include similar clarification in the sections for
>> find_package() and find_library()?
>>
>> A user of my library asked why
>> XXX_INCLUDE_DIR takes directory location, but
>> XXX_LIBRARIES takes absolute path to library file(s).
>>
>> I've found it difficult to explain the rationale really.
>> I could not find any back up in the manual.
>
> Thats two unrelated things really.


Andreas,

Yes, that is perfectly clear these two are very different and
unrelated settings.

> For libraries cmake needs to know
> the absolute path if possible to setup proper dependencies in
> target_link_libraries and to make sure that the linker links against
> exactly that library and not some library with the same name that
> happens to be in a directory further in the front of the linker
> commandline.

These two reasons are what I'm looking for.

> For include directories things are different, since the mechanism for
> those is different. In particular the pre-processor does not allow
> include files to be listed on the commandline. Instead you give it a
> couple of directories where to search.

Yes, the pre-processor constraint is clear.

> Dependencies of this are
> generated by CMake parsing the source files.

That's new.

For Visual Studio users as well as GNU toolset users,
separation of linker directories from library names is quite common,
if not obvious. So, I think it would be good if the documentation provides
relevant explanation here.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net


More information about the CMake mailing list