[cmake-developers] IMPORTED targets for some Find modules

Philipp Moeller bootsarehax at gmail.com
Wed Jun 25 10:14:02 EDT 2014


Stephen Kelly <steveire at gmail.com> writes:

> Philipp Moeller wrote:
>
>> Nils Gladitz <nilsgladitz at gmail.com>
>> writes:
>>> I would like that very much as well.
>> 
>> I'll look into doing that. I think populating
>> INTERFACE_COMPILE_DEFINTIONS with BOOST_${LIBRARY_NAME}_NO_LIB seems the
>> obvious choice. 
>
> Yes.
>
>> In addition I can provide a Boost::disable_autolinking
>> target to disable it for the complete library.
>
> Also consider a CMake variable to disable the addition of the defines (by 
> not linking the interface targets).
>
>  set(Boost_ENABLE_AUTOLINKING 1)
>  find_package(Boost)

I really would like to do that, but for that to work we need a
LINK_DIRECTORIES property. I opened a feature request for this some time
ago.

Let me give a quick summary of how auto-linking works so we have a
common understanding of it:

A header uses pragma comment(lib, library_name.lib). This triggers the
compiler to look for library_name.lib in all specified and implicit link
directories.

I think this sums up what we need: If we enable auto-linking the
IMPORTED targets need to be INTERFACE targets that propagate a
INTERFACE_LINK_DIRECTORY property if the compiler supports
auto-linking. If it is disabled or the compiler does not support it, we
need a UNKNOWN or STATIC library target with an
INTERFACE_COMPILE_DEFINITIONS to disable auto-linking.




More information about the cmake-developers mailing list