Making writing Config.cmake files easier - updated example

Alexander Neundorf neundorf at kde.org
Tue Jan 17 19:46:31 UTC 2012


On Tuesday 17 January 2012, Alexander Neundorf wrote:
> On Tuesday 17 January 2012, Yury G. Kudryashov wrote:
> > Alexander Neundorf wrote:
> > > On Tuesday 17 January 2012, Yury G. Kudryashov wrote:
> > >> so we need to ensure (or document?) that the
> > >> same directory used while writing MyLibConfig.cmake and installing it.
> > > 
> > > Hmm, I don't understand exactly what you mean, can you please explain a
> > > bit more ?
> > 
> > Look at the following code:
> > 
> > set(CMAKECONFIG_INSTALL_DIR lib/cmake/MyLib)
> > #MyLibConfig hardcodes $prefix/lib/cmake/MyLib
> > configure_file(MyLibConfig.cmake.in MyLibConfig.cmake)
> > #but is actually installed to a different directory
> > install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MyLibConig.cmake DESTINATION
> > lib/cmake)
> > 
> > My points are:
> > 1. The contents of MyLibConfigVersion.cmake does not depend on the
> > DESTINATION argument that will be passed to install(FILES).
> > 2. MyLibConfig.cmake content does.
> 
> I guess you want to show me that the example above is buggy, i.e. splitting
> creating and installing can lead to buggy cmake code, while combining it
> makes this impossible ?
> 
> > 3. Writing MyLibConfig.cmake to ${CMAKE_CURRENT_BINARY_DIR} is an
> > implementation detail, not a part of "public" API. We can hide this file
> > by placing it to CMakeFiles subdirectory.
> 
> As I said before, I wouldn't hide this file too much from the user. It
> should be easy for the developer to have a look at the file, IMO it
> shouldn't be hidden in a subdirectory.

Providing something which makes testing the installed files easier would be 
also good. I'm not sure yet how to do it.

Alex


More information about the Kde-buildsystem mailing list