[cmake-developers] install-interface-includes topic

Stephen Kelly steveire at gmail.com
Mon Jul 15 11:25:10 EDT 2013


Brad King wrote:

> Steve,
> 
> From the documentation of the feature:
> 
> +      "The INCLUDES DESTINATION specifies a list of directories which
> will "
> +      "be added to the INTERFACE_INCLUDE_DIRECTORIES of the <targets>
> when "
> +      "exported by install(EXPORT).  If a relative path is specified, it
> is "
> +      "treated as relative to the $<INSTALL_PREFIX>.  "
> 
> Should the "INCLUDES DESTINATION" option produce an error if it is
> used without the EXPORT option?

Good question.

Actually it led me to think the current implementation is not correct.

Is something like this realistic? (I've not done anything like it):

 add_library(foo foo.cpp)
 install(TARGETS foo EXPORT RegularExport 
   ARCHIVE DESTINATION lib ... 
   INCLUDES DESTINATION include
 )
 install(TARGETS foo EXPORT OtherExport 
   ARCHIVE DESTINATION /other/prefix/lib ... 
   INCLUDES DESTINATION /other/prefix/include
 )

 install(FILES foo.h 
   DESTINATION include)
 install(FILES foo.h 
   DESTINATION /other/prefix/include)

 install(EXPORT RegularExport FILE regularTargets.cmake 
   DESTINATION lib/cmake/Regular)
 install(EXPORT OtherExport FILE otherTargets.cmake 
   DESTINATION /other/prefix/lib/cmake/Other)

 install(FILES RegularConfig.cmake 
   DESTINATION lib/cmake/Regular)
 install(FILES OtherConfig.cmake 
   DESTINATION /other/prefix/lib/cmake/Other)


The problem with the above is that the generated IMPORTED targets in both 
*Targets.cmake files have 

 INTERFACE_INCLUDE_DIRECTORIES 
   "${_IMPORT_PREFIX}/include;/other/prefix/include"

Despite the fact that the /other/prefix/include does not necessarily exist.

The solution I think is to add the specified include directories to the 
cmTargetExport instance which gets created when using the EXPORT, and to 
append the directories only when generating.

Then, yes, this new signature requires that the EXPORT is specified and I 
can add an error if it is not used.

Thanks,

Steve.





More information about the cmake-developers mailing list