[CMake] Making it easier for downstreams to use my library
Andreas Pakulat
apaku at gmx.de
Fri Apr 9 04:50:52 EDT 2010
On 09.04.10 09:53:03, Stephen Kelly wrote:
> Hi,
>
> I've just tagged and tarballed a release candidate of Grantlee version
> 0.1.0. Grantlee is a Free Software string template system written in Qt and
> using CMake for its build system.[1]
>
> Most of my CMake knowledge is about writing simple CMakeLists.txt files to
> consume other libraries. Writing the necessary CMake files to so that
> downstreams can use my library is harder and I'm not sure I've done it
> right.
>
> I'd appreciate some review of the CMake stuff if anyone has the time and
> inclination.
>
> In particular, I'm not sure I'm doing the GrantleeUse.cmake file stuff
> correctly. I'm include()ing the Use file in my CMakeLists.txt file so that I
> can use its macros. Is that the usual way to do these things?[3]
>
> Also, the GrantleeConfig.cmake file looks wrong to me, but I don't know the
> right way to implement it. There's a lot of if(UNIX) etc for things which
> CMake must already know. I believe the solution I need there is importing
> and exporting the library, but I haven't figured out how to do it. [3]
Without having had a look at the actual code (I'll try to do that later),
one relatively simple example of libraries being exported and imported is
kdevplatform in KDE's svn. It generates a Config file that supports version
check, setting an include-dir and exporting of all its libraries. There's
also a separate file which contains cmake macros to support one of our
plugins.
Obviously kdevelop uses this stuff to find kdevplatform and also uses the
macro.
See
http://websvn.kde.org/trunk/extragear/sdk/kdevplatform/CMakeLists.txt?revision=1110255&view=markup
http://websvn.kde.org/trunk/extragear/sdk/kdevplatform/KDevPlatformConfig.cmake.in?revision=1067032&view=markup
http://websvn.kde.org/trunk/extragear/sdk/kdevplatform/cmake/modules/KDevPlatformMacros.cmake?revision=1082886&view=markup
http://websvn.kde.org/trunk/extragear/sdk/kdevelop/CMakeLists.txt?revision=1110254&view=markup
(You can ignore the fact that there is a FindKDevPlatform.cmake installed
by kdelibs and also inside of kdevelop, its just a very thing wrapper for
cmake's find_package( MODULE ) mode)
We just don't have a use-file, but that would be relatively easy and in
fact its common to just include() such a use-file.
Andreas
--
Caution: Keep out of reach of children.
More information about the CMake
mailing list