Library locations returned by find_package() and find_library()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Library locations returned by find_package() and find_library()

Mateusz Loskot
Hi,

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.

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

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
--
Mateusz Loskot
http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Re: Library locations returned by find_package() and find_library()

Andreas Pakulat-2
Hi,

On Thu, Dec 6, 2012 at 5:13 PM, Mateusz Loskot <[hidden email]> 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. 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.

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. Dependencies of this are
generated by CMake parsing the source files.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Library locations returned by find_package() and find_library()

Mateusz Loskot
On 6 December 2012 18:45, Andreas Pakulat <[hidden email]> wrote:

> On Thu, Dec 6, 2012 at 5:13 PM, Mateusz Loskot <[hidden email]> 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
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
--
Mateusz Loskot
http://mateusz.loskot.net