macro_optional_add_subdirectory()

Alexander Neundorf neundorf at kde.org
Tue Jan 15 00:01:34 CET 2008


On Sunday 13 January 2008, Stephen Kelly wrote:
> On Sunday 13 January 2008 14:18:03 Allen Winter wrote:
> > Howdy,
> >
> > Can we use macro_optional_add_subdirectory() for all project subdirs
> > in our module CMakeLists.txt files?
> >
> > Even the library subdirs?

It depends....
For library subdirs it can create more problems than for application subdirs 
(since in library subdirs libraries are created, which may be used by 
applications in application subdirs to link against, if these directories 
(and these libs (i.e. targets)) don't exist, it can break).

> > kdepim/CMakeLists.txt still uses plain old add_subdirectory() for
> > many of the subdirs and I would like to  know which ones I can
> > change to use macro_optional_add_subdirectory().
> >
> > -Allen
>
> My interest in this is that I wanted to compile kdepim/kmobiletools, and
> that requires that a lot of extras be compiled which look unneeded from my
> point of view.

Ok.
For the start I would suggest (as Allen does) to keep all library subdirs and 
make only the application subdirs optional. Then see how far you get.

> My attempt was to do the following:
>
> svn up -N kdepim
> cd kdepim
> svn up libkdepim kode akonadi libkholidays libkpgp libksieve mimelib
> kdganttl kresources cmake maildir knotes wizards plugins libkleo
> kmobiletools
>
> Even then I got this output:
>
> kde-devel at wopr:~/kde/src/KDE/kdepim$ cmakekde
> -- Found Qt-Version 4.3.2 (using /usr/bin/qmake)
> -- Found X11: /usr/lib/libX11.so
> -- Found KDE 4.0 include dir: /home/kde-devel/kde/include
> -- Found KDE 4 library dir: /home/kde-devel/kde/lib
> -- Found KDE4 kconfig_compiler
> preprocessor: /home/kde-devel/kde/bin/kconfig_compiler
> -- Found KDE4 automoc: /home/kde-devel/kde/bin/kde4automoc
> -- Found KDE PIM libraries
> -- Found Strigi: /usr/lib/libstreams.so
> -- Usable gpgme flavours found:  vanilla pthread pth
> -- Found qgpgme: libraries:
> qgpgme;gpgme++-pthread;/usr/lib/libgpgme-pthread.so;/usr/lib/libpthread.so;
>/usr/lib/libgpg-error.so -- Could not find OPTIONAL package GNOKII
> -- Found MySQL: /usr/include/mysql, /usr/lib/libmysqlclient.so
> -- Found MySQL Embedded: /usr/include/mysql, /usr/lib/mysql/libmysqld.a
> -- Found Nepomuk: /home/kde-devel/kde/lib/libnepomuk.so
> CMake Error: Error in cmake code at
> /home/kde-devel/kde/src/KDE/kdepim/CMakeLists.txt:93:
> INCLUDE Could not find include file: kleopatra/ConfigureChecks.cmake
> Current CMake stack:
> [1]     /home/kde-devel/kde/src/KDE/kdepim/CMakeLists.txt

So don't skip kleopatra.
Or don't include kleopatra/ConfigureChecks.txt, which may be the better way. 
Why is it included in the top level file ? It would be better if it was 
included in the subdirectory where it lives and also create its own 
kleo-config.h there (or something like this).

I had a quick look at that file. 
This is not good:
set( CMAKE_REQUIRED_LIBRARIES ${ASSUAN_VANILLA_LIBRARIES} )
...
set(CMAKE_REQUIRED_LIBRARIES)

Better use the following:
include(MacroPushRequiredVars)
macro_push_required_vars()
set( CMAKE_REQUIRED_LIBRARIES ${ASSUAN_VANILLA_LIBRARIES} )
...
macro_pop_required_vars()

This has the advantage that all these CMAKE_REQUIRED_XXX variables are stored, 
and at the end reset to their previous values.


There is a ONLY_KLEO variable in kdepim/CMakeLists.txt. There has been a 
request from a Gentoo packager how to package a single application from one 
module. You are asking basically for the same.
So it seems we really have to come up with a clean and generic solution for 
that for 4.1 I think.

Alex


More information about the Kde-buildsystem mailing list