[cmake-developers] [CMake 0013460]: Use the same mechanism for export() as for install(EXPORT)

Mantis Bug Tracker mantis at public.kitware.com
Mon Aug 6 12:36:41 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13460 
====================================================================== 
Reported By:                Michael Tänzer
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13460
Category:                   CMake
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-08-06 18:36 CEST
Last Modified:              2012-08-06 18:36 CEST
====================================================================== 
Summary:                    Use the same mechanism for export() as for
install(EXPORT)
Description: 
I have a CMake project that compiles some libraries statically or both shared
and static if BUILD_SHARED_LIBS is set. In the second case another target called
mylib_static is defined (BTW: would be cool if there was real support for these
cases because as it is now it has to be compiled twice, but that's another
story). myotherlib links to mylib.

The install(EXPORT) syntax is perfect because I just can define
install(TARGETS mylib ${mylib_static_TARGET} EXPORT myproject-targets)
in one subdir,
install(TARGETS myotherlib ${myotherlib_static_TARGET} EXPORT myproject-targets)
in the other subdir and
install(EXPORT myproject-targets)
in the top level directory and everything gets exported in just one cmake file.

Here comes the problem: if I use
export(TARGETS mylib ${mylib_static_TARGET} FILE mylib-exports.cmake)
in one subdir and
export(TARGETS myotherlib ${myotherlib_static_TARGET} mylib FILE
myotherlib-exports.cmake)
in the other one (mylib is needed as CMake complains otherwise that the target
myotherlib links to is not included in the export file). I can't just do the
following in a myproject-config.cmake.in
include("@myproject_BINARY_DIR@/source/mylib/mylib-exports.cmake")
include("@myproject_BINARY_DIR@/source/myotherlib/myotherlib-exports.cmake")
because then the mylib target would be redefined.

I could do the exports in the top-level file but then I would have to edit it
whenever a new library gets added (yeah, I know, I'm lazy) and also always
propagate the <lib>_static_TARGET variable to the PARENT_SCOPE for each
subdirectory in between.

Would be nice to have a consistent solution. Maybe make the install(EXPORT) also
available for the local build directory so there's two things generated from the
same command (a file in the build directory on compilation and a file in the
DESTINATION on install). Or something completely different.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-08-06 18:36 Michael Tänzer New Issue                                    
======================================================================




More information about the cmake-developers mailing list