[cmake-developers] FindBZip2 (was: Dashboard issues with ExternalProject)

Alexander Neundorf neundorf at kde.org
Wed Jan 11 16:13:57 EST 2012


On Wednesday 11 January 2012, Rolf Eike Beer wrote:
> Am Mittwoch, 11. Januar 2012, 15:32:47 schrieb Brad King:
> > On 1/11/2012 1:31 PM, Rolf Eike Beer wrote:
> > > Am Mittwoch 11 Januar 2012, 13:24:42 schrieben Sie:
> > >> The top-level CMakeLists.txt file in CMake needs to pre-load BZIP2_*
> > >> with whatever is needed to convince find_package(BZIP2) to use the
> > >> CMake-built cmbzip2 library.  If you're changing the Find module for
> > >> it then what needs to be pre-loaded may depend on which version of
> > >> CMake is used to configure the build of CMake.  It's a bit tricky.
> > > 
> > > I pushed an updated version to topic improve-findbzip2, hopefully that
> > > would do it. Does this look sane?
> > 
> > Since you're changing the way that module looks for libraries you should
> > also fix up some historical wrongness in it.  The Module/readme.txt file
> > explains that BZIP2_LIBRARIES should not be a cache variable.  Instead
> > it should be a normal variable that collects the results from other
> > single-library searches.  Ideally the module (with config support) should
> > 
> > offer these cache entries for users to set:
> >   BZIP2_LIBRARY_RELEASE
> >   BZIP2_LIBRARY_DEBUG
> > 
> > and the output should all be in a single
> > 
> >   set(BZIP2_LIBRARIES optimized ${BZIP2_LIBRARY_RELEASE}
> >   
> >                           debug ${BZIP2_LIBRARY_DEBUG})
> 
> That's the way we currently have in next.

How about creating an imported target and use ${BZIP2_LIBRARY_RELEASE} and 
${BZIP2_LIBRARY_DEBUG} to set the respective LOCATION properties ?
Like
add_library(ImportedLibrary::Bzip2 IMPORTED )
set_target_properties(ImportedLibrary::Bzip2
                      PROPERTIES IMPORTED_CONFIGS DEBUG;RELEASE
                                 LOCATION_DEBUG ${BZIP2_LIBRARY_DEBUG}
                                 LOCATION_RELEASE ${BZIP2_LIBRARY_RELEASE} )

set(BZIP2_LIBRARIES ImportedLibrary::Bzip2 )

There is a small source incompatiblity, in the case that somebody assumes                                
that BZIP2_LIBRARIES contains a file path, but beside that, it's a good thing 
and makes stuff work better on Windows (since if another project installs an 
exported targets file, and if those targets have been linked against the 
installed bzip2-target, they will reference the target in their export file, 
which will be found by FindBZip2.cmake at cmake-time of a using project on the 
end system, instead of depending on the full fixed path to libbzip2 on the 
developer system).

FindQt4.cmake does already create imported targets for the libs it finds.

Alex



More information about the cmake-developers mailing list